The archive_logs() function in ci.sh used to recursively copy
everything matching tests/upgrade-testsuite.*, which included
the entire base-repo source checkout with all object files and
binaries.  This made the CI artifact unnecessarily large.

Move the log collection logic into Python (collect_logs() in
ovn_upgrade_utils.py) so that only the relevant files are
gathered into upgrade-testsuite.dir/logs/ before archiving:

  - Log and metadata files directly under
    upgrade-testsuite.dir (*.log, *.txt, *.h).
  - Test results from base-repo/tests/ (the testsuite log
    and per-test directories), matching what other test
    suites already retain.

The cleanup handler in ovn_upgrade_test.py calls
collect_logs() unconditionally, and ci.sh now archives
just the pre-collected logs/ directory.

Assisted-by: Claude Opus 4.6, OpenCode
Signed-off-by: Ales Musil <[email protected]>
---
 .ci/ci.sh                |  4 ++--
 .ci/ovn_upgrade_test.py  |  2 ++
 .ci/ovn_upgrade_utils.py | 31 +++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/.ci/ci.sh b/.ci/ci.sh
index 19749a039..1eba61812 100755
--- a/.ci/ci.sh
+++ b/.ci/ci.sh
@@ -52,8 +52,8 @@ function archive_logs() {
         cp -r $CONTAINER_WORKDIR/tests/system-*-testsuite.* \
         $log_dir || true \
         && \
-        cp -r $CONTAINER_WORKDIR/tests/upgrade-testsuite.* \
-        $log_dir || true \
+        cp -r $CONTAINER_WORKDIR/tests/upgrade-testsuite.dir/logs \
+        $log_dir/upgrade-testsuite.dir || true \
         && \
         chmod -R +r $log_dir \
         &&
diff --git a/.ci/ovn_upgrade_test.py b/.ci/ovn_upgrade_test.py
index e38145cc2..d73d57596 100755
--- a/.ci/ovn_upgrade_test.py
+++ b/.ci/ovn_upgrade_test.py
@@ -15,6 +15,7 @@ from ovn_upgrade_utils import (
     ovn_upgrade_save_current_binaries,
     ovn_upgrade_extract_info,
     run_upgrade_workflow,
+    collect_logs,
     remove_upgrade_test_directory,
     UpgradeConfig
 )
@@ -45,6 +46,7 @@ def main():
     test_success = False
 
     def cleanup():
+        collect_logs(config)
         flags = os.environ.get('TESTSUITEFLAGS', '')
         if '-d' in flags or '--debug' in flags or not test_success:
             log(f"Keeping {config.path.upgrade_dir} for debugging")
diff --git a/.ci/ovn_upgrade_utils.py b/.ci/ovn_upgrade_utils.py
index b96696e1a..ccceabb18 100755
--- a/.ci/ovn_upgrade_utils.py
+++ b/.ci/ovn_upgrade_utils.py
@@ -23,6 +23,7 @@ GIT_LOG = 'git.log'
 NEW_EGRESS = 'ovn-upgrade-new-log-egress.txt'
 M4_DEFINES = 'ovn-upgrade-oftable-m4-defines.txt'
 OFCTL_DEFINES = 'ovn-upgrade-ofctl-defines.h'
+LOGS_DIR = 'logs'
 
 
 @contextlib.contextmanager
@@ -42,6 +43,7 @@ class PathConfig:
     base_dir: Path      # Path for base branch i.e. from which we upgrade
     binaries_dir: Path  # Path for binaries from dst branch
     test_dir: Path      # Path for system tests run by upgrade tests.
+    logs_dir: Path      # Path for collected logs (for CI archiving).
 
 
 @dataclass
@@ -86,6 +88,7 @@ class UpgradeConfig:
             base_dir=base_dir,
             upgrade_dir=upgrade_dir,
             test_dir=base_dir / SYSTEM_TESTS_DIR,
+            logs_dir=upgrade_dir / LOGS_DIR,
         )
 
         file_obj = FileConfig(
@@ -659,6 +662,34 @@ def run_upgrade_workflow(config):
         return True
 
 
+def collect_logs(config):
+    """Collect relevant logs into upgrade-testsuite.dir/logs/.
+
+    Copies only the files needed for debugging (log files from
+    upgrade-testsuite.dir and test results from base-repo) so that
+    ci.sh can archive a single small directory instead of the entire
+    base-repo source tree.
+    """
+    logs_dir = config.path.logs_dir
+    logs_dir.mkdir(parents=True, exist_ok=True)
+
+    # Collect log files from upgrade-testsuite.dir.
+    for pattern in ('*.log', '*.txt', '*.h'):
+        for f in config.path.upgrade_dir.glob(pattern):
+            shutil.copy2(f, logs_dir)
+
+    # Collect test results from base-repo (log + per-test dirs).
+    test_log = config.file.test_log
+    test_dir = config.path.test_dir
+    if test_log.exists():
+        shutil.copy2(test_log, logs_dir)
+    if test_dir.exists():
+        shutil.copytree(test_dir, logs_dir / test_dir.name,
+                        dirs_exist_ok=True)
+
+    log(f"Logs collected in {logs_dir}")
+
+
 def remove_upgrade_test_directory(config):
     upgrade_dir = config.path.upgrade_dir
     test_dir = config.path.test_dir
-- 
2.55.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to