static void
send_data_chunk (ec_main_t *ecm, ec_session_t *es)
{
+ const u64 max_burst = 128000;
u8 *test_data = ecm->connect_test_data;
int test_buf_len, test_buf_offset, rv;
+ u64 bytes_to_send;
u32 bytes_this_chunk;
+ svm_fifo_t *f = es->tx_fifo;
test_buf_len = vec_len (test_data);
ASSERT (test_buf_len > 0);
+ if (ecm->run_time)
+ bytes_to_send = clib_min (svm_fifo_max_enqueue_prod (f), max_burst);
+ else
+ bytes_to_send = clib_min (es->bytes_to_send, max_burst);
test_buf_offset = es->bytes_sent % test_buf_len;
- bytes_this_chunk =
- clib_min (test_buf_len - test_buf_offset, es->bytes_to_send);
+
+ bytes_this_chunk = clib_min (test_buf_len - test_buf_offset, bytes_to_send);
if (!es->is_dgram)
{
if (ecm->no_copy)
{
- svm_fifo_t *f = es->tx_fifo;
rv = clib_min (svm_fifo_max_enqueue_prod (f), bytes_this_chunk);
svm_fifo_enqueue_nocopy (f, rv);
session_program_tx_io_evt (es->tx_fifo->vpp_sh, SESSION_IO_EVT_TX);
}
else
{
- svm_fifo_t *f = es->tx_fifo;
u32 max_enqueue = svm_fifo_max_enqueue_prod (f);
if (max_enqueue < sizeof (session_dgram_hdr_t))
if (rv > 0)
{
/* Account for it... */
- es->bytes_to_send -= rv;
es->bytes_sent += rv;
+ if (ecm->run_time)
+ es->bytes_to_receive += rv;
+ else
+ es->bytes_to_send -= rv;
if (ecm->cfg.verbose)
{
{
ecm->repeats++;
ecm->prev_conns = vec_len (conns_this_batch);
- if (ecm->repeats == 500000)
+ if (ecm->repeats == 500000 && !ecm->run_time)
{
ec_err ("stuck clients");
}
delete_session = 0;
}
- if (PREDICT_FALSE (delete_session == 1))
+ if (PREDICT_FALSE (delete_session == 1) || ecm->timer_expired)
{
clib_atomic_fetch_add (&ecm->tx_total, es->bytes_sent);
clib_atomic_fetch_add (&ecm->rx_total, es->bytes_received);
ecm->tls_engine = CRYPTO_ENGINE_OPENSSL;
ecm->no_copy = 0;
ecm->run_test = EC_STARTING;
+ ecm->timer_expired = false;
ecm->ready_connections = 0;
ecm->connect_conn_index = 0;
ecm->rx_total = 0;
ecm->attach_flags = 0;
ecm->syn_timeout = 20.0;
ecm->test_timeout = 20.0;
+ ecm->run_time = 0;
vec_free (ecm->connect_uri);
}
ec_main_t *ecm = &ec_main;
uword *event_data = 0, event_type;
clib_error_t *error = 0;
- int rv, had_config = 1;
+ int rv, timed_run_conflict = 0, had_config = 1;
u64 total_bytes;
f64 delta;
;
else if (unformat (line_input, "bytes %U", unformat_memory_size,
&ecm->bytes_to_send))
- ;
+ timed_run_conflict++;
else if (unformat (line_input, "test-timeout %f", &ecm->test_timeout))
;
else if (unformat (line_input, "syn-timeout %f", &ecm->syn_timeout))
;
+ else if (unformat (line_input, "run-time %f", &ecm->run_time))
+ ;
else if (unformat (line_input, "echo-bytes"))
ecm->echo_bytes = 1;
else if (unformat (line_input, "fifo-size %U", unformat_memory_size,
}
}
+ if (timed_run_conflict && ecm->run_time)
+ return clib_error_return (0, "failed: invalid arguments for a timed run!");
+
parse_config:
ecm->cfg.num_test_sessions = ecm->expected_connections =
goto stop_test;
}
+ /* Testing officially starts now */
+ ecm->test_start_time = vlib_time_now (ecm->vlib_main);
+ ec_cli ("Test started at %.6f", ecm->test_start_time);
+
+ /*
+ * If a timed run, wait and expire timer
+ */
+ if (ecm->run_time)
+ {
+ vlib_process_suspend (vm, ecm->run_time);
+ ec_main.timer_expired = true;
+ }
+
/*
* Wait for the sessions to finish or test_timeout seconds pass
*/
- ecm->test_start_time = vlib_time_now (ecm->vlib_main);
- ec_cli ("Test started at %.6f", ecm->test_start_time);
vlib_process_wait_for_event_or_clock (vm, ecm->test_timeout);
event_type = vlib_process_get_events (vm, &event_data);
switch (event_type)
VLIB_CLI_COMMAND (ec_command, static) = {
.path = "test echo clients",
.short_help =
- "test echo clients [nclients %d][bytes <bytes>[m|g]]"
- "[test-timeout <time>][syn-timeout <time>][echo-bytes][fifo-size <size>]"
+ "test echo clients [nclients %d][bytes <bytes>[m|g]][test-timeout <time>]"
+ "[run-time <time>][syn-timeout <time>][echo-bytes][fifo-size <size>]"
"[private-segment-count <count>][private-segment-size <bytes>[m|g]]"
"[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]"
"[uri <tcp://ip/port>][test-bytes][verbose]",