From 10b0c37258da4a3d68ac94a1f6a4c6060f24ce65 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Fri, 5 Jul 2024 07:36:19 -0400 Subject: [PATCH] Add MG test to test the flag change in setup connection --- .../messages/common_messages.json | 16 +++++ .../job-declarator-mock-invalid-flag.json | 38 ++++++++++ .../job-declarator-flag-test.json | 71 +++++++++++++++++++ .../job-declarator-flag-test.sh | 9 +++ 4 files changed, 134 insertions(+) create mode 100644 test/message-generator/mock/job-declarator-mock-invalid-flag.json create mode 100644 test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.json create mode 100755 test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.sh diff --git a/test/message-generator/messages/common_messages.json b/test/message-generator/messages/common_messages.json index ff5d200dd3..80ee1c68cb 100644 --- a/test/message-generator/messages/common_messages.json +++ b/test/message-generator/messages/common_messages.json @@ -48,6 +48,22 @@ }, "id": "setup_connection_job_declarator" }, + { + "message": { + "type": "SetupConnection", + "protocol": 1, + "min_version": 2, + "max_version": 2, + "flags": 6, + "endpoint_host": "", + "endpoint_port": 0, + "vendor": "", + "hardware_version": "", + "firmware": "", + "device_id": "" + }, + "id": "setup_connection_job_declarator_with_no_async_flag" + }, { "message": { "type": "SetupConnectionSuccess", diff --git a/test/message-generator/mock/job-declarator-mock-invalid-flag.json b/test/message-generator/mock/job-declarator-mock-invalid-flag.json new file mode 100644 index 0000000000..a14f0554bd --- /dev/null +++ b/test/message-generator/mock/job-declarator-mock-invalid-flag.json @@ -0,0 +1,38 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Soft mock of JD", + "Connect to JDS", + "Receive Setup Connection Error as incorrect bits are set" + ], + "frame_builders": [ + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator_with_no_async_flag" + } + ], + "actions": [ + { + "message_ids": ["setup_connection_job_declarator_with_no_async_flag"], + "role": "client", + "results": [ + { + "type": "match_message_type", + "value": "0x01" + } + + ], + "actiondoc": "This action sends SetupConnection and checks that .Success" + } + ], + "setup_commands": [], + "execution_commands": [], + "cleanup_commands": [], + "role": "client", + "downstream": { + "ip": "127.0.0.1", + "port": 34264, + "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" + } +} diff --git a/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.json b/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.json new file mode 100644 index 0000000000..feb4cf571e --- /dev/null +++ b/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.json @@ -0,0 +1,71 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Launch the jd-server" + ], + "frame_builders": [ + ], + "actions": [ + ], + "setup_commands": [ + { + "command": "cargo", + "args": [ + "llvm-cov", + "--no-report", + "run", + "-p", + "jd_server", + "--", + "-c", + "../test/config/jds-do-not-fail-on-wrong-txdatasucc/jds-config.toml" + ], + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "JD INITIALIZED", + "output_location": "StdOut", + "late_condition": false, + "condition": true + } + ], + "timer_secs": 300, + "warn_no_panic": false + } + } + }, + { + "command": "cargo", + "args": [ + "run", + "../../test/message-generator/mock/job-declarator-mock-invalid-flag.json" + ], + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "MATCHED MESSAGE TYPE 1", + "output_location": "StdOut", + "late_condition": false, + "condition": true + } + ], + "timer_secs": 600, + "warn_no_panic": false + } + } + } + ], + "execution_commands": [ + ], + "cleanup_commands": [ + { + "command": "pkill", + "args": ["-f", "jd_server", "-SIGINT"], + "conditions": "None" + } + ], + "role": "none" +} diff --git a/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.sh b/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.sh new file mode 100755 index 0000000000..e11ba44a6e --- /dev/null +++ b/test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.sh @@ -0,0 +1,9 @@ +cd roles +cargo llvm-cov --no-report -p pool_sv2 + +cd ../utils/message-generator/ +cargo build + +RUST_LOG=debug cargo run ../../test/message-generator/test/job-declarator-flag-test/job-declarator-flag-test.json || { echo 'mg test failed' ; exit 1; } + +sleep 10