X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fplugins%2Funittest%2Fsession_test.c;h=cc273321d321d1a3e1c72ae03b5297302285e245;hb=b5e55a27a46f166f466c7996675542de645eff66;hp=5c2993e3322d6f32bdf48071ea64ae2a29d1c614;hpb=9f3b14e311155cb9beb43d6d4f9f775c6be4b187;p=vpp.git diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c index 5c2993e3322..cc273321d32 100644 --- a/src/plugins/unittest/session_test.c +++ b/src/plugins/unittest/session_test.c @@ -18,6 +18,7 @@ #include #include #include +#include #define SESSION_TEST_I(_cond, _comment, _args...) \ ({ \ @@ -62,14 +63,14 @@ dummy_session_connected_callback (u32 app_index, u32 api_context, static u32 dummy_segment_count; int -dummy_add_segment_callback (u32 client_index, const ssvm_private_t * fs) +dummy_add_segment_callback (u32 client_index, u64 segment_handle) { dummy_segment_count = 1; return 0; } int -dummy_del_segment_callback (u32 client_index, const ssvm_private_t * fs) +dummy_del_segment_callback (u32 client_index, u64 segment_handle) { dummy_segment_count = 0; return 0; @@ -215,6 +216,7 @@ session_test_basic (vlib_main_t * vm, unformat_input_t * input) vnet_app_detach_args_t detach_args = { .app_index = server_index, + .api_client_index = ~0, }; vnet_application_detach (&detach_args); return 0; @@ -268,10 +270,10 @@ static int session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input) { session_endpoint_cfg_t client_sep = SESSION_ENDPOINT_CFG_NULL; + u32 server_index, client_index, sw_if_index[2], tries = 0; u64 options[APP_OPTIONS_N_OPTIONS], dummy_secret = 1234; u16 dummy_server_port = 1234, dummy_client_port = 5678; session_endpoint_t server_sep = SESSION_ENDPOINT_NULL; - u32 server_index, client_index, sw_if_index[2]; ip4_address_t intf_addr[3]; transport_connection_t *tc; stream_session_t *s; @@ -361,13 +363,20 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input) .app_index = client_index, }; + connected_session_index = connected_session_thread = ~0; + accepted_session_index = accepted_session_thread = ~0; error = vnet_connect (&connect_args); SESSION_TEST ((error == 0), "connect should work"); /* wait for stuff to happen */ - vlib_process_suspend (vm, 10e-3); - + while ((connected_session_index == ~0 + || vec_len (tcp_main.wrk_ctx[0].pending_acks)) && ++tries < 100) + vlib_process_suspend (vm, 100e-3); + clib_warning ("waited %.1f seconds for connections", tries / 10.0); SESSION_TEST ((connected_session_index != ~0), "session should exist"); + SESSION_TEST ((connected_session_thread != ~0), "thread should exist"); + SESSION_TEST ((accepted_session_index != ~0), "session should exist"); + SESSION_TEST ((accepted_session_thread != ~0), "thread should exist"); s = session_get (connected_session_index, connected_session_thread); tc = session_get_transport (s); SESSION_TEST ((tc != 0), "transport should exist"); @@ -379,12 +388,13 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input) * main thread, even when we have workers and we avoid polling main thread, * i.e., we can't cleanup pending disconnects, so force cleanup for both */ - stream_session_cleanup (s); + session_transport_cleanup (s); s = session_get (accepted_session_index, accepted_session_thread); - stream_session_cleanup (s); + session_transport_cleanup (s); vnet_app_detach_args_t detach_args = { .app_index = server_index, + .api_client_index = ~0, }; vnet_application_detach (&detach_args); detach_args.app_index = client_index; @@ -409,7 +419,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) u64 options[APP_OPTIONS_N_OPTIONS], dummy_secret = 1234; u32 server_index, server_st_index, server_local_st_index; u32 dummy_port = 1234, client_index, server_wrk_index; - u32 dummy_api_context = 4321, dummy_client_api_index = 1234; + u32 dummy_api_context = 4321, dummy_client_api_index = ~0; u32 dummy_server_api_index = ~0, sw_if_index = 0; session_endpoint_t server_sep = SESSION_ENDPOINT_NULL; session_endpoint_t client_sep = SESSION_ENDPOINT_NULL; @@ -455,6 +465,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) vnet_app_detach_args_t detach_args = { .app_index = 0, + .api_client_index = ~0, }; ip4_address_t intf_addr = { @@ -1183,7 +1194,8 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) &is_filtered); SESSION_TEST ((tc == 0), "lookup for 1.2.3.4/32 1234 5.6.7.8/16 4321 " "should fail (deny rule)"); - SESSION_TEST ((is_filtered == 1), "lookup should be filtered (deny)"); + SESSION_TEST ((is_filtered == SESSION_LOOKUP_RESULT_FILTERED), + "lookup should be filtered (deny)"); handle = session_lookup_local_endpoint (local_ns_index, &sep); SESSION_TEST ((handle == SESSION_DROP_HANDLE), "lookup for 1.2.3.4/32 1234 " @@ -1482,7 +1494,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) app_ns = app_namespace_get_from_id (ns_id); attach_args.namespace_id = ns_id; - attach_args.api_client_index = dummy_server_api_index - 1; + attach_args.api_client_index = dummy_server_api_index; error = vnet_application_attach (&attach_args); SESSION_TEST ((error == 0), "server2 attached"); server_index2 = attach_args.app_index; @@ -1554,6 +1566,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) vec_free (args.table_args.tag); vnet_app_detach_args_t detach_args = { .app_index = server_index, + .api_client_index = ~0, }; vnet_application_detach (&detach_args); @@ -1669,6 +1682,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input) vnet_app_detach_args_t detach_args = { .app_index = server_index, + .api_client_index = ~0, }; vnet_application_detach (&detach_args);