diff --git a/util/tests/JSON/input-number-lists.json b/util/tests/JSON/input-number-lists.json new file mode 100644 index 00000000..a3ae25c6 --- /dev/null +++ b/util/tests/JSON/input-number-lists.json @@ -0,0 +1,134 @@ +{ + "benchmarks": [ + { + "name": "iperf", + "ids": "1-10+21-30", + "mv-params": { + "global-options": [ + { + "name": "required", + "params": [ + { "arg": "time", "vals": [ "10" ], "role": "client" }, + { "arg": "protocol", "vals": [ "tcp" ] }, + { "arg": "bitrate", "vals": [ "0" ] }, + { "arg": "ifname", "vals": [ "default-route" ], "role": "server" } + ] + } + ], + "sets": [ + { + "include": "required", + "params": [ + { "arg": "length", "vals": [ "256" ] } + ] + } + ] + } + }, + { + "name": "uperf", + "ids": [ + "11-20", + "31-39", + 40 + ], + "mv-params": { + "global-options": [ + { + "name": "required", + "params": [ + { "arg": "protocol", "vals": [ "tcp" ], "role": "client" }, + { "arg": "wsize", "vals": [ "256" ], "role": "client" }, + { "arg": "rsize", "vals": [ "256" ], "role": "client" }, + { "arg": "duration", "vals": [ "10" ], "role": "client" }, + { "arg": "ifname", "vals" : [ "default-route" ], "role": "server" } + ] + } + ], + "sets": [ + { + "include": "required", + "params": [ + { "arg": "test-type", "vals": [ "stream" ], "role": "client" }, + { "arg": "nthreads", "vals": [ "1" ], "role": "client" } + ] + } + ] + } + } + ], + "tags": { + "foo": "bar" + }, + "tool-params": [], + "endpoints": [ + { + "type": "remotehost", + "host": "ENDPOINT_HOST_1", + "user": "root", + "userenv": "rhubi9", + "server": "1-10+31-40", + "client": [ + "11-20", + "21-29", + 30 + ], + "profiler": 1, + "config": [ + { + "targets": [ + { "role": "server", "ids": "1-10+31-40" }, + { "role": "profiler", "ids": 1 } + ], + "settings": { + "osruntime": "chroot" + } + }, + { + "targets": [ + { "role": "client", "ids": [ "11-20", "21-29", 30 ] } + ], + "settings": { + "osruntime": "podman" + } + } + ] + }, + { + "type": "remotehost", + "host": "ENDPOINT_HOST_2", + "user": "root", + "userenv": "rhubi8", + "server": [ + 11, + "12-20", + "21-30" + ], + "client": "1-10+31-40", + "profiler": 2, + "config": [ + { + "targets": [ + { "role": "server", "ids": [ 11, "12-20", "21-30" ] }, + { "role": "profiler", "ids": 2 } + ], + "settings": { + "osruntime": "chroot" + } + }, + { + "targets": [ + { "role": "client", "ids": "1-10+31-40" } + ], + "settings": { + "osruntime": "podman" + } + } + ] + } + ], + "run-params": { + "num-samples": 1, + "test-order": "s" + } +} diff --git a/util/tests/JSON/output-number-lists-benchmarks.json b/util/tests/JSON/output-number-lists-benchmarks.json new file mode 100644 index 00000000..98e59c78 --- /dev/null +++ b/util/tests/JSON/output-number-lists-benchmarks.json @@ -0,0 +1 @@ +iperf:1-10+21-30,uperf:11-20+31-39+40 diff --git a/util/tests/JSON/output-number-lists-endpoints-0.json b/util/tests/JSON/output-number-lists-endpoints-0.json new file mode 100644 index 00000000..cdad426d --- /dev/null +++ b/util/tests/JSON/output-number-lists-endpoints-0.json @@ -0,0 +1 @@ +remotehost,host:ENDPOINT_HOST_1,user:root,userenv:rhubi9,server:1-10+31-40,client:11-20+21-29+30,profiler:1,osruntime:server-1-10+31-40:chroot,osruntime:profiler-1:chroot,osruntime:client-11-20+21-29+30:podman diff --git a/util/tests/JSON/output-number-lists-endpoints-1.json b/util/tests/JSON/output-number-lists-endpoints-1.json new file mode 100644 index 00000000..ba4e0a58 --- /dev/null +++ b/util/tests/JSON/output-number-lists-endpoints-1.json @@ -0,0 +1 @@ +remotehost,host:ENDPOINT_HOST_2,user:root,userenv:rhubi8,server:11+12-20+21-30,client:1-10+31-40,profiler:2,osruntime:server-11+12-20+21-30:chroot,osruntime:profiler-2:chroot,osruntime:client-1-10+31-40:podman diff --git a/util/tests/test-blockbreaker.py b/util/tests/test-blockbreaker.py index 3697ae1d..518dcd06 100755 --- a/util/tests/test-blockbreaker.py +++ b/util/tests/test-blockbreaker.py @@ -180,3 +180,30 @@ def test_dump_json_mvparams_index1(self, load_json_file): input_json = blockbreaker.dump_json(benchmark_blk, "mv-params", 0) expected_output = self._load_file("output-multibench-k8s-remotehost-mvparams1.json") assert input_json == expected_output + + """Test if get_bench_ids returns the correct stream""" + @pytest.mark.parametrize("load_json_file", + [ "input-number-lists.json" ], indirect = True) + def test_get_bench_ids_benchmarks(self, load_json_file): + benchmarks_stream = blockbreaker.get_bench_ids(load_json_file, "benchmarks") + expected_stream = self._load_file("output-number-lists-benchmarks.json") + + assert expected_stream in benchmarks_stream + + """Test if json_to_stream properly processes input-number-lists.json endpoint 0""" + @pytest.mark.parametrize("load_json_file", + [ "input-number-lists.json" ], indirect = True) + def test_json_to_stream_endpoints_number_lists_0(self, load_json_file): + endpoint_0_stream = blockbreaker.json_to_stream(load_json_file, "endpoints", 0) + expected_stream = self._load_file("output-number-lists-endpoints-0.json") + + assert expected_stream in endpoint_0_stream + + """Test if json_to_stream properly processes input-number-lists.json endpoint 1""" + @pytest.mark.parametrize("load_json_file", + [ "input-number-lists.json" ], indirect = True) + def test_json_to_stream_endpoints_number_lists_1(self, load_json_file): + endpoint_1_stream = blockbreaker.json_to_stream(load_json_file, "endpoints", 1) + expected_stream = self._load_file("output-number-lists-endpoints-1.json") + + assert expected_stream in endpoint_1_stream diff --git a/util/tests/test-validate_run_file.py b/util/tests/test-validate_run_file.py index 2874e7ae..a98a146a 100755 --- a/util/tests/test-validate_run_file.py +++ b/util/tests/test-validate_run_file.py @@ -9,7 +9,17 @@ class TestValidateRunFile: """Validate all ci runfiles""" @pytest.mark.parametrize("runfile", glob.glob("tests/JSON/ci-*.json")) - def test_validate_run_file(self, runfile, capsys): + def test_validate_ci_run_files(self, runfile, capsys): + validate = validate_run_file.validate(runfile) + out, err = capsys.readouterr() + assert validate == 0 + assert "[ OK ]" in out + assert err == "" + + """Validate other runfiles""" + @pytest.mark.parametrize("runfile", + [ "tests/JSON/input-number-lists.json" ]) + def test_validate_other_run_files(self, runfile, capsys): validate = validate_run_file.validate(runfile) out, err = capsys.readouterr() assert validate == 0