Skip to content

Commit 7915890

Browse files
committed
ft-orchestration make loop offsets for ft-replay optional
1 parent 58c6bc2 commit 7915890

4 files changed

Lines changed: 32 additions & 14 deletions

File tree

tools/ft-orchestration/src/config/scenario.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class SimConfig(YAMLWizard):
114114
probe: Optional[ProbeCfg] = None
115115
generator: Optional[FtGeneratorConfig] = None
116116
prefilter_ranges: Optional[list[str]] = None
117+
apply_loop_offsets: Optional[bool] = True
117118

118119
def get_probe_conf(self, probe_type: str, default: ProbeCfg) -> dict:
119120
"""Get probe configuration for a specific probe type (merged with the default configuration).

tools/ft-orchestration/tests/simulation/test_simulation_general.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def setup_replicator(
165165
prefilter_conf: list[str],
166166
loop_cnt: int,
167167
unit_cnt: int,
168+
apply_loop_offset: bool,
168169
) -> tuple[FlowReplicator, list[str]]:
169170
"""
170171
Setup replicator units and loops so that there is enough bits in an IP prefix
@@ -215,9 +216,9 @@ def setup_replicator(
215216
)
216217
for subnet in prefilter_conf:
217218
extended_prefilter_conf.add(ip_network_add_offset(subnet, offset))
218-
219-
loop_offset = unit_cnt * 2 ** (32 - prefix)
220-
generator.set_loop_modifiers(srcip_offset=loop_offset, dstip_offset=loop_offset)
219+
if apply_loop_offset:
220+
loop_offset = unit_cnt * 2 ** (32 - prefix)
221+
generator.set_loop_modifiers(srcip_offset=loop_offset, dstip_offset=loop_offset)
221222
extended_prefilter_conf = {
222223
ip_network_add_offset(subnet, loop_n * loop_offset)
223224
for subnet in extended_prefilter_conf
@@ -336,6 +337,7 @@ def finalizer_download_logs():
336337
scenario.test.get_prefilter_conf(scenario.default),
337338
scenario.test.loops,
338339
scenario.test.get_replicator_units(scenario.sampling),
340+
scenario.test.apply_loop_offsets,
339341
)
340342
if len(prefilter_conf) > 0:
341343
probe_instance.set_prefilter(prefilter_conf)

tools/ft-orchestration/tests/simulation/test_simulation_overload.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ def create_evaluation_segments(
100100

101101

102102
def setup_replicator(
103-
generator: Replicator, conf: FtGeneratorConfig, multiplier: float, unit_cnt: int
103+
generator: Replicator,
104+
conf: FtGeneratorConfig,
105+
multiplier: float,
106+
unit_cnt: int,
107+
apply_loop_offsets: bool,
104108
) -> tuple[FlowReplicator, list[SMSubnetSegment]]:
105109
"""
106110
Setup replicator units and loops so that there is enough bits in an IP prefix
@@ -157,10 +161,11 @@ def setup_replicator(
157161
)
158162

159163
# loop offset
160-
generator.set_loop_modifiers(
161-
srcip_offset=loop_units * 2 ** (32 - prefix),
162-
dstip_offset=loop_units * 2 ** (32 - prefix),
163-
)
164+
if apply_loop_offsets:
165+
generator.set_loop_modifiers(
166+
srcip_offset=loop_units * 2 ** (32 - prefix),
167+
dstip_offset=loop_units * 2 ** (32 - prefix),
168+
)
164169
segments = create_evaluation_segments(
165170
conf.ipv4.ip_range, conf.ipv6.ip_range, prefix, unit_cnt, loop_units
166171
)
@@ -277,6 +282,7 @@ def finalizer_download_logs():
277282
generator_conf,
278283
scenario.test.multiplier,
279284
int(1 / scenario.sampling),
285+
scenario.test.apply_loop_offsets,
280286
)
281287
speed = (
282288
scenario.test.speed_multiplier

tools/ft-orchestration/tests/simulation/test_simulation_threshold.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ def validate(
9898

9999

100100
def setup_replicator(
101-
generator: Replicator, conf: FtGeneratorConfig, loop_cnt: int, unit_cnt: int
101+
generator: Replicator,
102+
conf: FtGeneratorConfig,
103+
loop_cnt: int,
104+
unit_cnt: int,
105+
apply_loop_offsets: bool,
102106
) -> FlowReplicator:
103107
"""
104108
Setup replicator units and loops so that there is enough bits in an IP prefix
@@ -141,10 +145,11 @@ def setup_replicator(
141145
dstip=Replicator.AddConstant(unit_n * 2 ** (32 - prefix)),
142146
)
143147

144-
generator.set_loop_modifiers(
145-
srcip_offset=unit_cnt * 2 ** (32 - prefix),
146-
dstip_offset=unit_cnt * 2 ** (32 - prefix),
147-
)
148+
if apply_loop_offsets:
149+
generator.set_loop_modifiers(
150+
srcip_offset=unit_cnt * 2 ** (32 - prefix),
151+
dstip_offset=unit_cnt * 2 ** (32 - prefix),
152+
)
148153
logging.getLogger().info(
149154
"Generator - ipv4 range: %s, ipv6 range: %s",
150155
conf.ipv4.ip_range,
@@ -245,7 +250,11 @@ def run_single_test(
245250
probe_instance.start()
246251

247252
flow_replicator = setup_replicator(
248-
generator_instance, generator_conf, loops, replicator_units
253+
generator_instance,
254+
generator_conf,
255+
loops,
256+
replicator_units,
257+
scenario.test.apply_loop_offsets,
249258
)
250259
generator_instance.start_profile(
251260
profile_path,

0 commit comments

Comments
 (0)