3
3
"""Tests the network latency of a Firecracker guest."""
4
4
5
5
import re
6
+ import json
7
+ from pathlib import Path
6
8
7
9
import pytest
8
10
@@ -55,7 +57,7 @@ def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs):
55
57
56
58
@pytest .mark .nonci
57
59
@pytest .mark .parametrize ("network_microvm" , [1 ], indirect = True )
58
- def test_network_latency (network_microvm , metrics ):
60
+ def test_network_latency (network_microvm , metrics , test_output_dir ):
59
61
"""
60
62
Test network latency by sending pings from the guest to the host.
61
63
"""
@@ -84,6 +86,11 @@ def test_network_latency(network_microvm, metrics):
84
86
for sample in samples :
85
87
metrics .put_metric ("ping_latency" , sample , "Milliseconds" )
86
88
89
+ data = {"samples" : samples }
90
+ metrics_path = Path (test_output_dir / "metrics.json" )
91
+ with open (metrics_path , "w" ) as f :
92
+ json .dump (data , f )
93
+
87
94
88
95
@pytest .mark .nonci
89
96
@pytest .mark .timeout (120 )
@@ -95,6 +102,7 @@ def test_network_tcp_throughput(
95
102
payload_length ,
96
103
mode ,
97
104
metrics ,
105
+ test_output_dir ,
98
106
):
99
107
"""
100
108
Iperf between guest and host in both directions for TCP workload.
@@ -133,4 +141,16 @@ def test_network_tcp_throughput(
133
141
)
134
142
data = test .run_test (network_microvm .vcpus_count + 2 )
135
143
144
+ cpu_load_path = Path (test_output_dir / "cpu_load.json" )
145
+ with open (cpu_load_path , "w" ) as f :
146
+ json .dump (data ["cpu_load_raw" ], f )
147
+ for i , g2h in enumerate (data ["g2h" ]):
148
+ path = Path (test_output_dir / f"g2h_{ i } .json" )
149
+ with open (path , "w" ) as f :
150
+ json .dump (g2h , f )
151
+ for i , h2g in enumerate (data ["h2g" ]):
152
+ path = Path (test_output_dir / f"h2g_{ i } .json" )
153
+ with open (path , "w" ) as f :
154
+ json .dump (h2g , f )
155
+
136
156
emit_iperf3_metrics (metrics , data , warmup_sec )
0 commit comments