$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #define BOOST_TEST_MODULE CapacityTest_policy_t 00002 #include <boost/test/auto_unit_test.hpp> 00003 00004 #include "artdaq/Application/Routing/makeRoutingMasterPolicy.hh" 00005 #include "fhiclcpp/ParameterSet.h" 00006 #include "fhiclcpp/make_ParameterSet.h" 00007 00008 00009 BOOST_AUTO_TEST_SUITE(CapacityTest_policy_t) 00010 00011 BOOST_AUTO_TEST_CASE(Simple) 00012 { 00013 fhicl::ParameterSet ps; 00014 fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4] tokens_used_per_table_percent: 50", ps); 00015 00016 auto ct = artdaq::makeRoutingMasterPolicy("CapacityTest", ps); 00017 00018 BOOST_REQUIRE_EQUAL(ct->GetReceiverCount(), 4); 00019 00020 00021 00022 ct->AddReceiverToken(1, 10); 00023 ct->AddReceiverToken(2, 10); 00024 ct->AddReceiverToken(3, 10); 00025 ct->AddReceiverToken(4, 10); 00026 auto firstTable = ct->GetCurrentTable(); 00027 BOOST_REQUIRE_EQUAL(firstTable.size(), 20); 00028 BOOST_REQUIRE_EQUAL(firstTable[0].destination_rank, 1); 00029 BOOST_REQUIRE_EQUAL(firstTable[0].sequence_id, 1); 00030 BOOST_REQUIRE_EQUAL(firstTable[firstTable.size() - 1].destination_rank, 2); 00031 BOOST_REQUIRE_EQUAL(firstTable[firstTable.size() - 1].sequence_id,20); 00032 00033 //ct->Reset(); 00034 ct->AddReceiverToken(1, 1); 00035 ct->AddReceiverToken(3, 1); 00036 ct->AddReceiverToken(2, 1); 00037 ct->AddReceiverToken(4, 1); 00038 ct->AddReceiverToken(2, 1); 00039 auto secondTable = ct->GetCurrentTable(); 00040 BOOST_REQUIRE_EQUAL(secondTable.size(), 13); 00041 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1); 00042 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 21); 00043 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2); 00044 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 22); 00045 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 2); 00046 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 23); 00047 BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 3); 00048 BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 24); 00049 BOOST_REQUIRE_EQUAL(secondTable[4].destination_rank, 3); 00050 BOOST_REQUIRE_EQUAL(secondTable[4].sequence_id, 25); 00051 BOOST_REQUIRE_EQUAL(secondTable[5].destination_rank, 3); 00052 BOOST_REQUIRE_EQUAL(secondTable[5].sequence_id, 26); 00053 BOOST_REQUIRE_EQUAL(secondTable[6].destination_rank, 3); 00054 BOOST_REQUIRE_EQUAL(secondTable[6].sequence_id, 27); 00055 BOOST_REQUIRE_EQUAL(secondTable[7].destination_rank, 3); 00056 BOOST_REQUIRE_EQUAL(secondTable[7].sequence_id, 28); 00057 BOOST_REQUIRE_EQUAL(secondTable[8].destination_rank, 3); 00058 BOOST_REQUIRE_EQUAL(secondTable[8].sequence_id, 29); 00059 BOOST_REQUIRE_EQUAL(secondTable[9].destination_rank, 3); 00060 BOOST_REQUIRE_EQUAL(secondTable[9].sequence_id, 30); 00061 BOOST_REQUIRE_EQUAL(secondTable[10].destination_rank, 3); 00062 BOOST_REQUIRE_EQUAL(secondTable[10].sequence_id, 31); 00063 BOOST_REQUIRE_EQUAL(secondTable[11].destination_rank, 3); 00064 BOOST_REQUIRE_EQUAL(secondTable[11].sequence_id, 32); 00065 BOOST_REQUIRE_EQUAL(secondTable[12].destination_rank, 3); 00066 BOOST_REQUIRE_EQUAL(secondTable[12].sequence_id, 33); 00067 00068 //ct->Reset(); 00069 ct->AddReceiverToken(1, 0); 00070 auto thirdTable = ct->GetCurrentTable(); 00071 BOOST_REQUIRE_EQUAL(thirdTable.size(), 6); 00072 BOOST_REQUIRE_EQUAL(thirdTable[0].destination_rank, 3); 00073 BOOST_REQUIRE_EQUAL(thirdTable[0].sequence_id, 34); 00074 BOOST_REQUIRE_EQUAL(thirdTable[1].destination_rank, 4); 00075 BOOST_REQUIRE_EQUAL(thirdTable[1].sequence_id, 35); 00076 BOOST_REQUIRE_EQUAL(thirdTable[2].destination_rank, 4); 00077 BOOST_REQUIRE_EQUAL(thirdTable[2].sequence_id, 36); 00078 BOOST_REQUIRE_EQUAL(thirdTable[3].destination_rank, 4); 00079 BOOST_REQUIRE_EQUAL(thirdTable[3].sequence_id, 37); 00080 BOOST_REQUIRE_EQUAL(thirdTable[4].destination_rank, 4); 00081 BOOST_REQUIRE_EQUAL(thirdTable[4].sequence_id, 38); 00082 BOOST_REQUIRE_EQUAL(thirdTable[5].destination_rank, 4); 00083 BOOST_REQUIRE_EQUAL(thirdTable[5].sequence_id, 39); 00084 00085 ct->AddReceiverToken(1, 2); 00086 ct->AddReceiverToken(2, 1); 00087 ct->AddReceiverToken(3, 1); 00088 ct->AddReceiverToken(4, 2); 00089 auto fourthTable = ct->GetCurrentTable(); 00090 BOOST_REQUIRE_EQUAL(fourthTable.size(), 6); 00091 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1); 00092 BOOST_REQUIRE_EQUAL(fourthTable[0].sequence_id, 40); 00093 BOOST_REQUIRE_EQUAL(fourthTable[1].destination_rank, 1); 00094 BOOST_REQUIRE_EQUAL(fourthTable[1].sequence_id, 41); 00095 BOOST_REQUIRE_EQUAL(fourthTable[2].destination_rank, 2); 00096 BOOST_REQUIRE_EQUAL(fourthTable[2].sequence_id, 42); 00097 BOOST_REQUIRE_EQUAL(fourthTable[3].destination_rank, 3); 00098 BOOST_REQUIRE_EQUAL(fourthTable[3].sequence_id, 43); 00099 BOOST_REQUIRE_EQUAL(fourthTable[4].destination_rank, 4); 00100 BOOST_REQUIRE_EQUAL(fourthTable[4].sequence_id, 44); 00101 BOOST_REQUIRE_EQUAL(fourthTable[5].destination_rank, 4); 00102 BOOST_REQUIRE_EQUAL(fourthTable[5].sequence_id, 45); 00103 00104 ct->AddReceiverToken(3, 1); 00105 auto fifthTable = ct->GetCurrentTable(); 00106 BOOST_REQUIRE_EQUAL(fifthTable.size(), 4); 00107 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 3); 00108 BOOST_REQUIRE_EQUAL(fifthTable[0].sequence_id, 46); 00109 BOOST_REQUIRE_EQUAL(fifthTable[1].destination_rank, 4); 00110 BOOST_REQUIRE_EQUAL(fifthTable[1].sequence_id, 47); 00111 BOOST_REQUIRE_EQUAL(fifthTable[2].destination_rank, 4); 00112 BOOST_REQUIRE_EQUAL(fifthTable[2].sequence_id, 48); 00113 BOOST_REQUIRE_EQUAL(fifthTable[3].destination_rank, 4); 00114 BOOST_REQUIRE_EQUAL(fifthTable[3].sequence_id, 49); 00115 00116 ct->Reset(); 00117 ct->AddReceiverToken(1, 2); 00118 auto sixthTable = ct->GetCurrentTable(); 00119 BOOST_REQUIRE_EQUAL(sixthTable.size(), 1); 00120 BOOST_REQUIRE_EQUAL(sixthTable[0].destination_rank, 1); 00121 BOOST_REQUIRE_EQUAL(sixthTable[0].sequence_id, 1); 00122 } 00123 00124 BOOST_AUTO_TEST_SUITE_END()