summaryrefslogtreecommitdiffstats
path: root/vbench/src/tests/http_connection
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vbench/src/tests/http_connection
Publish
Diffstat (limited to 'vbench/src/tests/http_connection')
-rw-r--r--vbench/src/tests/http_connection/.gitignore1
-rw-r--r--vbench/src/tests/http_connection/CMakeLists.txt9
-rw-r--r--vbench/src/tests/http_connection/FILES1
-rw-r--r--vbench/src/tests/http_connection/http_connection_test.cpp22
4 files changed, 33 insertions, 0 deletions
diff --git a/vbench/src/tests/http_connection/.gitignore b/vbench/src/tests/http_connection/.gitignore
new file mode 100644
index 00000000000..9829af0bdba
--- /dev/null
+++ b/vbench/src/tests/http_connection/.gitignore
@@ -0,0 +1 @@
+vbench_http_connection_test_app
diff --git a/vbench/src/tests/http_connection/CMakeLists.txt b/vbench/src/tests/http_connection/CMakeLists.txt
new file mode 100644
index 00000000000..8d33e8fb1e3
--- /dev/null
+++ b/vbench/src/tests/http_connection/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vbench_http_connection_test_app
+ SOURCES
+ http_connection_test.cpp
+ DEPENDS
+ vbench_test
+ vbench
+)
+vespa_add_test(NAME vbench_http_connection_test_app COMMAND vbench_http_connection_test_app)
diff --git a/vbench/src/tests/http_connection/FILES b/vbench/src/tests/http_connection/FILES
new file mode 100644
index 00000000000..de51725c9ac
--- /dev/null
+++ b/vbench/src/tests/http_connection/FILES
@@ -0,0 +1 @@
+http_connection_test.cpp
diff --git a/vbench/src/tests/http_connection/http_connection_test.cpp b/vbench/src/tests/http_connection/http_connection_test.cpp
new file mode 100644
index 00000000000..dc03a9e7e8e
--- /dev/null
+++ b/vbench/src/tests/http_connection/http_connection_test.cpp
@@ -0,0 +1,22 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/vespalib/testkit/testapp.h>
+#include <vbench/test/all.h>
+
+using namespace vbench;
+
+TEST("http connection") {
+ ServerSocket serverSocket;
+ HttpConnection client(ServerSpec("localhost", serverSocket.port()));
+ Stream::UP server = serverSocket.accept();
+ EXPECT_TRUE(client.fresh());
+ EXPECT_EQUAL("localhost", client.server().host);
+ EXPECT_FALSE(client.mayReuse(0.1)); // still fresh
+ client.touch(5.0);
+ EXPECT_FALSE(client.fresh());
+ EXPECT_TRUE(client.mayReuse(5.1));
+ server.reset();
+ client.stream().obtain(1, 1); // trigger eof
+ EXPECT_FALSE(client.mayReuse(5.1));
+}
+
+TEST_MAIN() { TEST_RUN_ALL(); }