Skip to content

Commit

Permalink
add blockbreaker unit testing of the different ways of supplying numb…
Browse files Browse the repository at this point in the history
…ers, number ranges, list of number-ranges
  • Loading branch information
k-rister committed Dec 14, 2023
1 parent 06c6670 commit c4bb68e
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 1 deletion.
134 changes: 134 additions & 0 deletions util/tests/JSON/input-number-lists.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions util/tests/JSON/output-number-lists-benchmarks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iperf:1-10+21-30,uperf:11-20+31-39+40
1 change: 1 addition & 0 deletions util/tests/JSON/output-number-lists-endpoints-0.json
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions util/tests/JSON/output-number-lists-endpoints-1.json
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions util/tests/test-blockbreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion util/tests/test-validate_run_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4bb68e

Please sign in to comment.