Skip to content

Commit f419083

Browse files
committed
test: move tcp throughput parameters from baseline to pytest
Makes it easier to understand what tests are run/failing Signed-off-by: Patrick Roy <[email protected]>
1 parent e00bed1 commit f419083

File tree

4 files changed

+77
-141
lines changed

4 files changed

+77
-141
lines changed

tests/integration_tests/performance/configs/test_network_tcp_throughput_config_4.14.json

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,6 @@
19611961
}
19621962
}
19631963
},
1964-
"load_factor": 1,
19651964
"measurements": {
19661965
"cpu_utilization_vcpus_total": {
19671966
"statistics": [
@@ -2001,28 +2000,5 @@
20012000
],
20022001
"unit": "Mbps"
20032002
}
2004-
},
2005-
"modes": {
2006-
"bd": [
2007-
"",
2008-
"-R"
2009-
],
2010-
"g2h": [
2011-
""
2012-
],
2013-
"h2g": [
2014-
"-R"
2015-
]
2016-
},
2017-
"protocols": [
2018-
{
2019-
"name": "tcp",
2020-
"omit": 5,
2021-
"payload_length": [
2022-
"1024K",
2023-
"DEFAULT"
2024-
]
2025-
}
2026-
],
2027-
"time": 20
2003+
}
20282004
}

tests/integration_tests/performance/configs/test_network_tcp_throughput_config_5.10.json

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,6 @@
19611961
}
19621962
}
19631963
},
1964-
"load_factor": 1,
19651964
"measurements": {
19661965
"cpu_utilization_vcpus_total": {
19671966
"statistics": [
@@ -2001,33 +2000,5 @@
20012000
],
20022001
"unit": "Mbps"
20032002
}
2004-
},
2005-
"modes": {
2006-
"bd": [
2007-
"",
2008-
"-R"
2009-
],
2010-
"g2h": [
2011-
""
2012-
],
2013-
"h2g": [
2014-
"-R"
2015-
]
2016-
},
2017-
"protocols": [
2018-
{
2019-
"name": "tcp",
2020-
"omit": 5,
2021-
"payload_length": [
2022-
"1024K",
2023-
"DEFAULT"
2024-
],
2025-
"window_size": [
2026-
"16K",
2027-
"256K",
2028-
"DEFAULT"
2029-
]
2030-
}
2031-
],
2032-
"time": 20
2003+
}
20332004
}

tests/integration_tests/performance/configs/test_network_tcp_throughput_config_6.1.json

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,6 @@
19611961
}
19621962
}
19631963
},
1964-
"load_factor": 1,
19651964
"measurements": {
19661965
"cpu_utilization_vcpus_total": {
19671966
"statistics": [
@@ -2001,28 +2000,5 @@
20012000
],
20022001
"unit": "Mbps"
20032002
}
2004-
},
2005-
"modes": {
2006-
"bd": [
2007-
"",
2008-
"-R"
2009-
],
2010-
"g2h": [
2011-
""
2012-
],
2013-
"h2g": [
2014-
"-R"
2015-
]
2016-
},
2017-
"protocols": [
2018-
{
2019-
"name": "tcp",
2020-
"omit": 5,
2021-
"payload_length": [
2022-
"1024K",
2023-
"DEFAULT"
2024-
]
2025-
}
2026-
],
2027-
"time": 20
2003+
}
20282004
}

tests/integration_tests/performance/test_network_tcp_throughput.py

Lines changed: 74 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
CONFIG_NAME_ABS = os.path.join(defs.CFG_LOCATION, CONFIG_NAME_REL)
3030
CONFIG_DICT = json.load(open(CONFIG_NAME_ABS, encoding="utf-8"))
3131

32+
# Number of seconds to wait for the iperf3 server to start
33+
SERVER_STARTUP_TIME_SEC = 2
3234
DEBUG = False
3335
IPERF3 = "iperf3"
3436
THROUGHPUT = "throughput"
@@ -43,6 +45,18 @@
4345
DELTA_PERCENTAGE_TAG = "delta_percentage"
4446
TARGET_TAG = "target"
4547

48+
# How many clients/servers should be spawned per vcpu
49+
LOAD_FACTOR = 1
50+
51+
# Time (in seconds) for which iperf "warms up"
52+
WARMUP_SEC = 5
53+
54+
# Time (in seconds) for which iperf runs after warmup is done
55+
RUNTIME_SEC = 20
56+
57+
# Dictionary mapping modes (guest-to-host, host-to-guest, bidirectional) to arguments passed to the iperf3 clients spawned
58+
MODE_MAP = {"bd": ["", "-R"], "g2h": [""], "h2g": ["-R"]}
59+
4660

4761
# pylint: disable=R0903
4862
class NetTCPThroughputBaselineProvider(BaselineProvider):
@@ -95,7 +109,7 @@ def produce_iperf_output(
95109
current_avail_cpu += 1
96110

97111
# Wait for iperf3 server to start.
98-
time.sleep(2)
112+
time.sleep(SERVER_STARTUP_TIME_SEC)
99113

100114
# Start `vcpus` iperf3 clients. We can not use iperf3 parallel streams
101115
# due to non deterministic results and lack of scaling.
@@ -217,76 +231,73 @@ def consume_iperf_tcp_output(cons, result, vcpus_count):
217231
cons.consume_custom(fcvcpu_samples_tag, cpu_util_fc_vcpu_samples)
218232

219233

220-
def create_pipes_generator(basevm, mode, current_avail_cpu, protocol, host_ip, env_id):
234+
def pipe(basevm, mode, payload_length, current_avail_cpu, host_ip, env_id):
221235
"""Create producer/consumer pipes."""
222-
for payload_length in protocol["payload_length"]:
223-
iperf_guest_cmd_builder = (
224-
CmdBuilder(IPERF3)
225-
.with_arg("--verbose")
226-
.with_arg("--client", host_ip)
227-
.with_arg("--time", CONFIG_DICT["time"])
228-
.with_arg("--json")
229-
.with_arg("--omit", protocol["omit"])
236+
iperf_guest_cmd_builder = (
237+
CmdBuilder(IPERF3)
238+
.with_arg("--verbose")
239+
.with_arg("--client", host_ip)
240+
.with_arg("--time", RUNTIME_SEC)
241+
.with_arg("--json")
242+
.with_arg("--omit", WARMUP_SEC)
243+
)
244+
245+
if payload_length != "DEFAULT":
246+
iperf_guest_cmd_builder = iperf_guest_cmd_builder.with_arg(
247+
"--len", f"{payload_length}"
230248
)
231249

232-
if payload_length != "DEFAULT":
233-
iperf_guest_cmd_builder = iperf_guest_cmd_builder.with_arg(
234-
"--len", f"{payload_length}"
235-
)
236-
237-
iperf3_id = f"tcp-p{payload_length}-wsDEFAULT-{mode}"
238-
239-
cons = consumer.LambdaConsumer(
240-
metadata_provider=DictMetadataProvider(
241-
measurements=CONFIG_DICT["measurements"],
242-
baseline_provider=NetTCPThroughputBaselineProvider(env_id, iperf3_id),
243-
),
244-
func=consume_iperf_tcp_output,
245-
func_kwargs={"vcpus_count": basevm.vcpus_count},
246-
)
247-
248-
prod_kwargs = {
249-
"guest_cmd_builder": iperf_guest_cmd_builder,
250-
"basevm": basevm,
251-
"current_avail_cpu": current_avail_cpu,
252-
"runtime": CONFIG_DICT["time"],
253-
"omit": protocol["omit"],
254-
"load_factor": CONFIG_DICT["load_factor"],
255-
"modes": CONFIG_DICT["modes"][mode],
256-
}
257-
prod = producer.LambdaProducer(produce_iperf_output, prod_kwargs)
258-
yield cons, prod, f"{env_id}/{iperf3_id}"
259-
260-
261-
def pipes(basevm, host_ip, current_avail_cpu, env_id):
262-
"""Pipes generator."""
263-
for mode in CONFIG_DICT["modes"]:
264-
# We run bi-directional tests only on uVM with more than 2 vCPus
265-
# because we need to pin one iperf3/direction per vCPU, and since we
266-
# have two directions, we need at least two vCPUs.
267-
if mode == "bd" and basevm.vcpus_count < 2:
268-
continue
269-
270-
for protocol in CONFIG_DICT["protocols"]:
271-
# Distribute modes evenly between producers and consumers.
272-
pipes_generator = create_pipes_generator(
273-
basevm, mode, current_avail_cpu, protocol, host_ip, env_id
274-
)
275-
276-
for cons, prod, pipe_tag in pipes_generator:
277-
yield cons, prod, pipe_tag
250+
iperf3_id = f"tcp-p{payload_length}-wsDEFAULT-{mode}"
251+
252+
cons = consumer.LambdaConsumer(
253+
metadata_provider=DictMetadataProvider(
254+
measurements=CONFIG_DICT["measurements"],
255+
baseline_provider=NetTCPThroughputBaselineProvider(env_id, iperf3_id),
256+
),
257+
func=consume_iperf_tcp_output,
258+
func_kwargs={"vcpus_count": basevm.vcpus_count},
259+
)
260+
261+
prod_kwargs = {
262+
"guest_cmd_builder": iperf_guest_cmd_builder,
263+
"basevm": basevm,
264+
"current_avail_cpu": current_avail_cpu,
265+
"runtime": RUNTIME_SEC,
266+
"omit": WARMUP_SEC,
267+
"load_factor": LOAD_FACTOR,
268+
"modes": MODE_MAP[mode],
269+
}
270+
prod = producer.LambdaProducer(produce_iperf_output, prod_kwargs)
271+
return cons, prod, f"{env_id}/{iperf3_id}"
278272

279273

280274
@pytest.mark.nonci
281275
@pytest.mark.timeout(3600)
282276
@pytest.mark.parametrize("vcpus", [1, 2])
277+
@pytest.mark.parametrize(
278+
"payload_length", ["DEFAULT", "1024K"], ids=["pDEFAULT", "p1024K"]
279+
)
280+
@pytest.mark.parametrize("mode", ["g2h", "h2g", "bd"])
283281
def test_network_tcp_throughput(
284-
microvm_factory, network_config, guest_kernel, rootfs, vcpus, st_core
282+
microvm_factory,
283+
network_config,
284+
guest_kernel,
285+
rootfs,
286+
vcpus,
287+
payload_length,
288+
mode,
289+
st_core,
285290
):
286291
"""
287292
Iperf between guest and host in both directions for TCP workload.
288293
"""
289294

295+
# We run bi-directional tests only on uVM with more than 2 vCPus
296+
# because we need to pin one iperf3/direction per vCPU, and since we
297+
# have two directions, we need at least two vCPUs.
298+
if mode == "bd" and vcpus < 2:
299+
pytest.skip("bidrectional test only done with at least 2 vcpus")
300+
290301
guest_mem_mib = 1024
291302
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
292303
vm.spawn()
@@ -312,13 +323,15 @@ def test_network_tcp_throughput(
312323
current_avail_cpu += 1
313324
assert vm.pin_vcpu(i, current_avail_cpu), f"Failed to pin fc_vcpu {i} thread."
314325

315-
for cons, prod, tag in pipes(
326+
cons, prod, tag = pipe(
316327
vm,
317-
DEFAULT_HOST_IP,
328+
mode,
329+
payload_length,
318330
current_avail_cpu + 1,
331+
DEFAULT_HOST_IP,
319332
f"{guest_kernel.name()}/{rootfs.name()}/{microvm_cfg}",
320-
):
321-
st_core.add_pipe(prod, cons, tag)
333+
)
334+
st_core.add_pipe(prod, cons, tag)
322335

323336
# Start running the commands on guest, gather results and verify pass
324337
# criteria.

0 commit comments

Comments
 (0)