Skip to content

Commit f6292ce

Browse files
committed
ci: Fix upgrade test table number remapping.
The update_test() function only remapped hardcoded table=NUMBER values in the range [LOG_EGRESS_PIPELINE, SAVE_INPORT). Tables beyond SAVE_INPORT, such as CHK_LB_AFFINITY (78 -> 102), were not patched. This caused all LB affinity upgrade tests to fail when upgrading from branch-24.03 because the old test files use hardcoded table=78 while the new ovn-controller puts learned flows in table 102. Keep the range-based shift for in-pipeline tables [LOG_EGRESS, SAVE_INPORT) since tests use hardcoded offsets within the pipeline, and add exact remapping for every OFTABLE_ define that changed outside that range. Fixes: 9b26455 ("ci: Run system tests in upgrade scenario.") Assisted-by: Claude Opus 4.6, OpenCode Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ales Musil <amusil@redhat.com> (cherry picked from commit 8450f13)
1 parent 47f5fa1 commit f6292ce

1 file changed

Lines changed: 54 additions & 23 deletions

File tree

.ci/ovn_upgrade_utils.py

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,28 @@ def ovn_upgrade_save_ovn_debug(binaries_dir):
410410
return True
411411

412412

413-
def update_test(old_start, old_end, shift, test_file):
413+
def _parse_oftable_defines(lines):
414+
"""Return {name: int_value} for all OFTABLE_ #defines."""
415+
result = {}
416+
for line in lines:
417+
parts = line.split()
418+
if len(parts) >= 3 and parts[0] == '#define' \
419+
and parts[1].startswith('OFTABLE_'):
420+
try:
421+
result[parts[1]] = int(parts[2])
422+
except ValueError:
423+
pass
424+
return result
425+
426+
427+
def update_test(table_remap, test_file):
414428
with open(test_file, encoding='utf-8') as f:
415429
content = f.read()
416430

417431
def replace_table(match):
418432
table_num = int(match.group(1))
419-
if old_start <= table_num < old_end:
420-
return f"table={table_num + shift}"
433+
if table_num in table_remap:
434+
return f"table={table_remap[table_num]}"
421435
return match.group(0)
422436

423437
# Replace all table=NUMBER patterns
@@ -430,44 +444,61 @@ def replace_table(match):
430444
def ovn_upgrade_table_numbers_in_tests_patch(config):
431445
lflow_h = Path('controller/lflow.h')
432446

433-
if not config.file.new_egress.exists():
434-
log("No LOG_EGRESS")
447+
if not config.file.ofctl_defines.exists():
448+
log("No ofctl defines file")
435449
return False
436450

437451
if not lflow_h.exists():
438452
log("Controller/lflow.h not found")
439453
return False
440454

441-
with open(config.file.new_egress, encoding='utf-8') as f:
442-
new_log_egress = int(f.read().strip())
455+
# Get new OFTABLE values (saved from the current version).
456+
with open(config.file.ofctl_defines, encoding='utf-8') as f:
457+
new_defines = _parse_oftable_defines(f.readlines())
443458

444-
# Get old values from base version's lflow.h
459+
# Get old OFTABLE values from the base version's lflow.h.
445460
with open(lflow_h, encoding='utf-8') as f:
446-
content = [
447-
line.strip() for line in f if line.startswith('#define OFTABLE_')
448-
]
461+
old_defines = _parse_oftable_defines(f.readlines())
449462

450-
old_log_egress, old_save_inport = extract_oftable_values(content)
463+
old_log_egress = old_defines.get('OFTABLE_LOG_EGRESS_PIPELINE')
464+
old_save_inport = old_defines.get('OFTABLE_SAVE_INPORT')
451465

452-
if (not old_log_egress or not old_save_inport
453-
or old_log_egress == new_log_egress):
454-
log(f"No change in test files as old_log_egress={old_log_egress}, "
455-
f"old_save_inport={old_save_inport} and "
456-
f"new_log_egress={new_log_egress}")
457-
# No change needed is success.
458-
return True
466+
if not old_log_egress or not old_save_inport:
467+
log("Could not extract LOG_EGRESS / SAVE_INPORT from base")
468+
return False
469+
470+
new_log_egress = new_defines.get('OFTABLE_LOG_EGRESS_PIPELINE')
471+
472+
# Build {old_value: new_value} remap for all changed tables.
473+
table_remap = {}
459474

460-
shift = new_log_egress - old_log_egress
475+
# Range-based shift for in-pipeline tables [LOG_EGRESS, SAVE_INPORT).
476+
# These include hardcoded offsets that are not OFTABLE_ defines.
477+
if new_log_egress and new_log_egress != old_log_egress:
478+
shift = new_log_egress - old_log_egress
479+
for t in range(old_log_egress, old_save_inport):
480+
table_remap[t] = t + shift
481+
482+
# Exact remap for every OFTABLE_ define that changed and is
483+
# outside the pipeline range (e.g. CHK_LB_AFFINITY, ECMP_NH).
484+
for name, old_val in old_defines.items():
485+
if name in new_defines and new_defines[name] != old_val:
486+
if old_val not in table_remap:
487+
table_remap[old_val] = new_defines[name]
488+
489+
if not table_remap:
490+
log("No table number changes detected")
491+
return True
461492

462-
log(f"Updating hardcoded table numbers in tests (shift: +{shift} for "
463-
f"tables {old_log_egress}-{old_save_inport - 1})")
493+
log(f"Updating hardcoded table numbers in tests "
494+
f"({len(table_remap)} table(s) remapped)")
464495

465496
# Update test files
466497
for test_file in ['tests/system-ovn.at', 'tests/system-ovn-kmod.at',
467498
'tests/system-ovn-netlink.at']:
468499
if Path(test_file).exists():
469500
log(f"Updating {test_file}")
470-
update_test(old_log_egress, old_save_inport, shift, test_file)
501+
update_test(table_remap, test_file)
471502
return True
472503

473504

0 commit comments

Comments
 (0)