21 #define BOOST_TEST_MODULE isimud_tests
22 #include <boost/test/included/unit_test.hpp>
24 #include <boost/mpl/list.hpp>
26 #include "../exchanges/FIX/v5.0sp2/fix.hpp"
27 #include "../exchanges/FIX/v5.0sp2/fix_sim.hpp"
29 #include "core/latency_timestamps.hpp"
31 using namespace libjmmcg;
32 using namespace libisimud;
43 BOOST_AUTO_TEST_SUITE(exchange_gateways)
45 BOOST_AUTO_TEST_SUITE(links)
52 BOOST_AUTO_TEST_CASE_TEMPLATE(gateway_unavailable, exchg_t, exchg_t_types) {
53 using connection_t=
typename exchg_t::first_type;
54 using conn_pol_t=
typename connection_t::conn_pol_t;
55 typename conn_pol_t::gateways_t gateways(
56 std::make_pair(localhost, unused_primary_port)
58 conn_pol_t conn_pol(gateways);
59 auto const &begin=
std::chrono::system_clock::now();
61 typename exchg_t::first_type link(
63 exchg_t::first_type::skt_mgr_t::socket_t::socket_priority::high,
68 auto const &end=
std::chrono::system_clock::now();
69 BOOST_CHECK_GE(std::chrono::duration_cast<std::chrono::seconds>(end-begin).count(), (conn_pol_t::max_attempts*conn_pol_t::min_timeout).count());
77 BOOST_AUTO_TEST_CASE_TEMPLATE(gateway_available, exchg_t, exchg_t_types) {
78 using connection_t=
typename exchg_t::first_type;
79 using simulator_t=
typename exchg_t::second_type;
80 using conn_pol_t=
typename connection_t::conn_pol_t;
81 typename simulator_t::proc_rules_t proc_rules;
82 no_latency_timestamps ts
(0
);
86 simulator_t::socket_t::socket_priority::high,
87 api_thread_traits::processor_mask_type(exchanges::common::thread_traits::exchange_simulator_thread.core),
88 exchanges::common::thread_traits::exchange_simulator_thread.priority,
93 typename conn_pol_t::gateways_t gateways(
94 std::make_pair(localhost, unused_primary_port)
96 conn_pol_t conn_pol(gateways);
97 auto const &begin=
std::chrono::system_clock::now();
99 typename exchg_t::first_type link(
101 exchg_t::first_type::skt_mgr_t::socket_t::socket_priority::high,
102 exchanges::common::thread_traits::client_to_exchange_thread.core
105 auto const &end=
std::chrono::system_clock::now();
106 BOOST_CHECK_LT(std::chrono::duration_cast<std::chrono::seconds>(end-begin).count(), conn_pol_t::min_timeout.count());
109 BOOST_AUTO_TEST_SUITE_END()
111 BOOST_AUTO_TEST_SUITE(admin)
118 BOOST_AUTO_TEST_CASE_TEMPLATE(client_heartbeat, exchg_t, exchg_t_types) {
119 using connection_t=
typename exchg_t::first_type;
120 using simulator_t=
typename exchg_t::second_type;
121 using conn_pol_t=
typename connection_t::conn_pol_t;
122 typename simulator_t::proc_rules_t proc_rules;
123 no_latency_timestamps ts
(0
);
127 simulator_t::socket_t::socket_priority::high,
128 api_thread_traits::processor_mask_type(exchanges::common::thread_traits::exchange_simulator_thread.core),
129 exchanges::common::thread_traits::exchange_simulator_thread.priority,
134 typename conn_pol_t::gateways_t gateways(
135 std::make_pair(localhost, unused_primary_port)
137 conn_pol_t conn_pol(gateways);
138 typename exchg_t::first_type link(
140 exchg_t::first_type::skt_mgr_t::socket_t::socket_priority::high,
144 "8=FIX.5.0\0019=005\00135=0\00110=000\001"
146 typename connection_t::msg_details_t::ClientHeartbeat
const &msg=
reinterpret_cast<
typename connection_t::msg_details_t::ClientHeartbeat
const &>(*fix_buffer.begin());
147 BOOST_CHECK(msg.is_valid());
148 BOOST_CHECK_NO_THROW(link.send(msg));
151 BOOST_AUTO_TEST_SUITE_END()
153 BOOST_AUTO_TEST_SUITE_END()