aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/hs-test/http_test.go36
-rw-r--r--src/plugins/hs_apps/test_builtins.c25
2 files changed, 54 insertions, 7 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index 9e52e961d28..f4aec142a78 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -31,7 +31,8 @@ func init() {
HttpStaticMacTimeTest, HttpStaticBuildInUrlGetVersionVerboseTest, HttpVersionNotSupportedTest,
HttpInvalidContentLengthTest, HttpInvalidTargetSyntaxTest, HttpStaticPathTraversalTest, HttpUriDecodeTest,
HttpHeadersTest, HttpStaticFileHandlerTest, HttpStaticFileHandlerDefaultMaxAgeTest, HttpClientTest, HttpClientErrRespTest, HttpClientPostFormTest,
- HttpClientPostFileTest, HttpClientPostFilePtrTest, AuthorityFormTargetTest, HttpRequestLineTest)
+ HttpClientPostFileTest, HttpClientPostFilePtrTest, AuthorityFormTargetTest, HttpRequestLineTest,
+ HttpStaticFileHandlerWrkTest, HttpStaticUrlHandlerWrkTest)
RegisterNoTopoSoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest,
PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest,
PromConsecutiveConnectionsTest)
@@ -594,6 +595,39 @@ func HttpInvalidClientRequestMemLeakTest(s *NoTopoSuite) {
}
+func runWrkPerf(s *NoTopoSuite) {
+ nConnections := 1000
+ serverAddress := s.VppAddr()
+
+ wrkCont := s.GetContainerByName("wrk")
+ args := fmt.Sprintf("-c %d -t 2 -d 30s http://%s:80/64B", nConnections, serverAddress)
+ wrkCont.ExtraRunningArgs = args
+ wrkCont.Run()
+ s.Log("Please wait for 30s, test is running.")
+ o, err := wrkCont.GetOutput()
+ s.Log(o)
+ s.AssertEmpty(err, "err: '%s'", err)
+}
+
+func HttpStaticFileHandlerWrkTest(s *NoTopoSuite) {
+ vpp := s.GetContainerByName("vpp").VppInstance
+ serverAddress := s.VppAddr()
+ vpp.Container.Exec("mkdir -p " + wwwRootPath)
+ content := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+ err := vpp.Container.CreateFile(wwwRootPath+"/64B", content)
+ s.AssertNil(err, fmt.Sprint(err))
+ s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 private-segment-size 256m"))
+ runWrkPerf(s)
+}
+
+func HttpStaticUrlHandlerWrkTest(s *NoTopoSuite) {
+ vpp := s.GetContainerByName("vpp").VppInstance
+ serverAddress := s.VppAddr()
+ s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers private-segment-size 256m"))
+ s.Log(vpp.Vppctl("test-url-handler enable"))
+ runWrkPerf(s)
+}
+
func HttpStaticFileHandlerDefaultMaxAgeTest(s *NoTopoSuite) {
HttpStaticFileHandlerTestFunction(s, "default")
}
diff --git a/src/plugins/hs_apps/test_builtins.c b/src/plugins/hs_apps/test_builtins.c
index 631c1f1a8a2..c314e71b5df 100644
--- a/src/plugins/hs_apps/test_builtins.c
+++ b/src/plugins/hs_apps/test_builtins.c
@@ -16,6 +16,7 @@ typedef struct tb_main_
tw_timer_elt_t *delayed_resps;
tw_timer_wheel_2t_1w_2048sl_t tw;
hss_session_send_fn send_data;
+ u8 *test_data;
} tb_main_t;
static tb_main_t tb_main;
@@ -51,7 +52,7 @@ VLIB_REGISTER_NODE (test_builtins_timer_process_node) = {
};
static void
-send_data_to_hss (hss_session_handle_t sh, u8 *data)
+send_data_to_hss (hss_session_handle_t sh, u8 *data, u8 free_vec_data)
{
tb_main_t *tbm = &tb_main;
hss_url_handler_args_t args = {};
@@ -61,7 +62,7 @@ send_data_to_hss (hss_session_handle_t sh, u8 *data)
args.data_len = vec_len (data);
args.ct = HTTP_CONTENT_TEXT_PLAIN;
args.sc = HTTP_STATUS_OK;
- args.free_vec_data = 1;
+ args.free_vec_data = free_vec_data;
tbm->send_data (&args);
}
@@ -73,7 +74,7 @@ handle_get_test1 (hss_url_handler_args_t *args)
clib_warning ("get request on test1");
data = format (0, "hello");
- send_data_to_hss (args->sh, data);
+ send_data_to_hss (args->sh, data, 1);
return HSS_URL_HANDLER_ASYNC;
}
@@ -85,7 +86,7 @@ handle_get_test2 (hss_url_handler_args_t *args)
clib_warning ("get request on test2");
data = format (0, "some data");
- send_data_to_hss (args->sh, data);
+ send_data_to_hss (args->sh, data, 1);
return HSS_URL_HANDLER_ASYNC;
}
@@ -105,7 +106,7 @@ delayed_resp_cb (u32 *expired_timers)
e = pool_elt_at_index (tbm->delayed_resps, pool_index);
clib_warning ("sending delayed data");
data = format (0, "delayed data");
- send_data_to_hss (e->sh, data);
+ send_data_to_hss (e->sh, data, 1);
pool_put (tbm->delayed_resps, e);
}
}
@@ -128,7 +129,15 @@ handle_get_test_delayed (hss_url_handler_args_t *args)
static hss_url_handler_rc_t
handle_post_test3 (hss_url_handler_args_t *args)
{
- send_data_to_hss (args->sh, 0);
+ send_data_to_hss (args->sh, 0, 0);
+ return HSS_URL_HANDLER_ASYNC;
+}
+
+static hss_url_handler_rc_t
+handle_get_64bytes (hss_url_handler_args_t *args)
+{
+ tb_main_t *tbm = &tb_main;
+ send_data_to_hss (args->sh, tbm->test_data, 0);
return HSS_URL_HANDLER_ASYNC;
}
@@ -148,10 +157,14 @@ test_builtins_init (vlib_main_t *vm)
return;
}
+ tbm->test_data = format (
+ 0, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+
(*fp) (handle_get_test1, "test1", HTTP_REQ_GET);
(*fp) (handle_get_test2, "test2", HTTP_REQ_GET);
(*fp) (handle_get_test_delayed, "test_delayed", HTTP_REQ_GET);
(*fp) (handle_post_test3, "test3", HTTP_REQ_POST);
+ (*fp) (handle_get_64bytes, "64B", HTTP_REQ_GET);
tbm->send_data =
vlib_get_plugin_symbol ("http_static_plugin.so", "hss_session_send_data");