diff options
| author | lijia <[email protected]> | 2024-06-21 14:32:39 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2024-06-21 16:16:26 +0800 |
| commit | 5d0168f5eb8c263b3e9b940b99b2c2097ee99282 (patch) | |
| tree | 066127ce92dbae231bce2dc0133071dc1d123f46 /test | |
| parent | a2e5617ed5f32078b9e2fc1f1a2649aaef6b0eec (diff) | |
add asymmetric test case.
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | test/http_decoder_perf_main.cpp | 35 | ||||
| -rw-r--r-- | test/http_pcap/http_fin.pcap | bin | 0 -> 240 bytes | |||
| -rw-r--r-- | test/http_pcap/http_tunnel_for_http_C2S.pcap | bin | 0 -> 823 bytes | |||
| -rw-r--r-- | test/http_pcap/http_tunnel_for_http_S2C.pcap | bin | 0 -> 3434 bytes | |||
| -rw-r--r-- | test/http_pcap/http_tunnel_s2c_only_hdr.pcap | bin | 0 -> 195 bytes | |||
| -rw-r--r-- | test/test_result_json/http_msg_type_state_tunnel_c2s.json | 15 | ||||
| -rw-r--r-- | test/test_result_json/http_msg_type_state_tunnel_s2c.json | 19 | ||||
| -rw-r--r-- | test/test_result_json/http_tunnel_for_http_c2s.json | 31 | ||||
| -rw-r--r-- | test/test_result_json/http_tunnel_for_http_s2c.json | 36 | ||||
| -rw-r--r-- | test/test_result_json/http_tunnel_s2c_only_hdr.json | 15 |
11 files changed, 136 insertions, 18 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2445ef2..07c1456 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,7 +16,6 @@ set(TEST_RUN_DIR /home/mesasoft/sapp_run) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_SOURCE_DIR}/deps) -# include_directories(/usr/local/include/cjson) include_directories(/opt/tsg/framework/include/) include_directories(/opt/MESA/include/MESA) include_directories(${CMAKE_BINARY_DIR}/vendor/vbuild/include) @@ -28,5 +27,3 @@ aux_source_directory(${PROJECT_SOURCE_DIR}/src PERF_TEST_DEP_SRC) add_executable(httpd_perf_test ${PERF_TEST_DEP_SRC} http_decoder_perf_main.cpp http_decoder_perf_plug.cpp) target_link_libraries(httpd_perf_test z brotlidec llhttp-static fieldstat4 pthread) - -#add_test(NAME INSTALL_PERF_TEST_MAIN COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/httpd_perf_test ${TEST_RUN_DIR}/httpd_perf_test")
\ No newline at end of file diff --git a/test/http_decoder_perf_main.cpp b/test/http_decoder_perf_main.cpp index 5d1b0f2..bd82b18 100644 --- a/test/http_decoder_perf_main.cpp +++ b/test/http_decoder_perf_main.cpp @@ -125,11 +125,15 @@ enum session_state session_get_current_state(struct session *sess) int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name) { - for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){ - if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){ - return st->consumer_topid_id; - } - } + // for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){ + // if(strcmp(topic_name, "TCP_STREAM") == 0){ + // st->consumer_topid_id = g_topic_exdata_set[HTTPD_TOPIC_TCP_STREAM_INDEX].sub_topic_id; + // st->publish_topic_id = g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id; + // } + // if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){ + // return st->consumer_topid_id; + // } + // } return -1; } @@ -138,12 +142,13 @@ int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name, for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){ if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){ - st->consumer_topid_id = g_topic_exdata_set[i].sub_topic_id; - st->publish_msg_free_cb = msg_free_cb; + if(strcmp(topic_name, HTTP_DECODER_TOPIC) == 0){ + st->publish_msg_free_cb = msg_free_cb; + } if(strcmp(topic_name, "TCP_STREAM") == 0){ st->publish_topic_id = g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id; } - return st->consumer_topid_id; + return g_topic_exdata_set[i].sub_topic_id; } } return -1; @@ -177,7 +182,7 @@ int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_session_ms } int session_mq_publish_message(struct session *sess, int topic_id, void *msg) { - if(topic_id == sess->st->publish_topic_id){ + if(topic_id == g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id){ http_decoder_perf_entry(sess, topic_id, msg, NULL, NULL); //maybe generate many messages for one packet, so free msg immediately sess->st->publish_msg_free_cb(sess, msg, NULL); @@ -206,17 +211,17 @@ static void perf_test_free_per_session(struct session *sess) sess->st->free_func(sess, sess->st->exdata_id, sess->exdata, NULL); } -static void perf_test_loop(struct session *sess, struct packet *test_payload, int test_payload_index_max, const struct fieldstat_tag *tag, int fs4_metric_id) +static void perf_test_loop(struct stellar *st, struct session *sess, struct packet *test_payload, int test_payload_index_max, const struct fieldstat_tag *tag, int fs4_metric_id) { - TIME_START(); sess->current_payload_st = &test_payload[0]; perf_test_init_per_session(sess); sess->sess_state = SESSION_STATE_OPENING; + TIME_START(); for(int i = 0; i < test_payload_index_max; i++) { sess->current_payload_st = &test_payload[i]; - http_decoder_tcp_stream_msg_cb(sess, sess->st->consumer_topid_id, test_payload[i].payload, NULL, sess->st->plugin_env); + http_decoder_tcp_stream_msg_cb(sess, g_topic_exdata_set[HTTPD_TOPIC_TCP_STREAM_INDEX].sub_topic_id, test_payload[i].payload, NULL, sess->st->plugin_env); TIME_DIFF(); fieldstat_easy_histogram_record(fs4_instance, 0, fs4_metric_id, tag, 1, time_diff_ns); sess->sess_state = SESSION_STATE_ACTIVE; @@ -380,9 +385,9 @@ int main(int argc, char const *argv[]) init_test_data_frag(test_payload_frag, &payload_index_frag); while(1){ - perf_test_loop(&sess, test_payload_simple, payload_index_simple, &FS4_SIMPLE_HISGRAM_TAG, fs4_simple_id); - perf_test_loop(&sess, test_payload_long_long_url, payload_index_long_long_url, &FS4_LONG_LONG_URL_HISGRAM_TAG, fs4_long_long_url_id); - perf_test_loop(&sess, test_payload_frag, payload_index_frag, &FS4_FRAG_HISGRAM_TAG, fs4_frag_id); + perf_test_loop(&st, &sess, test_payload_simple, payload_index_simple, &FS4_SIMPLE_HISGRAM_TAG, fs4_simple_id); + perf_test_loop(&st, &sess, test_payload_long_long_url, payload_index_long_long_url, &FS4_LONG_LONG_URL_HISGRAM_TAG, fs4_long_long_url_id); + perf_test_loop(&st, &sess, test_payload_frag, payload_index_frag, &FS4_FRAG_HISGRAM_TAG, fs4_frag_id); } return 0; } diff --git a/test/http_pcap/http_fin.pcap b/test/http_pcap/http_fin.pcap Binary files differnew file mode 100644 index 0000000..d23bcba --- /dev/null +++ b/test/http_pcap/http_fin.pcap diff --git a/test/http_pcap/http_tunnel_for_http_C2S.pcap b/test/http_pcap/http_tunnel_for_http_C2S.pcap Binary files differnew file mode 100644 index 0000000..db336d9 --- /dev/null +++ b/test/http_pcap/http_tunnel_for_http_C2S.pcap diff --git a/test/http_pcap/http_tunnel_for_http_S2C.pcap b/test/http_pcap/http_tunnel_for_http_S2C.pcap Binary files differnew file mode 100644 index 0000000..f9bb2f5 --- /dev/null +++ b/test/http_pcap/http_tunnel_for_http_S2C.pcap diff --git a/test/http_pcap/http_tunnel_s2c_only_hdr.pcap b/test/http_pcap/http_tunnel_s2c_only_hdr.pcap Binary files differnew file mode 100644 index 0000000..6887fec --- /dev/null +++ b/test/http_pcap/http_tunnel_s2c_only_hdr.pcap diff --git a/test/test_result_json/http_msg_type_state_tunnel_c2s.json b/test/test_result_json/http_msg_type_state_tunnel_c2s.json new file mode 100644 index 0000000..71e5cb5 --- /dev/null +++ b/test/test_result_json/http_msg_type_state_tunnel_c2s.json @@ -0,0 +1,15 @@ +[ + { + "msg_0": "HTTP_TRANSACTION_NEW_transaction_0", + "msg_1": "HTTP_MESSAGE_REQ_LINE", + "msg_2": "HTTP_MESSAGE_REQ_HEADER", + "msg_3": "HTTP_MESSAGE_REQ_HEADER_END", + "msg_4": "HTTP_TRANSACTION_FREE_transaction_0", + "msg_5": "HTTP_TRANSACTION_NEW_transaction_1", + "msg_6": "HTTP_MESSAGE_REQ_LINE", + "msg_7": "HTTP_MESSAGE_REQ_HEADER", + "msg_8": "HTTP_MESSAGE_REQ_HEADER_END", + "msg_9": "HTTP_TRANSACTION_FREE_transaction_1" + }, + {} +]
\ No newline at end of file diff --git a/test/test_result_json/http_msg_type_state_tunnel_s2c.json b/test/test_result_json/http_msg_type_state_tunnel_s2c.json new file mode 100644 index 0000000..b31260d --- /dev/null +++ b/test/test_result_json/http_msg_type_state_tunnel_s2c.json @@ -0,0 +1,19 @@ +[ + {}, + { + "msg_0": "HTTP_TRANSACTION_NEW_transaction_0", + "msg_1": "HTTP_MESSAGE_RES_LINE", + "msg_2": "HTTP_MESSAGE_RES_HEADER", + "msg_3": "HTTP_MESSAGE_RES_HEADER_END", + "msg_4": "HTTP_TRANSACTION_FREE_transaction_0", + "msg_5": "HTTP_TRANSACTION_NEW_transaction_1", + "msg_6": "HTTP_MESSAGE_RES_LINE", + "msg_7": "HTTP_MESSAGE_RES_HEADER", + "msg_8": "HTTP_MESSAGE_RES_HEADER_END", + "msg_9": "HTTP_MESSAGE_RES_BODY", + "msg_10": "HTTP_MESSAGE_RES_BODY", + "msg_11": "HTTP_MESSAGE_RES_BODY", + "msg_12": "HTTP_MESSAGE_RES_BODY_END", + "msg_13": "HTTP_TRANSACTION_FREE_transaction_1" + } +]
\ No newline at end of file diff --git a/test/test_result_json/http_tunnel_for_http_c2s.json b/test/test_result_json/http_tunnel_for_http_c2s.json new file mode 100644 index 0000000..5e17067 --- /dev/null +++ b/test/test_result_json/http_tunnel_for_http_c2s.json @@ -0,0 +1,31 @@ +[ + { + "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080" + }, + { + "__X_HTTP_TRANSACTION": "request", + "__X_HTTP_TRANSACTION_SEQ": 0, + "method": "CONNECT", + "uri": "www.baidu.com:80", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "www.baidu.com:80", + "User-Agent": "curl/7.29.0", + "Proxy-Connection": "Keep-Alive", + "__X_HTTP_URL": "www.baidu.com:80" + }, + { + "__X_HTTP_TRANSACTION": "request", + "__X_HTTP_TRANSACTION_SEQ": 1, + "method": "GET", + "uri": "/", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "User-Agent": "curl/7.29.0", + "Host": "www.baidu.com", + "Accept": "*/*", + "__X_HTTP_URL": "www.baidu.com/" + } +]
\ No newline at end of file diff --git a/test/test_result_json/http_tunnel_for_http_s2c.json b/test/test_result_json/http_tunnel_for_http_s2c.json new file mode 100644 index 0000000..7bd4996 --- /dev/null +++ b/test/test_result_json/http_tunnel_for_http_s2c.json @@ -0,0 +1,36 @@ +[ + { + "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080" + }, + { + "__X_HTTP_TRANSACTION": "response", + "__X_HTTP_TRANSACTION_SEQ": 0, + "res_version": "1.1", + "res_status": "Connection established", + "major_version": 1, + "minor_version": 1, + "status_code": 200, + "Proxy-agent": "CCProxy" + }, + { + "__X_HTTP_TRANSACTION": "response", + "__X_HTTP_TRANSACTION_SEQ": 1, + "res_version": "1.1", + "res_status": "OK", + "major_version": 1, + "minor_version": 1, + "status_code": 200, + "Accept-Ranges": "bytes", + "Cache-Control": "private, no-cache, no-store, proxy-revalidate, no-transform", + "Connection": "keep-alive", + "Content-Length": "2381", + "Content-Type": "text/html", + "Date": "Mon, 08 Apr 2024 09:45:51 GMT", + "Etag": "\"588604c1-94d\"", + "Last-Modified": "Mon, 23 Jan 2017 13:27:29 GMT", + "Pragma": "no-cache", + "Server": "bfe/1.0.8.18", + "Set-Cookie": "BDORZ=27315; max-age=86400; domain=.baidu.com; path=/", + "__X_HTTP_PAYLOAD_MD5": "090fe607a5be1228362614ccaa088577" + } +]
\ No newline at end of file diff --git a/test/test_result_json/http_tunnel_s2c_only_hdr.json b/test/test_result_json/http_tunnel_s2c_only_hdr.json new file mode 100644 index 0000000..4f11604 --- /dev/null +++ b/test/test_result_json/http_tunnel_s2c_only_hdr.json @@ -0,0 +1,15 @@ +[ + { + "__X_HTTP_TUPLE4": "36.255.45.61.29079>68.28.1.153.80" + }, + { + "__X_HTTP_TRANSACTION": "response", + "__X_HTTP_TRANSACTION_SEQ": 0, + "res_version": "1.0", + "res_status": "Connection Established", + "major_version": 1, + "minor_version": 0, + "status_code": 200, + "Proxy-agent": "Apache/2.0.55 (Unix) proxy_html/2.5" + } +]
\ No newline at end of file |
