$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #define BOOST_TEST_MODULE RoundRobin_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(RoundRobin_policy_t) 00010 00011 BOOST_AUTO_TEST_CASE(Simple) 00012 { 00013 fhicl::ParameterSet ps; 00014 fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4]", ps); 00015 00016 auto rr = artdaq::makeRoutingMasterPolicy("RoundRobin", ps); 00017 00018 BOOST_REQUIRE_EQUAL(rr->GetReceiverCount(), 4); 00019 00020 rr->Reset(); 00021 rr->AddReceiverToken(1, 1); 00022 rr->AddReceiverToken(3, 1); 00023 rr->AddReceiverToken(2, 1); 00024 rr->AddReceiverToken(4, 1); 00025 rr->AddReceiverToken(2, 1); 00026 auto secondTable = rr->GetCurrentTable(); 00027 BOOST_REQUIRE_EQUAL(secondTable.size(), 4); 00028 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1); 00029 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2); 00030 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 3); 00031 BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 4); 00032 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 1); 00033 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 2); 00034 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 3); 00035 BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 4); 00036 00037 rr->AddReceiverToken(1, 0); 00038 00039 auto thirdTable = rr->GetCurrentTable(); 00040 BOOST_REQUIRE_EQUAL(thirdTable.size(), 0); 00041 00042 rr->AddReceiverToken(1, 2); 00043 rr->AddReceiverToken(2, 1); 00044 rr->AddReceiverToken(3, 1); 00045 rr->AddReceiverToken(4, 2); 00046 auto fourthTable = rr->GetCurrentTable(); 00047 BOOST_REQUIRE_EQUAL(fourthTable.size(), 4); 00048 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1); 00049 00050 rr->AddReceiverToken(3, 1); 00051 auto fifthTable = rr->GetCurrentTable(); 00052 BOOST_REQUIRE_EQUAL(fifthTable.size(), 4); 00053 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 1); 00054 00055 } 00056 00057 BOOST_AUTO_TEST_CASE(MinimumParticipants) 00058 { 00059 fhicl::ParameterSet ps; 00060 fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4] minimum_participants: 2", ps); 00061 00062 auto rr = artdaq::makeRoutingMasterPolicy("RoundRobin", ps); 00063 00064 BOOST_REQUIRE_EQUAL(rr->GetReceiverCount(), 4); 00065 00066 rr->Reset(); 00067 rr->AddReceiverToken(1, 1); 00068 rr->AddReceiverToken(3, 1); 00069 rr->AddReceiverToken(2, 1); 00070 rr->AddReceiverToken(4, 1); 00071 rr->AddReceiverToken(2, 1); 00072 auto secondTable = rr->GetCurrentTable(); 00073 BOOST_REQUIRE_EQUAL(secondTable.size(), 4); 00074 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1); 00075 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2); 00076 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 3); 00077 BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 4); 00078 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 1); 00079 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 2); 00080 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 3); 00081 BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 4); 00082 00083 rr->AddReceiverToken(1, 0); 00084 00085 auto thirdTable = rr->GetCurrentTable(); 00086 BOOST_REQUIRE_EQUAL(thirdTable.size(), 0); 00087 00088 00089 rr->AddReceiverToken(1, 1); 00090 auto fourthTable = rr->GetCurrentTable(); 00091 BOOST_REQUIRE_EQUAL(fourthTable.size(), 2); 00092 00093 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1); 00094 BOOST_REQUIRE_EQUAL(fourthTable[1].destination_rank, 2); 00095 BOOST_REQUIRE_EQUAL(fourthTable[0].sequence_id, 5); 00096 BOOST_REQUIRE_EQUAL(fourthTable[1].sequence_id, 6); 00097 00098 rr->AddReceiverToken(1, 2); 00099 rr->AddReceiverToken(2, 2); 00100 rr->AddReceiverToken(3, 1); 00101 rr->AddReceiverToken(4, 2); 00102 auto fifthTable = rr->GetCurrentTable(); 00103 BOOST_REQUIRE_EQUAL(fifthTable.size(), 7); 00104 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 1); 00105 00106 rr->AddReceiverToken(3, 1); 00107 auto sixthTable = rr->GetCurrentTable(); 00108 BOOST_REQUIRE_EQUAL(sixthTable.size(), 0); 00109 00110 } 00111 00112 BOOST_AUTO_TEST_SUITE_END()