Introduce some initial basic testcases for configuration parsing and standard daemon startup and shutdown routines. This should give an example of how the framework works. Here is an example of running this: === 8< === $ cd tests/ ; sudo ./cttools-testing-framework.py [cttools-testing-framework.py] INFO: --- running test: stats_general [cttools-testing-framework.py] INFO: --- passed test: stats_general [cttools-testing-framework.py] INFO: --- running test: stats_network [cttools-testing-framework.py] INFO: --- passed test: stats_network [cttools-testing-framework.py] INFO: --- running test: stats_runtime [cttools-testing-framework.py] INFO: --- passed test: stats_runtime [cttools-testing-framework.py] INFO: --- running test: stats_process [cttools-testing-framework.py] INFO: --- passed test: stats_process [cttools-testing-framework.py] INFO: --- running test: stats_queue [cttools-testing-framework.py] INFO: --- passed test: stats_queue [cttools-testing-framework.py] INFO: --- running test: stats_ct [cttools-testing-framework.py] INFO: --- passed test: stats_ct [cttools-testing-framework.py] INFO: --- running test: stats_expect [cttools-testing-framework.py] INFO: --- passed test: stats_expect [cttools-testing-framework.py] INFO: --- [cttools-testing-framework.py] INFO: --- finished [cttools-testing-framework.py] INFO: --- passed tests: 7 [cttools-testing-framework.py] INFO: --- failed tests: 0 [cttools-testing-framework.py] INFO: --- scenario failure: 0 [cttools-testing-framework.py] INFO: --- total tests: 7 === 8< === Signed-off-by: Arturo Borrero Gonzalez <arturo@xxxxxxxxxxxxx> --- HINT: if you fuzz a bit the conntrackd.conf file in this scenario these simple tests fails with several segfaults. env.yaml | 2 ++ scenarios.yaml | 19 +++++++++++++++++++ tests.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/tests/env.yaml b/tests/env.yaml new file mode 100644 index 0000000..8a7514b --- /dev/null +++ b/tests/env.yaml @@ -0,0 +1,2 @@ +- CONNTRACKD: ../src/conntrackd +- CONNTRACK: ../src/conntrack diff --git a/tests/scenarios.yaml b/tests/scenarios.yaml new file mode 100644 index 0000000..a47e1a1 --- /dev/null +++ b/tests/scenarios.yaml @@ -0,0 +1,19 @@ +- name: simple_stats + start: + - rm -f /var/lock/conntrack.lock + - | + cat << EOF > /tmp/conntrackd_test_simple_stats + General { + HashSize 8192 + LockFile /var/lock/conntrack.lock + UNIX { Path /var/run/conntrackd.ctl } + } + Stats { + LogFile on + } + EOF + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -d + stop: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -k + - rm -f /var/lock/conntrack.lock + - rm -f /tmp/conntrackd_test_simple_stats diff --git a/tests/tests.yaml b/tests/tests.yaml new file mode 100644 index 0000000..8324dbe --- /dev/null +++ b/tests/tests.yaml @@ -0,0 +1,41 @@ +- name: stats_general + scenario: simple_stats + # check that we can obtain stats via unix socket: general + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s | grep -q "cache stats" + +- name: stats_network + scenario: simple_stats + # check that we can obtain stats via unix socket: network (no output) + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s network + +- name: stats_runtime + scenario: simple_stats + # check that we can obtain stats via unix socket: runtime + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s runtime | grep -q uptime + +- name: stats_process + scenario: simple_stats + # check that we can obtain stats via unix socket: process (no output) + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s process + +- name: stats_queue + scenario: simple_stats + # check that we can obtain stats via unix socket: queue (no output) + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s queue + +- name: stats_ct + scenario: simple_stats + # check that we can obtain stats via unix socket: ct + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s ct | grep -q traffic + +- name: stats_expect + scenario: simple_stats + # check that we can obtain stats via unix socket: expect (no output) + test: + - $CONNTRACKD -C /tmp/conntrackd_test_simple_stats -s expect