mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
stress_test parameter parsing
This commit is contained in:
@@ -64,7 +64,62 @@ stress_handler::stress_handler(wscmd::cmd& cmd)
|
||||
, m_failed_connections(0)
|
||||
, m_next_con_id(0)
|
||||
, m_init(boost::chrono::steady_clock::now())
|
||||
, m_con_sync(false)
|
||||
{
|
||||
if (!wscmd::extract_number<size_t>(cmd,"msg_count",m_msg_count)) {
|
||||
m_msg_count = 0;
|
||||
}
|
||||
|
||||
if (!wscmd::extract_number<size_t>(cmd,"msg_size",m_msg_size)) {
|
||||
m_msg_size = 0;
|
||||
}
|
||||
|
||||
std::string mode;
|
||||
if (wscmd::extract_string(cmd,"msg_mode",mode)) {
|
||||
if (mode == "fixed") {
|
||||
m_msg_mode = msg_mode::FIXED;
|
||||
} else if (mode == "infinite") {
|
||||
m_msg_mode = msg_mode::INFINITE;
|
||||
} else {
|
||||
m_msg_mode = msg_mode::NONE;
|
||||
}
|
||||
} else {
|
||||
m_msg_mode = msg_mode::NONE;
|
||||
}
|
||||
|
||||
if (wscmd::extract_string(cmd,"con_lifetime",mode)) {
|
||||
if (mode == "random") {
|
||||
m_con_lifetime = con_lifetime::RANDOM;
|
||||
} else if (mode == "infinite") {
|
||||
m_con_lifetime = con_lifetime::INFINITE;
|
||||
} else {
|
||||
m_con_lifetime = con_lifetime::FIXED;
|
||||
}
|
||||
} else {
|
||||
m_con_lifetime = con_lifetime::FIXED;
|
||||
}
|
||||
|
||||
if (m_con_lifetime == con_lifetime::FIXED) {
|
||||
if (!wscmd::extract_number<size_t>(cmd,"con_duration",m_con_duration)) {
|
||||
m_con_duration = 5000;
|
||||
}
|
||||
} else if (m_con_lifetime == con_lifetime::RANDOM) {
|
||||
size_t max_dur;
|
||||
if (!wscmd::extract_number<size_t>(cmd,"con_duration",max_dur)) {
|
||||
max_dur = 5000;
|
||||
}
|
||||
|
||||
// TODO: choose random number between 0 and max_dur
|
||||
m_con_duration = max_dur;
|
||||
}
|
||||
|
||||
std::cout << "con_duration: " << m_con_duration
|
||||
<< "msg_count: " << m_msg_count
|
||||
<< "msg_size: " << m_msg_size
|
||||
<< "m_con_sync: " << m_con_sync
|
||||
<< "m_con_lifetime: " << m_con_lifetime
|
||||
<< "m_msg_mode: " << m_msg_mode
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void stress_handler::on_connect(connection_ptr con) {
|
||||
@@ -225,7 +280,7 @@ bool stress_handler::maintenance() {
|
||||
boost::chrono::nanoseconds dur = now - data.on_open;
|
||||
size_t milliseconds = dur.count() / 1000000.;
|
||||
|
||||
if (milliseconds > 5000) {
|
||||
if (milliseconds > m_con_duration) {
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,25 @@ using websocketpp::client;
|
||||
|
||||
namespace wsperf {
|
||||
|
||||
namespace con_lifetime {
|
||||
enum value {
|
||||
FIXED = 0,
|
||||
RANDOM = 1,
|
||||
INFINITE = 2
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace msg_mode {
|
||||
enum value {
|
||||
NONE = 0,
|
||||
FIXED = 1,
|
||||
INFINITE = 2
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
struct con_data {
|
||||
typedef boost::chrono::steady_clock::time_point time_point;
|
||||
|
||||
@@ -134,6 +153,16 @@ protected:
|
||||
size_t m_timeout;
|
||||
boost::shared_ptr<boost::asio::deadline_timer> m_timer;
|
||||
|
||||
// test settings pulled from the command
|
||||
con_lifetime::value m_con_lifetime;
|
||||
size_t m_con_duration;
|
||||
bool m_con_sync;
|
||||
|
||||
msg_mode::value m_msg_mode;
|
||||
size_t m_msg_count;
|
||||
size_t m_msg_size;
|
||||
|
||||
|
||||
mutable boost::mutex m_lock;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user