summaryrefslogtreecommitdiff
path: root/tests/test-reconnect.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2020-12-21 16:21:00 -0800
committerBen Pfaff <blp@ovn.org>2021-01-07 10:58:53 -0800
commitfcf281b0b61078dc8ca23ebe1e2198c3f7c6763f (patch)
treece9addde4160f9484575b90333a5c3eb9b804d78 /tests/test-reconnect.c
parent98b1d633c4125e395c08d3257b7352f3172d8c8f (diff)
downloadopenvswitch-fcf281b0b61078dc8ca23ebe1e2198c3f7c6763f.tar.gz
reconnect: Add Python implementation of received_attempt(), and test.
This follows up on commit 4241d652e465 ("jsonrpc: Avoid disconnecting prematurely due to long poll intervals."), which implemented the same thing in C. Signed-off-by: Ben Pfaff <blp@ovn.org> Requested-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'tests/test-reconnect.c')
-rw-r--r--tests/test-reconnect.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c
index bf0463e25..c84bb1cdb 100644
--- a/tests/test-reconnect.c
+++ b/tests/test-reconnect.c
@@ -48,7 +48,6 @@ test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
now = 1000;
reconnect = reconnect_create(now);
- reconnect_receive_attempted(reconnect, LLONG_MAX);
reconnect_set_name(reconnect, "remote");
reconnect_get_stats(reconnect, now, &prev);
printf("### t=%d ###\n", now);
@@ -278,6 +277,18 @@ do_listen_error(struct ovs_cmdl_context *ctx)
reconnect_listen_error(reconnect, now, atoi(ctx->argv[1]));
}
+static void
+do_receive_attempted(struct ovs_cmdl_context *ctx OVS_UNUSED)
+{
+ if (!strcmp(ctx->argv[1], "now")) {
+ reconnect_receive_attempted(reconnect, now);
+ } else if (!strcmp(ctx->argv[1], "LLONG_MAX")) {
+ reconnect_receive_attempted(reconnect, LLONG_MAX);
+ } else {
+ ovs_fatal(0, "%s: bad argument %s", ctx->argv[0], ctx->argv[1]);
+ }
+}
+
static const struct ovs_cmdl_command all_commands[] = {
{ "enable", NULL, 0, 0, do_enable, OVS_RO },
{ "disable", NULL, 0, 0, do_disable, OVS_RO },
@@ -296,6 +307,7 @@ static const struct ovs_cmdl_command all_commands[] = {
{ "passive", NULL, 0, 0, do_set_passive, OVS_RO },
{ "listening", NULL, 0, 0, do_listening, OVS_RO },
{ "listen-error", NULL, 1, 1, do_listen_error, OVS_RO },
+ { "receive-attempted", NULL, 1, 1, do_receive_attempted, OVS_RO },
{ NULL, NULL, 0, 0, NULL, OVS_RO },
};