summaryrefslogtreecommitdiff
path: root/tests/test-vconn.c
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2019-01-09 20:30:17 +0300
committerBen Pfaff <blp@ovn.org>2019-01-10 15:42:54 -0800
commit04895042e9f62dd738ef5424e45925a6637d03db (patch)
tree8ebde7e3691da53bb77f78f335c010e42c4694fd /tests/test-vconn.c
parent77f42ca53581089a15ede670f0be6b6203360491 (diff)
downloadopenvswitch-04895042e9f62dd738ef5424e45925a6637d03db.tar.gz
vconn: Allow timeout configuration for blocking connection.
On some systems in case where remote is not responding, socket could remain in SYN_SENT state for a really long time without errors waiting for connection. This leads to situations where vconn connection hangs for a few minutes waiting for connection to the DOWN remote. For example, this situation emulated by "refuse-connection" vconn testcase. This leads to test failures because Alarm signal arrives much faster than ETIMEDOUT from the socket: ./vconn.at:21: ovstest test-vconn refuse-connection tcp Alarm clock stderr: |socket_util|INFO|0:127.0.0.1: listening on port 63812 |poll_loop|DBG|wakeup due to 0-ms timeout |poll_loop|DBG|wakeup due to 10155-ms timeout |fatal_signal|WARN|terminating with signal 14 (Alarm clock) ./vconn.at:21: exit code was 142, expected 0 vconn.at:21: 535. tcp vconn - refuse connection (vconn.at:21): FAILED This patch allowes to specify timeout value for vconn blocking connections. If the connection takes more time, socket will be closed with ETIMEDOUT error code. Negative value could be used to wait infinitely. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests/test-vconn.c')
-rw-r--r--tests/test-vconn.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index 8b8d12e36..73ef9a958 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -37,6 +37,8 @@
#include "timeval.h"
#include "util.h"
+#define TIMEOUT 10
+
struct fake_pvconn {
const char *type;
char *pvconn_name;
@@ -152,9 +154,9 @@ test_refuse_connection(struct ovs_cmdl_context *ctx)
fpv_close(&fpv);
vconn_run(vconn);
- error = vconn_connect_block(vconn);
+ error = vconn_connect_block(vconn, (TIMEOUT - 2) * 1000);
if (!strcmp(type, "tcp")) {
- if (error != ECONNRESET && error != EPIPE
+ if (error != ECONNRESET && error != EPIPE && error != ETIMEDOUT
#ifdef _WIN32
&& error != WSAECONNRESET
#endif
@@ -165,7 +167,7 @@ test_refuse_connection(struct ovs_cmdl_context *ctx)
} else if (!strcmp(type, "unix")) {
CHECK_ERRNO(error, EPIPE);
} else if (!strcmp(type, "ssl")) {
- if (error != EPROTO && error != ECONNRESET) {
+ if (error != EPROTO && error != ECONNRESET && error != ETIMEDOUT) {
ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)",
error, ovs_strerror(error));
}
@@ -194,7 +196,7 @@ test_accept_then_close(struct ovs_cmdl_context *ctx)
stream_close(fpv_accept(&fpv));
fpv_close(&fpv);
- error = vconn_connect_block(vconn);
+ error = vconn_connect_block(vconn, -1);
if (!strcmp(type, "tcp") || !strcmp(type, "unix")) {
if (error != ECONNRESET && error != EPIPE
#ifdef _WIN32
@@ -254,7 +256,7 @@ test_read_hello(struct ovs_cmdl_context *ctx)
poll_block();
}
stream_close(stream);
- error = vconn_connect_block(vconn);
+ error = vconn_connect_block(vconn, -1);
if (error != ECONNRESET && error != EPIPE) {
ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)",
error, ovs_strerror(error));
@@ -451,7 +453,7 @@ test_vconn_main(int argc, char *argv[])
vlog_set_levels(NULL, VLF_CONSOLE, VLL_DBG);
fatal_ignore_sigpipe();
- time_alarm(10);
+ time_alarm(TIMEOUT);
ovs_cmdl_run_command(&ctx, commands);
}