1 #define BOOST_TEST_MODULE ( CapacityTest_policy_t )
2 #include "boost/test/auto_unit_test.hpp"
4 #include "artdaq/Application/Routing/makeRoutingMasterPolicy.hh"
5 #include "fhiclcpp/ParameterSet.h"
6 #include "fhiclcpp/make_ParameterSet.h"
9 BOOST_AUTO_TEST_SUITE(CapacityTest_policy_t)
13 fhicl::ParameterSet ps;
14 fhicl::make_ParameterSet(
"receiver_ranks: [1,2,3,4] tokens_used_per_table_percent: 50", ps);
18 BOOST_REQUIRE_EQUAL(ct->GetReceiverCount(), 4);
22 ct->AddReceiverToken(1, 10);
23 ct->AddReceiverToken(2, 10);
24 ct->AddReceiverToken(3, 10);
25 ct->AddReceiverToken(4, 10);
26 auto firstTable = ct->GetCurrentTable();
27 BOOST_REQUIRE_EQUAL(firstTable.size(), 20);
28 BOOST_REQUIRE_EQUAL(firstTable[0].destination_rank, 1);
29 BOOST_REQUIRE_EQUAL(firstTable[0].sequence_id, 0);
30 BOOST_REQUIRE_EQUAL(firstTable[firstTable.size() - 1].destination_rank, 2);
31 BOOST_REQUIRE_EQUAL(firstTable[firstTable.size() - 1].sequence_id, 19);
34 ct->AddReceiverToken(1, 1);
35 ct->AddReceiverToken(3, 1);
36 ct->AddReceiverToken(2, 1);
37 ct->AddReceiverToken(4, 1);
38 ct->AddReceiverToken(2, 1);
39 auto secondTable = ct->GetCurrentTable();
40 BOOST_REQUIRE_EQUAL(secondTable.size(), 13);
41 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1);
42 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 0);
43 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2);
44 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 1);
45 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 2);
46 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 2);
47 BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 3);
48 BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 3);
49 BOOST_REQUIRE_EQUAL(secondTable[4].destination_rank, 3);
50 BOOST_REQUIRE_EQUAL(secondTable[4].sequence_id, 4);
51 BOOST_REQUIRE_EQUAL(secondTable[5].destination_rank, 3);
52 BOOST_REQUIRE_EQUAL(secondTable[5].sequence_id, 5);
53 BOOST_REQUIRE_EQUAL(secondTable[6].destination_rank, 3);
54 BOOST_REQUIRE_EQUAL(secondTable[6].sequence_id, 6);
55 BOOST_REQUIRE_EQUAL(secondTable[7].destination_rank, 3);
56 BOOST_REQUIRE_EQUAL(secondTable[7].sequence_id, 7);
57 BOOST_REQUIRE_EQUAL(secondTable[8].destination_rank, 3);
58 BOOST_REQUIRE_EQUAL(secondTable[8].sequence_id, 8);
59 BOOST_REQUIRE_EQUAL(secondTable[9].destination_rank, 3);
60 BOOST_REQUIRE_EQUAL(secondTable[9].sequence_id, 9);
61 BOOST_REQUIRE_EQUAL(secondTable[10].destination_rank, 3);
62 BOOST_REQUIRE_EQUAL(secondTable[10].sequence_id, 10);
63 BOOST_REQUIRE_EQUAL(secondTable[11].destination_rank, 3);
64 BOOST_REQUIRE_EQUAL(secondTable[11].sequence_id, 11);
65 BOOST_REQUIRE_EQUAL(secondTable[12].destination_rank, 3);
66 BOOST_REQUIRE_EQUAL(secondTable[12].sequence_id, 12);
69 ct->AddReceiverToken(1, 0);
70 auto thirdTable = ct->GetCurrentTable();
71 BOOST_REQUIRE_EQUAL(thirdTable.size(), 6);
72 BOOST_REQUIRE_EQUAL(thirdTable[0].destination_rank, 3);
73 BOOST_REQUIRE_EQUAL(thirdTable[0].sequence_id, 0);
74 BOOST_REQUIRE_EQUAL(thirdTable[1].destination_rank, 4);
75 BOOST_REQUIRE_EQUAL(thirdTable[1].sequence_id, 1);
76 BOOST_REQUIRE_EQUAL(thirdTable[2].destination_rank, 4);
77 BOOST_REQUIRE_EQUAL(thirdTable[2].sequence_id, 2);
78 BOOST_REQUIRE_EQUAL(thirdTable[3].destination_rank, 4);
79 BOOST_REQUIRE_EQUAL(thirdTable[3].sequence_id, 3);
80 BOOST_REQUIRE_EQUAL(thirdTable[4].destination_rank, 4);
81 BOOST_REQUIRE_EQUAL(thirdTable[4].sequence_id, 4);
82 BOOST_REQUIRE_EQUAL(thirdTable[5].destination_rank, 4);
83 BOOST_REQUIRE_EQUAL(thirdTable[5].sequence_id, 5);
85 ct->AddReceiverToken(1, 2);
86 ct->AddReceiverToken(2, 1);
87 ct->AddReceiverToken(3, 1);
88 ct->AddReceiverToken(4, 2);
89 auto fourthTable = ct->GetCurrentTable();
90 BOOST_REQUIRE_EQUAL(fourthTable.size(), 6);
91 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1);
92 BOOST_REQUIRE_EQUAL(fourthTable[0].sequence_id, 6);
93 BOOST_REQUIRE_EQUAL(fourthTable[1].destination_rank, 1);
94 BOOST_REQUIRE_EQUAL(fourthTable[1].sequence_id, 7);
95 BOOST_REQUIRE_EQUAL(fourthTable[2].destination_rank, 2);
96 BOOST_REQUIRE_EQUAL(fourthTable[2].sequence_id, 8);
97 BOOST_REQUIRE_EQUAL(fourthTable[3].destination_rank, 3);
98 BOOST_REQUIRE_EQUAL(fourthTable[3].sequence_id, 9);
99 BOOST_REQUIRE_EQUAL(fourthTable[4].destination_rank, 4);
100 BOOST_REQUIRE_EQUAL(fourthTable[4].sequence_id, 10);
101 BOOST_REQUIRE_EQUAL(fourthTable[5].destination_rank, 4);
102 BOOST_REQUIRE_EQUAL(fourthTable[5].sequence_id, 11);
104 ct->AddReceiverToken(3, 1);
105 auto fifthTable = ct->GetCurrentTable();
106 BOOST_REQUIRE_EQUAL(fifthTable.size(), 4);
107 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 3);
108 BOOST_REQUIRE_EQUAL(fifthTable[0].sequence_id, 12);
109 BOOST_REQUIRE_EQUAL(fifthTable[1].destination_rank, 4);
110 BOOST_REQUIRE_EQUAL(fifthTable[1].sequence_id, 13);
111 BOOST_REQUIRE_EQUAL(fifthTable[2].destination_rank, 4);
112 BOOST_REQUIRE_EQUAL(fifthTable[2].sequence_id, 14);
113 BOOST_REQUIRE_EQUAL(fifthTable[3].destination_rank, 4);
114 BOOST_REQUIRE_EQUAL(fifthTable[3].sequence_id, 15);
118 BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< RoutingMasterPolicy > makeRoutingMasterPolicy(std::string const &policy_plugin_spec, fhicl::ParameterSet const &ps)
Load a RoutingMasterPolicy plugin.