From bb15877800063e0bca1aa7864853c836dadb8afb Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 12 Sep 2024 08:17:23 -0300 Subject: [PATCH 01/33] tests: new approach to run tests in ubuntu and debian using snapd deb from the repo The idea of this change is to change de default behaviour for the deb pacage used in our spread tests. To simulate a more real scenario, and having snapd snap build from local, this change is adding as default a new scenario to have snapd installed from the deb repository. Then the deb package is saved in the same place as it was built in during the test, making easy to have both scenarios working together. It is a requirement also so be able to run the tests using a built snapd deb as we are currently doing. --- spread.yaml | 2 ++ tests/lib/prepare-restore.sh | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spread.yaml b/spread.yaml index 372ca5cd201..9a00ca397ba 100644 --- a/spread.yaml +++ b/spread.yaml @@ -82,6 +82,8 @@ environment: SNAPD_NO_MEMORY_LIMIT: '$(HOST: echo "${SPREAD_SNAPD_NO_MEMORY_LIMIT:-}")' SNAPD_PUBLISHED_VERSION: '$(HOST: echo "$SPREAD_SNAPD_PUBLISHED_VERSION")' + # Use the snapd package from the repository when possible + SNAPD_DEB_FROM_REPO: '$(HOST: echo "${SPREAD_SNAPD_DEB_FROM_REPO:-true}")' # Build and use snapd from current branch BUILD_SNAPD_FROM_CURRENT: '$(HOST: echo "${SPREAD_BUILD_SNAPD_FROM_CURRENT:-true}")' diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index b71b5eace24..10d69c339d5 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -585,7 +585,9 @@ prepare_project() { # go mod runs as root and will leave strange permissions chown test:test -R "$SPREAD_PATH" - if [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then + if [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; then + ( cd "${GOHOME}" && tests.pkgs download snapd ) + elif [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then case "$SPREAD_SYSTEM" in ubuntu-*|debian-*) build_deb From a2637fda70a9d9f9fdc3d299712da9090735223f Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 12 Sep 2024 08:20:48 -0300 Subject: [PATCH 02/33] Squashed 'tests/lib/external/snapd-testing-tools/' changes from 1c8efb77e1..33c1d672c6 33c1d672c6 update os.query test 5a428a71ea fix shellcheck 8b423d177a support opensuse 15.6 ab1fa59719 support tests.pkgs download 1e39b307b6 udpate image names for openstack 2a85365d51 remove support for fedora-38 and ubuntu mantic 112bc0a315 append in log-filter 1d4350a818 Make sure the tools are at the begining of the path 45c2f45004 address comments 8743ceaf8c tools: fix support for multi-arch packages on apt-based systems (#54) 33aa8d1e53 fix details in remote.retry test e43b9e314d rename test libraries to avoid static check errors in snapd 4ab8b00afb New spread-filter tool (#53) cdf5cfd47b Remove centos-7 support f3996cc3fa change the spread label 1e309f41c6 change how legacy parameter is determine in remote.pull c43c35f7e3 run remote refresh and wait-for for xenial (skip bionic) 5262d30da7 make sure the test jobs are executed in runners with the spread label cb74259b7a add openstack systems 0b41fd40d3 fix tests.pkgs on arch-linux 558e109793 run fedora-40 spread tests in openstack 6f6187416d fix list implementation b4a5439c9b added more type annotatios to log_helper 58da1e36c3 mypy cleaned 1ff651e680 update wording of remote.pull 18615b1667 just usc scp -O when ssh version is -ge 9 cc68c9868b Added type annotations for log-filter 66f90d10cd Adding -O to scp command to make it compatible in uc24 tests 496cb7b5b3 removing support for centos-8 f2eef30db4 Updated the log helper and log parser 5a375ebf73 Formatting for python utils d3eed3faa5 fix codespell in CODE_OF_CONDUCT.md 18bcca6b14 new log helper d60381fcd9 add run number to filtered filename 5dde2d67b8 consider the tests execution in main 6b9a3aabcc change filtered log name b2756aa579 default file is .filtered.log 500b9dace4 Fix tests workflow 45db26a3d2 fix shellcheck error in log-filter fe45c27b7d create a var to store filter params 5a9b66d7dc filter spread results 51f9b055af New tool used to filter the spread.log output b8d20c1d5b fix snaps.name test with correct siffix spelling f640ac72e3 Add missing test details f0754df304 Filter the error y debug output in log-parser fc10196efd Add suggestions to details 94ac5ffe58 Add details on tests 501578c719 add more checks in os.query to check is-core_xx e8929207ff fix os-query for ubuntu comparing with core 226114641f os.query won't check SPREAD_SYSTEM anymore to compare core systems b89ec98b23 use local variables in os.query tool dacfd81de9 fix is_core functions 1db5214d5f Improve the remote docs (#36) 2e4a3153a2 1 more comment 3a0fc57e1e add explanation about why we check for ( Do | Doing ) 4cf8e635bf fix os.query test after merge b89b4f8647 fix artifacts name d30cee6da0 Merge remote-tracking branch 'upstream/main' 5ef5dcbe8f Tests use artifacts in spread tests (#51) 555c43d2ab Support auto-refresh with Do instead of Doing 96c2b0c19c remove tests support for ubuntu 23.04 (EoL) 74082c0c34 Tests improve remote wait (#49) 5121bfb659 remove support for opensuse leap 15.4 (#48) 30df700d08 Add new systems support (#47) 1f08938925 Support check amazon linux version (#46) 43533bdd97 Change the exit value checking for test formats (#45) 3c88244c04 Update check-test-format to support a dir and a list of files (#44) 510d95f429 add extra check for error in auto-refresh detection function 3289d4031b Try open the log with latin-1 encoding when utf-8 is not working 9db785499f improved how the tools are waiting for system reboot 2a5c4414a3 fix shellcheck errors 5e7b63883d Fixes for osquery and tests pkgs (#43) 4c9145e2ac support reboot waiting for auto-refresh 45768f5188 show changes in unknown status after refresh 8013c30c2a Remove support for ubuntu 22.10 b32b80bf54 Fix remote.rait-for test in bionic 5675c625e9 Enable fedora 38 55f4471957 Support for new oss f2e88b357c New tool used to query spread json reports cacd35ede0 utils/spread-shellcheck: explain disabled warnings (#42) c82afb2dee Support --no-install-recommends parameter when installing dependencies with tests.pkgs b84eea92e2 spread-shellcheck: fix quotes in environment variables (#41) ab1e51c29f New comparison in os-query for core systems (#40) e5ae22a5d4 systemd units can be overwritten 63540b845a Fix error messages in remote pull and push 75e8a426a5 make sure the unit is removed in tests.systemd test 9089ff5c02 Update tests to use the new tests.systemd stop-unit 44ecd5e56a Move tests.systemd stop-units to stop-unit 01a2a83b4b Update tests.systemd to have stop units as systemd.sh 162e93bd35 update tests.systemd CLI options to be the same than retry command 14aa43a405 new feature to re-run failed spread tests (#39) 604cb782db Fix shellcheck in systemd tool bfc71082c8 Update the tests.systemd to allow parameters waiting for service status 8a2d0a99df Adding quiet tool and removing set +-x from tests.pkgs d90935d2a4 A comment explaining about the default values for wait-for 3232c5dba7 Add support for ubuntu 23.04 a7164fba07 remove fedora 35 support, add fedora 37 support 89b9eb5301 Update systems supported 92bb6a0664 Include snap-sufix in the snaps.name tool git-subtree-dir: tests/lib/external/snapd-testing-tools git-subtree-split: 33c1d672c6512b23892481eeb013bd01e5eb389a --- .github/workflows/tests.yaml | 91 ++- CODE_OF_CONDUCT.md | 2 +- remote/remote.pull | 18 +- remote/remote.push | 12 +- remote/remote.refresh | 4 +- remote/remote.setup | 2 +- remote/remote.wait-for | 76 ++- spread.yaml | 45 +- tests/check-test-format/task.yaml | 45 +- .../tasks/{task1 => task1.yaml} | 2 + .../tasks/{task2 => task2.yaml} | 2 + .../tasks/{task3 => task3.yaml} | 2 + .../tasks/{task4 => task4.yaml} | 2 - .../tasks/{task5 => task5.yaml} | 2 + .../tasks/{task6 => task6.yaml} | 2 + ...borted-and-failed-execute-and-restore.json | 86 +-- tests/log-analyzer/data/all-aborted.json | 36 +- tests/log-analyzer/data/all-failed.json | 104 ++-- .../data/all-success-failed-restore.json | 104 ++-- tests/log-analyzer/data/all-success.json | 104 ++-- .../data/failed-prepare-and-restore.json | 104 ++-- .../data/failed-prepare-project.json | 70 +-- .../data/failed-prepare-suite.json | 74 +-- .../data/failed-prepare-task.json | 144 ++--- .../data/with-aborted-and-failed-restore.json | 56 +- .../with-failed-and-failed-restore-suite.json | 493 +++++++++++++++ .../with-failed-and-failed-restore-suite.log | 79 +++ tests/log-analyzer/task.yaml | 33 +- tests/log-analyzer/tests/test-1/task.yaml | 2 + tests/log-analyzer/tests/test-2/task.yaml | 2 + tests/log-analyzer/tests/test-3/task.yaml | 2 + tests/log-analyzer/tests/test-4/task.yaml | 2 + tests/log-analyzer/tests/test-5/task.yaml | 2 + tests/log-filter/task.yaml | 51 ++ tests/log-parser/task.yaml | 54 +- tests/log-parser/with-all-results.log.spread | 3 +- tests/log-parser/with-debug-output.log.spread | 81 +++ tests/log-parser/with-error-output.log.spread | 81 +++ tests/not/task.yaml | 3 + tests/os.paths/task.yaml | 4 + tests/os.query/task.yaml | 60 +- tests/quiet/task.yaml | 12 + tests/remote.exec/task.yaml | 7 +- tests/remote.pull/task.yaml | 22 +- tests/remote.push/task.yaml | 20 +- tests/remote.refresh/task.yaml | 14 +- tests/remote.retry/task.yaml | 8 +- tests/remote.setup/task.yaml | 5 + tests/remote.wait-for/task.yaml | 14 +- tests/repack-kernel/task.yaml | 5 + tests/retry/task.yaml | 4 + tests/snaps.cleanup/task.yaml | 5 + tests/snaps.name/task.yaml | 17 + tests/spread-filter/HACKING.md | 0 tests/spread-filter/README.md | 0 tests/spread-filter/res | 1 + tests/spread-filter/rules.yaml | 33 + tests/spread-filter/source/file1 | 0 tests/spread-filter/source/file2 | 0 tests/spread-filter/source/lib1/file3 | 0 tests/spread-filter/source/lib1/lib1 | 0 tests/spread-filter/source/lib1/lib1_test.py | 0 tests/spread-filter/source/lib1/task.yaml | 6 + tests/spread-filter/source/lib2/lib2 | 0 tests/spread-filter/source/lib2/lib2_test.py | 0 .../source/lib2/lib2_test.py.back | 0 tests/spread-filter/task.yaml | 91 +++ tests/spread-filter/tests/core/other/lib1 | 0 tests/spread-filter/tests/core/other/lib2 | 0 .../spread-filter/tests/core/test1/helper.py | 0 .../spread-filter/tests/core/test1/task.yaml | 6 + .../tests/core/test2/otherfile.py | 0 .../spread-filter/tests/core/test2/task.yaml | 6 + tests/spread-filter/tests/lib/lib1.sh | 0 tests/spread-filter/tests/lib/lib2.sh | 0 tests/spread-filter/tests/lib/nested.sh | 0 .../tests/lib/tools/suite/test1/helper.sh | 0 .../tests/lib/tools/suite/test1/task.yaml | 6 + .../tests/lib/tools/suite/test2/snap/bin/sh | 0 .../lib/tools/suite/test2/snap/meta/snap.yaml | 0 .../lib/tools/suite/test2/snap/otherfile | 0 .../tests/lib/tools/suite/test2/task.yaml | 6 + .../spread-filter/tests/main/test1/task.yaml | 6 + .../spread-filter/tests/main/test11/task.yaml | 6 + .../tests/main/test1b/logs/log1.txt | 0 .../tests/main/test1b/logs/log2.txt | 0 .../spread-filter/tests/main/test1b/task.yaml | 6 + .../tests/main/test2/snap/bin/sh | 0 .../tests/main/test2/snap/meta/snap.yaml | 0 .../tests/main/test2/snap/otherfile | 0 .../spread-filter/tests/main/test2/task.yaml | 6 + .../tests/nested/test1/task.yaml | 6 + .../tests/nested/test2/snap/bin/sh | 0 .../tests/nested/test2/snap/meta/snap.yaml | 0 .../tests/nested/test2/snap/otherfile | 0 .../tests/nested/test2/task.yaml | 6 + .../tests/nested/test2/task.yaml.old | 0 tests/spread-manager/checks/task1/task.yaml | 2 + tests/spread-manager/checks/task2/task.yaml | 2 + tests/spread-manager/checks/task3/task.yaml | 2 + tests/spread-manager/checks/task4/task.yaml | 2 + tests/spread-manager/task.yaml | 4 + tests/spread-shellcheck/task.yaml | 6 + tests/tests.backup/task.yaml | 4 + tests/tests.cleanup/task.yaml | 4 + tests/tests.pkgs/task.yaml | 36 +- tests/tests.systemd/task.yaml | 47 +- tools/os.query | 113 ++-- tools/quiet | 32 + tools/snaps.name | 18 +- tools/tests.pkgs | 29 +- tools/tests.pkgs.apt.sh | 55 +- tools/tests.pkgs.dnf-yum.sh | 43 +- tools/tests.pkgs.pacman.sh | 32 +- tools/tests.pkgs.zypper.sh | 31 +- tools/tests.systemd | 97 ++- utils/check-test-format | 32 +- utils/log-analyzer | 6 +- utils/log-filter | 208 +++++++ utils/log-parser | 567 ++++++++---------- utils/log_helper.py | 193 ++++++ utils/spread-filter | 220 +++++++ utils/spread-shellcheck | 36 +- utils/spreadJ | 119 ++++ 124 files changed, 3330 insertions(+), 1075 deletions(-) rename tests/check-test-format/tasks/{task1 => task1.yaml} (83%) rename tests/check-test-format/tasks/{task2 => task2.yaml} (83%) rename tests/check-test-format/tasks/{task3 => task3.yaml} (81%) rename tests/check-test-format/tasks/{task4 => task4.yaml} (80%) rename tests/check-test-format/tasks/{task5 => task5.yaml} (86%) rename tests/check-test-format/tasks/{task6 => task6.yaml} (76%) create mode 100644 tests/log-analyzer/data/with-failed-and-failed-restore-suite.json create mode 100644 tests/log-analyzer/data/with-failed-and-failed-restore-suite.log create mode 100644 tests/log-filter/task.yaml create mode 100644 tests/log-parser/with-debug-output.log.spread create mode 100644 tests/log-parser/with-error-output.log.spread create mode 100644 tests/quiet/task.yaml create mode 100644 tests/spread-filter/HACKING.md create mode 100644 tests/spread-filter/README.md create mode 100644 tests/spread-filter/res create mode 100644 tests/spread-filter/rules.yaml create mode 100644 tests/spread-filter/source/file1 create mode 100644 tests/spread-filter/source/file2 create mode 100644 tests/spread-filter/source/lib1/file3 create mode 100644 tests/spread-filter/source/lib1/lib1 create mode 100644 tests/spread-filter/source/lib1/lib1_test.py create mode 100644 tests/spread-filter/source/lib1/task.yaml create mode 100644 tests/spread-filter/source/lib2/lib2 create mode 100644 tests/spread-filter/source/lib2/lib2_test.py create mode 100644 tests/spread-filter/source/lib2/lib2_test.py.back create mode 100644 tests/spread-filter/task.yaml create mode 100644 tests/spread-filter/tests/core/other/lib1 create mode 100644 tests/spread-filter/tests/core/other/lib2 create mode 100644 tests/spread-filter/tests/core/test1/helper.py create mode 100644 tests/spread-filter/tests/core/test1/task.yaml create mode 100644 tests/spread-filter/tests/core/test2/otherfile.py create mode 100644 tests/spread-filter/tests/core/test2/task.yaml create mode 100644 tests/spread-filter/tests/lib/lib1.sh create mode 100644 tests/spread-filter/tests/lib/lib2.sh create mode 100644 tests/spread-filter/tests/lib/nested.sh create mode 100644 tests/spread-filter/tests/lib/tools/suite/test1/helper.sh create mode 100644 tests/spread-filter/tests/lib/tools/suite/test1/task.yaml create mode 100644 tests/spread-filter/tests/lib/tools/suite/test2/snap/bin/sh create mode 100644 tests/spread-filter/tests/lib/tools/suite/test2/snap/meta/snap.yaml create mode 100644 tests/spread-filter/tests/lib/tools/suite/test2/snap/otherfile create mode 100644 tests/spread-filter/tests/lib/tools/suite/test2/task.yaml create mode 100644 tests/spread-filter/tests/main/test1/task.yaml create mode 100644 tests/spread-filter/tests/main/test11/task.yaml create mode 100644 tests/spread-filter/tests/main/test1b/logs/log1.txt create mode 100644 tests/spread-filter/tests/main/test1b/logs/log2.txt create mode 100644 tests/spread-filter/tests/main/test1b/task.yaml create mode 100644 tests/spread-filter/tests/main/test2/snap/bin/sh create mode 100644 tests/spread-filter/tests/main/test2/snap/meta/snap.yaml create mode 100644 tests/spread-filter/tests/main/test2/snap/otherfile create mode 100644 tests/spread-filter/tests/main/test2/task.yaml create mode 100644 tests/spread-filter/tests/nested/test1/task.yaml create mode 100644 tests/spread-filter/tests/nested/test2/snap/bin/sh create mode 100644 tests/spread-filter/tests/nested/test2/snap/meta/snap.yaml create mode 100644 tests/spread-filter/tests/nested/test2/snap/otherfile create mode 100644 tests/spread-filter/tests/nested/test2/task.yaml create mode 100644 tests/spread-filter/tests/nested/test2/task.yaml.old create mode 100755 tools/quiet create mode 100755 utils/log-filter create mode 100644 utils/log_helper.py create mode 100755 utils/spread-filter create mode 100755 utils/spreadJ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3687b00003f..a1b8be7cd10 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -34,11 +34,98 @@ jobs: test: needs: [unit-tests] - runs-on: self-hosted + runs-on: [self-hosted, spread-enabled] steps: - name: Checkout code uses: actions/checkout@v2 + - name: Get previous attempt + id: get-previous-attempt + run: | + echo "previous_attempt=$(( ${{ github.run_attempt }} - 1 ))" >> $GITHUB_OUTPUT + shell: bash + + - name: Get previous cache + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.test-results" + key: "${{ github.job }}-results-${{ github.run_id }}-${{ steps.get-previous-attempt.outputs.previous_attempt }}" + + - name: Prepare test results env and vars + id: prepare-test-results-env + run: | + # Create test results directories and save vars + TEST_RESULTS_DIR="${{ github.workspace }}/.test-results" + echo "TEST_RESULTS_DIR=$TEST_RESULTS_DIR" >> $GITHUB_ENV + + # Save the var with the failed tests file + echo "FAILED_TESTS_FILE=$TEST_RESULTS_DIR/failed-tests" >> $GITHUB_ENV + + # Make sure the test results dirs are created + # This step has to be after the cache is restored + mkdir -p "$TEST_RESULTS_DIR" + + - name: Check failed tests to run + if: "!contains(github.event.pull_request.labels.*.name, 'Run all')" + run: | + # Save previous failed test results in FAILED_TESTS env var + FAILED_TESTS="" + if [ -f "$FAILED_TESTS_FILE" ]; then + echo "Failed tests file found" + FAILED_TESTS="$(cat $FAILED_TESTS_FILE)" + if [ -n "$FAILED_TESTS" ]; then + echo "Failed tests to run: $FAILED_TESTS" + echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV + fi + fi + - name: Run test run: | - spread google:tests/ google-nested:tests/ + RUN_TESTS="google:tests/ google-nested:tests/ openstack:tests/" + if [ -n "$FAILED_TESTS" ]; then + RUN_TESTS="$FAILED_TESTS" + fi + CHANGE_ID="${{ github.event.number }}" + if [ -z "$PR_ID" ]; then + CHANGE_ID="main" + fi + CHANGE_ID="${CHANGE_ID}_n${{ github.run_attempt }}" + # The log-filter tool is used to filter the spread logs to be stored + FILTER_PARAMS="-o spread_$CHANGE_ID.filtered.log -e Debug -e WARNING: -f Failed=NO_LINES -f Error=NO_LINES" + + (set -o pipefail; spread $RUN_TESTS | ./utils/log-filter $FILTER_PARAMS | tee spread.log) + + - name: Discard spread workers + if: always() + run: | + shopt -s nullglob; + for r in .spread-reuse.*.yaml; do + spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')"; + done + + - name: analyze spread test results + if: always() + run: | + if [ -f spread.log ]; then + echo "Running spread log parser" + ./utils/log-parser spread.log --output spread-results.json + + echo "Determining which tests were executed" + RUN_TESTS="google:tests/ google-nested:tests/" + if [ -n "$FAILED_TESTS" ]; then + RUN_TESTS="$FAILED_TESTS" + fi + + echo "Running spread log analyzer" + ./utils/log-analyzer list-reexecute-tasks "$RUN_TESTS" spread-results.json > "$FAILED_TESTS_FILE" + else + echo "No spread log found, saving empty list of failed tests" + touch "$FAILED_TESTS_FILE" + fi + + - name: save spread test results to cache + if: always() + uses: actions/cache/save@v3 + with: + path: "${{ github.workspace }}/.test-results" + key: "${{ github.job }}-results-${{ github.run_id }}-${{ github.run_attempt }}" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index eae850e8749..e8d83b7b9d1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal +level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards diff --git a/remote/remote.pull b/remote/remote.pull index 75e006913c1..544b373c262 100755 --- a/remote/remote.pull +++ b/remote/remote.pull @@ -1,7 +1,7 @@ #!/bin/bash -e show_help() { - echo "usage: remote.pull " + echo "usage: remote.pull [LOCAL_PATH]" echo "" echo "Available options:" echo " -h --help show this help message." @@ -34,18 +34,24 @@ _get_cert() { } remote_pull() { - local REMOTE_PATH=$1 - local LOCAL_PATH=$2 - if [ -z "$LOCAL_PATH" ] || [ -z "$REMOTE_PATH" ]; then - echo "remote.pull: local and remote paths are required" + local REMOTE_PATH="$1" + local LOCAL_PATH="${2:-.}" + if [ -z "$REMOTE_PATH" ]; then + echo "remote.pull: remote path is required" fi local SSH_PASS SSH_CERT SSH_PASS="$(_get_pass)" SSH_CERT="$(_get_cert)" + LEGACY_PARAM="-O" + # We check if -O option is supported by scp + if scp -O 2>&1 | grep -q "unknown option"; then + LEGACY_PARAM="" + fi + # shellcheck disable=SC2153,SC2086 - $SSH_PASS scp $SSH_CERT -P "$TESTS_REMOTE_PORT" -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$TESTS_REMOTE_USER"@"$TESTS_REMOTE_HOST":"$1" "$2" + $SSH_PASS scp $SSH_CERT $LEGACY_PARAM -P "$TESTS_REMOTE_PORT" -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$TESTS_REMOTE_USER"@"$TESTS_REMOTE_HOST":"$REMOTE_PATH" "$LOCAL_PATH" } main() { diff --git a/remote/remote.push b/remote/remote.push index 3bd1c32146b..095be0c5590 100755 --- a/remote/remote.push +++ b/remote/remote.push @@ -1,7 +1,7 @@ #!/bin/bash -e show_help() { - echo "usage: remote.push " + echo "usage: remote.push [REMOTE_PATH]" echo "" echo "Available options:" echo " -h --help show this help message." @@ -34,10 +34,10 @@ _get_cert() { } remote_push() { - local LOCAL_PATH=$1 - local REMOTE_PATH=$2 - if [ -z "$LOCAL_PATH" ] || [ -z "$REMOTE_PATH" ]; then - echo "remote.push: local and remote paths are required" + local LOCAL_PATH="$1" + local REMOTE_PATH="${2:-}" + if [ -z "$LOCAL_PATH" ]; then + echo "remote.push: local path is required" fi local SSH_PASS SSH_CERT @@ -45,7 +45,7 @@ remote_push() { SSH_CERT="$(_get_cert)" # shellcheck disable=SC2153,SC2086 - $SSH_PASS scp $SSH_CERT -P "$TESTS_REMOTE_PORT" -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$1" "$TESTS_REMOTE_USER"@"$TESTS_REMOTE_HOST":"$2" + $SSH_PASS scp $SSH_CERT -P "$TESTS_REMOTE_PORT" -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$LOCAL_PATH" "$TESTS_REMOTE_USER"@"$TESTS_REMOTE_HOST":"$REMOTE_PATH" } main() { diff --git a/remote/remote.refresh b/remote/remote.refresh index 67278d42794..95aa0739cc6 100755 --- a/remote/remote.refresh +++ b/remote/remote.refresh @@ -2,8 +2,8 @@ show_help() { echo "usage: remote.refresh snap [--channel CHANNEL] " - echo "usage: remote.refresh full [--channel CHANNEL]" - echo "usage: remote.refresh disable-refreshes" + echo " remote.refresh full [--channel CHANNEL]" + echo " remote.refresh disable-refreshes" echo "" echo "SNAPNAME: allowed options are: kernel, core, base, gadget, snapd or the snap name" echo "" diff --git a/remote/remote.setup b/remote/remote.setup index 35e0ea694cd..89d47d04024 100755 --- a/remote/remote.setup +++ b/remote/remote.setup @@ -4,7 +4,7 @@ CFG_FILE="${REMOTE_CFG_FILE:-$(pwd)/remote.setup.cfg}" show_help() { echo "usage: remote.setup config --host --port --user [--pass ] [--cert ]" - echo "usage: remote.setup get-config-path" + echo " remote.setup get-config-path" echo "" echo "Available options:" echo " -h --help show this help message." diff --git a/remote/remote.wait-for b/remote/remote.wait-for index 3013568e7e2..a16179d8b1b 100755 --- a/remote/remote.wait-for +++ b/remote/remote.wait-for @@ -1,5 +1,7 @@ #!/bin/bash -e +# The default values have been selected trying to match with most of +# the wait times in the tests and also trying to follow common sense. DEFAULT_WAIT_FOR_SSH_ATTEMPTS=800 DEFAULT_WAIT_FOR_SSH_WAIT=1 DEFAULT_WAIT_FOR_NO_SSH_ATTEMPTS=200 @@ -150,34 +152,82 @@ wait_for_device_initialized() { echo "remote.wait-for: device initialized" } +wait_for_refresh_reboot() { + echo "remote.wait-for: waiting for refresh reboot" + + local change_id=${1:-} + local boot_id=${2:-} + if [ -z "$change_id" ] || [ -z "$boot_id" ]; then + echo "remote.wait-for: either change_id or boot_id not provided" + return 1 + fi + + wait_for_ssh "$DEFAULT_WAIT_FOR_SSH_ATTEMPTS" "$DEFAULT_WAIT_FOR_SSH_WAIT" + for _ in $(seq 5); do + # The refresh is being executed + # It checks a that refresh is in state either Do or Doing (and not Done) + if remote.exec "snap changes" | grep -Eq "$change_id.*( Do | Doing ).*(Auto-refresh|Refresh)"; then + # The systems is waiting for reboot + if remote.exec "sudo journalctl -u snapd -n 30" | grep -q "Waiting for system reboot"; then + echo "remote.wait-for: waiting for system reboot" + remote.exec "sudo reboot" || true + wait_for_no_ssh "$DEFAULT_WAIT_FOR_NO_SSH_ATTEMPTS" "$DEFAULT_WAIT_FOR_NO_SSH_WAIT" + break + fi + echo "remote.wait-for: either auto-refresh or refresh in progress" + fi + + # when the refresh has finished and no reboot needed, the function returns + if remote.exec "snap changes" | grep -Eq "$change_id.*Done.*(Auto-refresh|Refresh)"; then + echo "remote.wait-for: refresh completed, reboot not required" + return + fi + + if remote.exec "snap changes" | grep -Eq "$change_id.*Error.*(Auto-refresh|Refresh)"; then + echo "remote.wait-for: refresh finished with error" + return 1 + fi + + echo "remote.wait-for: system reboot not detected" + sleep 1 + done + wait_for_ssh "$DEFAULT_WAIT_FOR_SSH_ATTEMPTS" "$DEFAULT_WAIT_FOR_SSH_WAIT" + if [ "$(remote.exec "cat /proc/sys/kernel/random/boot_id")" == "$boot_id" ]; then + echo "remote.wait-for: boot id did not change" + return 1 + else + echo "remote.wait-for: boot id changed, refresh completed with reboot" + fi +} + wait_for_refresh(){ echo "remote.wait-for: waiting for either auto-refresh or refresh" - change_line="$(remote.exec 'snap changes' | grep -E 'Doing.*(Auto-refresh|Refresh)' || true)" + # It checks a that refresh is in state either Do or Doing (and not Done) + change_line="$(remote.exec 'snap changes' | grep -E '( Do | Doing ).*(Auto-refresh|Refresh)' || true)" if [ -n "$change_line" ]; then - echo "remote.wait-for: Refresh in progress" + echo "remote.wait-for: refresh in progress" change_id="$(echo "$change_line" | awk '{ print $1 }')" + boot_id="$(remote.exec "cat /proc/sys/kernel/random/boot_id")" - while remote.exec "snap changes" | grep -Eq "$change_id.*Doing.*(Auto-refresh|Refresh)"; do - echo -n '.' - if remote.exec "true" &>/dev/null; then - sleep 1 + for _ in $(seq 20); do + if wait_for_refresh_reboot "$change_id" "$boot_id"; then + break fi done echo "" - if ! remote.exec "true" &>/dev/null; then - wait_for_ssh "$DEFAULT_WAIT_FOR_SSH_ATTEMPTS" "$DEFAULT_WAIT_FOR_SSH_WAIT" - fi - - if remote.exec "snap changes" | grep -Eq "$change_id.*Doing.*(Auto-refresh|Refresh)"; then + changes="$(remote.exec 'snap changes')" + # It checks a that refresh is in state either Do or Doing (and not Done) + if echo "$changes" | grep -Eq "$change_id.*( Do | Doing ).*(Auto-refresh|Refresh)"; then echo "remote.wait-for: still doing refresh, exiting" - elif remote.exec "snap changes" | grep -Eq "$change_id.*Error.*(Auto-refresh|Refresh)"; then + elif echo "$changes" | grep -Eq "$change_id.*Error.*(Auto-refresh|Refresh)"; then echo "remote.wait-for: refresh failed" - elif remote.exec "snap changes" | grep -Eq "$change_id.*Done.*(Auto-refresh|Refresh)"; then + elif echo "$changes" | grep -Eq "$change_id.*Done.*(Auto-refresh|Refresh)"; then echo "remote.wait-for: refresh completed" else echo "remote.wait-for: refresh results unknown" + echo "$changes" return 1 fi else diff --git a/spread.yaml b/spread.yaml index fd85be01b13..9282cc06ed4 100644 --- a/spread.yaml +++ b/spread.yaml @@ -2,7 +2,7 @@ project: snapd-testing-tools environment: PROJECT_PATH: /root/snapd-testing-tools - PATH: $PATH:$PROJECT_PATH/tools:$PROJECT_PATH/utils:$PROJECT_PATH/remote + PATH: $PROJECT_PATH/tools:$PROJECT_PATH/utils:$PROJECT_PATH/remote:$PATH backends: google: @@ -16,23 +16,20 @@ backends: - ubuntu-18.04-64: - ubuntu-20.04-64: - ubuntu-22.04-64: - - ubuntu-22.10-64: - - debian-10-64: + - ubuntu-24.04-64: - debian-11-64: - - debian-sid-64: - - fedora-35-64: - - fedora-36-64: + - debian-12-64: + - debian-sid-64: + - fedora-39-64: - arch-linux-64: - amazon-linux-2-64: storage: preserve-size - - centos-7-64: - storage: preserve-size - - centos-8-64: + - amazon-linux-2023-64: storage: preserve-size - centos-9-64: storage: preserve-size - - opensuse-15.3-64: - - opensuse-15.4-64: + - opensuse-15.5-64: + - opensuse-15.6-64: - opensuse-tumbleweed-64: google-nested: @@ -46,7 +43,29 @@ backends: - ubuntu-20.04-64: image: ubuntu-2004-64-virt-enabled storage: 20G - workers: 1 + + openstack: + key: '$(HOST: echo "$SPREAD_OPENSTACK_ENV")' + plan: staging-cpu2-ram4-disk50 + halt-timeout: 2h + groups: [default] + environment: + HTTP_PROXY: 'http://squid.internal:3128' + HTTPS_PROXY: 'http://squid.internal:3128' + NO_PROXY: 'canonical.com' + systems: + - ubuntu-22.04-64: + image: snapd-spread/ubuntu-22.04-64 + - ubuntu-24.04-64: + image: snapd-spread/ubuntu-24.04-64 + - fedora-40-64: + image: snapd-spread/fedora-40-64 + - opensuse-15.5-64: + image: snapd-spread/opensuse-15.5-64 + - centos-9-64: + image: snapd-spread/centos-9-64 + - debian-12-64: + image: snapd-spread/debian-12-64 path: /root/snapd-testing-tools @@ -62,7 +81,7 @@ restore: | suites: tests/: - summary: Main test suite for snapd-testing-tools + summary: Main test suite for snapd-testing-tools project prepare: | echo "Preparing snapd-testing-tools main suite" # Create users for the tests diff --git a/tests/check-test-format/task.yaml b/tests/check-test-format/task.yaml index 0fc9b63a737..c421e818359 100644 --- a/tests/check-test-format/task.yaml +++ b/tests/check-test-format/task.yaml @@ -1,5 +1,9 @@ summary: smoke test for the spread checker tool +details: | + Verify that the check-test-format tool checks properly the desired + order and mandatory keys in spread tasks. + backends: [google] systems: [ ubuntu-20.04-64 ] @@ -13,33 +17,30 @@ restore: | execute: | check-test-format -h | MATCH "usage: check-test-format" - # Check the format of the spread tests in this project - check-test-format "$PROJECT_PATH/tests" + # Check failing tasks with order not desired + check-test-format --tests "$PWD/tasks/task1.yaml" 2>&1 | MATCH "Keys 'execute' and 'prepare' do not follow the desired order" - # Check failing tasks - cp "$PWD/tasks/task1" "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Keys 'execute' and 'prepare' do not follow the desired order" - rm "$PWD/tasks/task.yaml" + check-test-format --tests "$PWD/tasks/task2.yaml" 2>&1 | MATCH "Keys 'execute' and 'restore' do not follow the desired order" - cp "$PWD/tasks/task2" "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Keys 'execute' and 'restore' do not follow the desired order" - rm "$PWD/tasks/task.yaml" + check-test-format --tests "$PWD/tasks/task3.yaml" 2>&1 | MATCH "Keys 'systems' and 'backends' do not follow the desired order" + check-test-format --tests "$PWD/tasks/task3.yaml" 2>&1 | MATCH "Key 'execute' is mandatory" - cp "$PWD/tasks/task3" "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Keys 'systems' and 'backends' do not follow the desired order" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Key 'execute' is mandatory" - rm "$PWD/tasks/task.yaml" + # Check passing a file with more than 1 error + check-test-format --tests "$PWD/tasks/task4.yaml" 2>&1 | MATCH "Keys 'environment' and 'systems' do not follow the desired order" + check-test-format --tests "$PWD/tasks/task4.yaml" 2>&1 | MATCH "Key 'details' is mandatory" - cp "$PWD/tasks/task4" "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Keys 'environment' and 'systems' do not follow the desired order" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Key 'execute' is mandatory" - rm "$PWD/tasks/task.yaml" + # Check passing a file with a non supported section + check-test-format --tests "$PWD/tasks/task5.yaml" 2>&1 | MATCH "key 'unsupported' is not among the supported keys" - cp "$PWD/tasks/task5" "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "key 'unsupported' is not among the supported keys" - rm "$PWD/tasks/task.yaml" + # Check passing more than 1 file to the tool + check-test-format --tests "$PWD/tasks/task4.yaml" "$PWD/tasks/task5.yaml" 2>&1 | MATCH "Key 'details' is mandatory" + check-test-format --tests "$PWD/tasks/task4.yaml" "$PWD/tasks/task5.yaml" 2>&1 | MATCH "key 'unsupported' is not among the supported keys" - cp "$PWD/tasks/task6" "$PWD/tasks/task.yaml" + # Check passing a file with a non supported format + # Check passing a dir + cp "$PWD/tasks/task6.yaml" "$PWD/tasks/task.yaml" echo "newtext" >> "$PWD/tasks/task.yaml" - check-test-format "$PWD/tasks" 2>&1 | MATCH "Invalid task format, checks failed for task" + check-test-format --tests "$PWD/tasks/task.yaml" 2>&1 | MATCH "Invalid task format, checks failed for task" + check-test-format --dir "$PWD/tasks/" 2>&1 | MATCH "Invalid task format, checks failed for task" + check-test-format --dir "$PWD/tasks/" 2>&1 | NOMATCH "Key 'execute' is mandatory" rm "$PWD/tasks/task.yaml" diff --git a/tests/check-test-format/tasks/task1 b/tests/check-test-format/tasks/task1.yaml similarity index 83% rename from tests/check-test-format/tasks/task1 rename to tests/check-test-format/tasks/task1.yaml index fd2d85fc00a..90ecfe6cbab 100644 --- a/tests/check-test-format/tasks/task1 +++ b/tests/check-test-format/tasks/task1.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: details + execute: | echo "execute" diff --git a/tests/check-test-format/tasks/task2 b/tests/check-test-format/tasks/task2.yaml similarity index 83% rename from tests/check-test-format/tasks/task2 rename to tests/check-test-format/tasks/task2.yaml index 18b21724c88..9e02ee75128 100644 --- a/tests/check-test-format/tasks/task2 +++ b/tests/check-test-format/tasks/task2.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: details + execute: | echo "execute" diff --git a/tests/check-test-format/tasks/task3 b/tests/check-test-format/tasks/task3.yaml similarity index 81% rename from tests/check-test-format/tasks/task3 rename to tests/check-test-format/tasks/task3.yaml index 4ce4fbd7d8b..55989a175d4 100644 --- a/tests/check-test-format/tasks/task3 +++ b/tests/check-test-format/tasks/task3.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: details + systems: [ ubuntu-20.04-64 ] backends: [ google ] diff --git a/tests/check-test-format/tasks/task4 b/tests/check-test-format/tasks/task4.yaml similarity index 80% rename from tests/check-test-format/tasks/task4 rename to tests/check-test-format/tasks/task4.yaml index 2a3e036ecba..c712c79f503 100644 --- a/tests/check-test-format/tasks/task4 +++ b/tests/check-test-format/tasks/task4.yaml @@ -1,7 +1,5 @@ summary: this is the summary -details: no details - environment: TEST: 1 diff --git a/tests/check-test-format/tasks/task5 b/tests/check-test-format/tasks/task5.yaml similarity index 86% rename from tests/check-test-format/tasks/task5 rename to tests/check-test-format/tasks/task5.yaml index e619daaf85a..ff45b068c14 100644 --- a/tests/check-test-format/tasks/task5 +++ b/tests/check-test-format/tasks/task5.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: details + unsupported: not supported systems: [ ubuntu-20.04-64 ] diff --git a/tests/check-test-format/tasks/task6 b/tests/check-test-format/tasks/task6.yaml similarity index 76% rename from tests/check-test-format/tasks/task6 rename to tests/check-test-format/tasks/task6.yaml index 0a189d15de0..e42a4092a1a 100644 --- a/tests/check-test-format/tasks/task6 +++ b/tests/check-test-format/tasks/task6.yaml @@ -1,4 +1,6 @@ summary: this is the summary +details: details + execute: | echo "execute" diff --git a/tests/log-analyzer/data/aborted-and-failed-execute-and-restore.json b/tests/log-analyzer/data/aborted-and-failed-execute-and-restore.json index 258d7bd218c..bba7f98d2cc 100644 --- a/tests/log-analyzer/data/aborted-and-failed-execute-and-restore.json +++ b/tests/log-analyzer/data/aborted-and-failed-execute-and-restore.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:06", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:06", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:15", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-20.04-64 (may242137-942824) to boot at 34.75.199.115..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:20", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-22.04-64 (may242137-942720) to boot at 34.75.71.82..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:57", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242137-942720)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:57", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242137-942720)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:58", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242137-942720) at 34.75.71.82." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:37:58", "verb": "Sending", @@ -64,14 +64,14 @@ "extra": "project content to google:ubuntu-22.04-64 (may242137-942720)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:02", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:02", "verb": "Allocated", @@ -79,7 +79,7 @@ "extra": "google:ubuntu-20.04-64 (may242137-942824)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:02", "verb": "Connecting", @@ -87,21 +87,21 @@ "extra": "to google:ubuntu-20.04-64 (may242137-942824)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:02", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:03", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:04", "verb": "Connected", @@ -109,7 +109,7 @@ "extra": "to google:ubuntu-20.04-64 (may242137-942824) at 34.75.199.115." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:04", "verb": "Sending", @@ -117,28 +117,28 @@ "extra": "project content to google:ubuntu-20.04-64 (may242137-942824)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:04", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:04", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:05", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:05", "verb": "Executing", @@ -164,14 +164,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:06", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:06", "verb": "Preparing", @@ -197,35 +197,35 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:06", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:07", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:07", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:07", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:07", "verb": "Discarding", @@ -233,91 +233,91 @@ "extra": "google:ubuntu-22.04-64 (may242137-942720)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:08", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:08", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:09", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:09", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:10", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:10", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:11", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:11", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:12", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:12", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:13", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:13", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:14", "verb": "Executing", @@ -343,7 +343,7 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:14", "verb": "Restoring", @@ -369,21 +369,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:15", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:38:15", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:38:16", "verb": "Discarding", diff --git a/tests/log-analyzer/data/all-aborted.json b/tests/log-analyzer/data/all-aborted.json index 6e2424bf22d..75d79549df9 100644 --- a/tests/log-analyzer/data/all-aborted.json +++ b/tests/log-analyzer/data/all-aborted.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:06:40", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:06:40", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:06:49", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-22.04-64 (may242106-435572) to boot at 34.148.101.55..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:06:50", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242106-435744) to boot at 34.148.4.171..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:30", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242106-435572)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:30", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242106-435572)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:32", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242106-435572) at 34.148.101.55." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:32", "verb": "Sending", @@ -64,7 +64,7 @@ "extra": "project content to google:ubuntu-22.04-64 (may242106-435572)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:07:36", "verb": "Preparing", @@ -90,14 +90,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:07:37", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:37", "verb": "Discarding", @@ -105,7 +105,7 @@ "extra": "google:ubuntu-22.04-64 (may242106-435572)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:41", "verb": "Allocated", @@ -113,7 +113,7 @@ "extra": "google:ubuntu-20.04-64 (may242106-435744)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:41", "verb": "Connecting", @@ -121,7 +121,7 @@ "extra": "to google:ubuntu-20.04-64 (may242106-435744)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:42", "verb": "Connected", @@ -129,7 +129,7 @@ "extra": "to google:ubuntu-20.04-64 (may242106-435744) at 34.148.4.171." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:42", "verb": "Sending", @@ -137,7 +137,7 @@ "extra": "project content to google:ubuntu-20.04-64 (may242106-435744)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:07:46", "verb": "Preparing", @@ -163,14 +163,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:07:47", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:07:47", "verb": "Discarding", diff --git a/tests/log-analyzer/data/all-failed.json b/tests/log-analyzer/data/all-failed.json index dea8ba7a855..705011ad771 100644 --- a/tests/log-analyzer/data/all-failed.json +++ b/tests/log-analyzer/data/all-failed.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:52:29", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:52:29", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:52:39", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-20.04-64 (may242052-202754) to boot at 34.139.205.254..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:52:43", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-22.04-64 (may242052-202652) to boot at 104.196.209.131..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:24", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242052-202652)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:24", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242052-202652)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:25", "verb": "Allocated", @@ -56,7 +56,7 @@ "extra": "google:ubuntu-20.04-64 (may242052-202754)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:25", "verb": "Connecting", @@ -64,7 +64,7 @@ "extra": "to google:ubuntu-20.04-64 (may242052-202754)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:26", "verb": "Connected", @@ -72,7 +72,7 @@ "extra": "to google:ubuntu-22.04-64 (may242052-202652) at 104.196.209.131." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:26", "verb": "Sending", @@ -80,7 +80,7 @@ "extra": "project content to google:ubuntu-22.04-64 (may242052-202652)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:26", "verb": "Connected", @@ -88,7 +88,7 @@ "extra": "to google:ubuntu-20.04-64 (may242052-202754) at 34.139.205.254." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:26", "verb": "Sending", @@ -96,49 +96,49 @@ "extra": "project content to google:ubuntu-20.04-64 (may242052-202754)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:28", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:29", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:29", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:29", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:30", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:30", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:30", "verb": "Preparing", @@ -164,14 +164,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:31", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:31", "verb": "Executing", @@ -197,35 +197,35 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:31", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:31", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:32", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:32", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:32", "verb": "Executing", @@ -251,7 +251,7 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:33", "verb": "Restoring", @@ -277,35 +277,35 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:33", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:33", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:33", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:34", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:34", "verb": "Executing", @@ -331,7 +331,7 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:34", "verb": "Restoring", @@ -357,28 +357,28 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:35", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:35", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:35", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:35", "verb": "Preparing", @@ -404,21 +404,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:36", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:36", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:36", "verb": "Preparing", @@ -444,21 +444,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:36", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:37", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:37", "verb": "Preparing", @@ -484,28 +484,28 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:37", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:38", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:38", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:38", "verb": "Restoring", @@ -531,14 +531,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:38", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:39", "verb": "Discarding", @@ -546,21 +546,21 @@ "extra": "google:ubuntu-20.04-64 (may242052-202754)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:39", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:53:40", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:53:41", "verb": "Discarding", diff --git a/tests/log-analyzer/data/all-success-failed-restore.json b/tests/log-analyzer/data/all-success-failed-restore.json index 48bd65cb9e0..f3b10547ef7 100644 --- a/tests/log-analyzer/data/all-success-failed-restore.json +++ b/tests/log-analyzer/data/all-success-failed-restore.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:42:58", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:42:58", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:07", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-22.04-64 (may242043-312411) to boot at 34.148.59.204..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:07", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242043-312500) to boot at 34.138.215.109..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:43", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242043-312411)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:43", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242043-312411)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:45", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242043-312411) at 34.148.59.204." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:43:45", "verb": "Sending", @@ -64,133 +64,133 @@ "extra": "project content to google:ubuntu-22.04-64 (may242043-312411)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:50", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:50", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:51", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:52", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:52", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:53", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:54", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:55", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:55", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:56", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:56", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:57", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:58", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:58", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:43:59", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:00", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:00", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:01", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:02", "verb": "Restoring", @@ -216,7 +216,7 @@ } }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:02", "verb": "Discarding", @@ -224,7 +224,7 @@ "extra": "google:ubuntu-22.04-64 (may242043-312411)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:04", "verb": "Allocated", @@ -232,7 +232,7 @@ "extra": "google:ubuntu-20.04-64 (may242043-312500)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:04", "verb": "Connecting", @@ -240,7 +240,7 @@ "extra": "to google:ubuntu-20.04-64 (may242043-312500)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:05", "verb": "Connected", @@ -248,7 +248,7 @@ "extra": "to google:ubuntu-20.04-64 (may242043-312500) at 34.138.215.109." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:05", "verb": "Sending", @@ -256,133 +256,133 @@ "extra": "project content to google:ubuntu-20.04-64 (may242043-312500)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:08", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:08", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:09", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:09", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:10", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:10", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:11", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:11", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:12", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:13", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:13", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:14", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:14", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:15", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:15", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:16", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:16", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:17", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:44:17", "verb": "Restoring", @@ -408,7 +408,7 @@ } }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:44:18", "verb": "Discarding", diff --git a/tests/log-analyzer/data/all-success.json b/tests/log-analyzer/data/all-success.json index 962875f414d..b3560db03df 100644 --- a/tests/log-analyzer/data/all-success.json +++ b/tests/log-analyzer/data/all-success.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:45:05", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:45:05", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:45:14", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-22.04-64 (may242045-878680) to boot at 35.237.221.225..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:45:15", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242045-878764) to boot at 34.148.94.157..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:00", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242045-878680)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:00", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242045-878680)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:02", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242045-878680) at 35.237.221.225." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:02", "verb": "Sending", @@ -64,77 +64,77 @@ "extra": "project content to google:ubuntu-22.04-64 (may242045-878680)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:06", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:06", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:07", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:08", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:08", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:09", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:09", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:10", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:10", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:11", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:11", "verb": "Allocated", @@ -142,7 +142,7 @@ "extra": "google:ubuntu-20.04-64 (may242045-878764)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:11", "verb": "Connecting", @@ -150,21 +150,21 @@ "extra": "to google:ubuntu-20.04-64 (may242045-878764)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:11", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:12", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:12", "verb": "Connected", @@ -172,7 +172,7 @@ "extra": "to google:ubuntu-20.04-64 (may242045-878764) at 34.148.94.157." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:12", "verb": "Sending", @@ -180,63 +180,63 @@ "extra": "project content to google:ubuntu-20.04-64 (may242045-878764)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:12", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:13", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:13", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:14", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:14", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:15", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:15", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:15", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:16", "verb": "Discarding", @@ -244,133 +244,133 @@ "extra": "google:ubuntu-22.04-64 (may242045-878680)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:16", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:17", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:17", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:18", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:19", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:19", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:20", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:20", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:21", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:22", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:22", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:23", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:24", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:24", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:25", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:25", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:26", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:46:27", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:46:27", "verb": "Discarding", diff --git a/tests/log-analyzer/data/failed-prepare-and-restore.json b/tests/log-analyzer/data/failed-prepare-and-restore.json index 57fba41b389..ff09ea561aa 100644 --- a/tests/log-analyzer/data/failed-prepare-and-restore.json +++ b/tests/log-analyzer/data/failed-prepare-and-restore.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:26", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:26", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:26", "verb": "Allocating", @@ -24,7 +24,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:36", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242056-644336) to boot at 35.185.37.159..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:41", "verb": "Waiting", @@ -40,7 +40,7 @@ "extra": "for google:ubuntu-22.04-64 (may242056-644230) to boot at 34.75.94.174..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:56:42", "verb": "Waiting", @@ -48,7 +48,7 @@ "extra": "for google:ubuntu-20.04-64 (may242056-644428) to boot at 34.138.43.204..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:17", "verb": "Allocated", @@ -56,7 +56,7 @@ "extra": "google:ubuntu-22.04-64 (may242056-644230)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:17", "verb": "Connecting", @@ -64,7 +64,7 @@ "extra": "to google:ubuntu-22.04-64 (may242056-644230)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:19", "verb": "Connected", @@ -72,7 +72,7 @@ "extra": "to google:ubuntu-22.04-64 (may242056-644230) at 34.75.94.174." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:19", "verb": "Sending", @@ -80,7 +80,7 @@ "extra": "project content to google:ubuntu-22.04-64 (may242056-644230)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:22", "verb": "Allocated", @@ -88,7 +88,7 @@ "extra": "google:ubuntu-20.04-64 (may242056-644336)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:22", "verb": "Connecting", @@ -96,14 +96,14 @@ "extra": "to google:ubuntu-20.04-64 (may242056-644336)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:23", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:24", "verb": "Allocated", @@ -111,7 +111,7 @@ "extra": "google:ubuntu-20.04-64 (may242056-644428)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:24", "verb": "Connecting", @@ -119,7 +119,7 @@ "extra": "to google:ubuntu-20.04-64 (may242056-644428)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:24", "verb": "Connected", @@ -127,7 +127,7 @@ "extra": "to google:ubuntu-20.04-64 (may242056-644336) at 35.185.37.159." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:24", "verb": "Sending", @@ -135,21 +135,21 @@ "extra": "project content to google:ubuntu-20.04-64 (may242056-644336)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:24", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:25", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:25", "verb": "Connected", @@ -157,7 +157,7 @@ "extra": "to google:ubuntu-20.04-64 (may242056-644428) at 34.138.43.204." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:25", "verb": "Sending", @@ -165,42 +165,42 @@ "extra": "project content to google:ubuntu-20.04-64 (may242056-644428)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:26", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:26", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:27", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:27", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:27", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:28", "verb": "Preparing", @@ -226,21 +226,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:28", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:28", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:28", "verb": "Preparing", @@ -266,49 +266,49 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:28", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:29", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:29", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:29", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:29", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:29", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:29", "verb": "Discarding", @@ -316,42 +316,42 @@ "extra": "google:ubuntu-22.04-64 (may242056-644230)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:30", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:30", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:30", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:30", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:31", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:31", "verb": "Preparing", @@ -377,14 +377,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:31", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:32", "verb": "Executing", @@ -410,42 +410,42 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:32", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:32", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:33", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:33", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:57:33", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:34", "verb": "Discarding", @@ -453,7 +453,7 @@ "extra": "google:ubuntu-20.04-64 (may242056-644336)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:57:34", "verb": "Discarding", diff --git a/tests/log-analyzer/data/failed-prepare-project.json b/tests/log-analyzer/data/failed-prepare-project.json index 3a443963725..ed7da17ea32 100644 --- a/tests/log-analyzer/data/failed-prepare-project.json +++ b/tests/log-analyzer/data/failed-prepare-project.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:04:51", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:04:51", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:00", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-22.04-64 (may242104-523536) to boot at 34.148.146.189..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:05", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242104-523644) to boot at 35.185.103.64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:42", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242104-523536)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:42", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242104-523536)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:43", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242104-523536) at 34.148.146.189." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:43", "verb": "Sending", @@ -64,140 +64,140 @@ "extra": "project content to google:ubuntu-22.04-64 (may242104-523536)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:47", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:48", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:48", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:49", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:49", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:50", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:50", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:50", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:51", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:52", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:52", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:53", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:53", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:54", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:54", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:55", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:55", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:56", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:05:56", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:57", "verb": "Allocated", @@ -205,7 +205,7 @@ "extra": "google:ubuntu-20.04-64 (may242104-523644)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:57", "verb": "Connecting", @@ -213,7 +213,7 @@ "extra": "to google:ubuntu-20.04-64 (may242104-523644)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:57", "verb": "Discarding", @@ -221,7 +221,7 @@ "extra": "google:ubuntu-22.04-64 (may242104-523536)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:58", "verb": "Connected", @@ -229,7 +229,7 @@ "extra": "to google:ubuntu-20.04-64 (may242104-523644) at 35.185.103.64." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:05:58", "verb": "Sending", @@ -237,7 +237,7 @@ "extra": "project content to google:ubuntu-20.04-64 (may242104-523644)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:06:01", "verb": "Preparing", @@ -264,14 +264,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:06:01", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:06:02", "verb": "Discarding", diff --git a/tests/log-analyzer/data/failed-prepare-suite.json b/tests/log-analyzer/data/failed-prepare-suite.json index 27bab6cd49d..cd370c3b704 100644 --- a/tests/log-analyzer/data/failed-prepare-suite.json +++ b/tests/log-analyzer/data/failed-prepare-suite.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:02:09", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:02:09", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:02:17", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-22.04-64 (may242102-500954) to boot at 34.138.163.49..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:02:18", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-20.04-64 (may242102-501054) to boot at 35.227.118.17..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:04", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242102-500954)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:04", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242102-500954)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:05", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242102-500954) at 34.138.163.49." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:05", "verb": "Sending", @@ -64,7 +64,7 @@ "extra": "project content to google:ubuntu-22.04-64 (may242102-500954)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:09", "verb": "Allocated", @@ -72,7 +72,7 @@ "extra": "google:ubuntu-20.04-64 (may242102-501054)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:09", "verb": "Connecting", @@ -80,14 +80,14 @@ "extra": "to google:ubuntu-20.04-64 (may242102-501054)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:09", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:11", "verb": "Connected", @@ -95,7 +95,7 @@ "extra": "to google:ubuntu-20.04-64 (may242102-501054) at 35.227.118.17." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:11", "verb": "Sending", @@ -103,63 +103,63 @@ "extra": "project content to google:ubuntu-20.04-64 (may242102-501054)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:11", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:11", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:12", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:12", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:13", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:13", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:14", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:14", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:14", "verb": "Restoring", @@ -184,28 +184,28 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:14", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:15", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:15", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:15", "verb": "Discarding", @@ -213,77 +213,77 @@ "extra": "google:ubuntu-20.04-64 (may242102-501054)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:15", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:16", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:17", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:17", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:18", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:19", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:20", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:20", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:21", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "18:03:22", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "18:03:22", "verb": "Discarding", diff --git a/tests/log-analyzer/data/failed-prepare-task.json b/tests/log-analyzer/data/failed-prepare-task.json index ce9c10afffb..9af0c03c951 100644 --- a/tests/log-analyzer/data/failed-prepare-task.json +++ b/tests/log-analyzer/data/failed-prepare-task.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:47", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:47", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:47", "verb": "Allocating", @@ -24,7 +24,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:47", "verb": "Allocating", @@ -32,7 +32,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:56", "verb": "Waiting", @@ -40,7 +40,7 @@ "extra": "for google:ubuntu-22.04-64 (may242058-071834) to boot at 34.75.85.33..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:56", "verb": "Waiting", @@ -48,7 +48,7 @@ "extra": "for google:ubuntu-20.04-64 (may242058-071935) to boot at 104.196.44.113..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:58:57", "verb": "Waiting", @@ -56,7 +56,7 @@ "extra": "for google:ubuntu-20.04-64 (may242058-072004) to boot at 35.196.115.140..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:02", "verb": "Waiting", @@ -64,7 +64,7 @@ "extra": "for google:ubuntu-22.04-64 (may242058-072021) to boot at 34.139.4.50..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:32", "verb": "Allocated", @@ -72,7 +72,7 @@ "extra": "google:ubuntu-22.04-64 (may242058-071834)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:32", "verb": "Connecting", @@ -80,7 +80,7 @@ "extra": "to google:ubuntu-22.04-64 (may242058-071834)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:33", "verb": "Connected", @@ -88,7 +88,7 @@ "extra": "to google:ubuntu-22.04-64 (may242058-071834) at 34.75.85.33." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:33", "verb": "Sending", @@ -96,28 +96,28 @@ "extra": "project content to google:ubuntu-22.04-64 (may242058-071834)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:37", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:38", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:38", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:38", "verb": "Allocated", @@ -125,7 +125,7 @@ "extra": "google:ubuntu-22.04-64 (may242058-072021)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:38", "verb": "Connecting", @@ -152,21 +152,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:39", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:39", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:40", "verb": "Connected", @@ -174,7 +174,7 @@ "extra": "to google:ubuntu-22.04-64 (may242058-072021) at 34.139.4.50." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:40", "verb": "Sending", @@ -182,49 +182,49 @@ "extra": "project content to google:ubuntu-22.04-64 (may242058-072021)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:40", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:40", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:41", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:41", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:42", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:42", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:43", "verb": "Allocated", @@ -232,7 +232,7 @@ "extra": "google:ubuntu-20.04-64 (may242058-072004)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:43", "verb": "Connecting", @@ -240,42 +240,42 @@ "extra": "to google:ubuntu-20.04-64 (may242058-072004)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:43", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:43", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:43", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:44", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:44", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:44", "verb": "Connected", @@ -283,7 +283,7 @@ "extra": "to google:ubuntu-20.04-64 (may242058-072004) at 35.196.115.140." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:44", "verb": "Sending", @@ -291,28 +291,28 @@ "extra": "project content to google:ubuntu-20.04-64 (may242058-072004)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:44", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:44", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:45", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:45", "verb": "Discarding", @@ -320,28 +320,28 @@ "extra": "google:ubuntu-22.04-64 (may242058-071834)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:45", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:46", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:46", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:47", "verb": "Discarding", @@ -349,7 +349,7 @@ "extra": "google:ubuntu-22.04-64 (may242058-072021)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:47", "verb": "Allocated", @@ -357,7 +357,7 @@ "extra": "google:ubuntu-20.04-64 (may242058-071935)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:47", "verb": "Connecting", @@ -365,7 +365,7 @@ "extra": "to google:ubuntu-20.04-64 (may242058-071935)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:49", "verb": "Connected", @@ -373,7 +373,7 @@ "extra": "to google:ubuntu-20.04-64 (may242058-071935) at 104.196.44.113." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:49", "verb": "Sending", @@ -381,126 +381,126 @@ "extra": "project content to google:ubuntu-20.04-64 (may242058-071935)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:50", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:50", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:51", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:51", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:52", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:52", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:52", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:53", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:53", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:53", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:53", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-3" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:54", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:54", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:55", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:55", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-4" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:55", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-2" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:56", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:56", "verb": "Restoring", @@ -526,35 +526,35 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:56", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:56", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:57", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:59:57", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:57", "verb": "Discarding", @@ -562,7 +562,7 @@ "extra": "google:ubuntu-20.04-64 (may242058-072004)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:59:58", "verb": "Discarding", diff --git a/tests/log-analyzer/data/with-aborted-and-failed-restore.json b/tests/log-analyzer/data/with-aborted-and-failed-restore.json index 904d43c850f..8d5dbbd9876 100644 --- a/tests/log-analyzer/data/with-aborted-and-failed-restore.json +++ b/tests/log-analyzer/data/with-aborted-and-failed-restore.json @@ -1,6 +1,6 @@ [ { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:47:36", "verb": "Allocating", @@ -8,7 +8,7 @@ "extra": "google:ubuntu-22.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:47:36", "verb": "Allocating", @@ -16,7 +16,7 @@ "extra": "google:ubuntu-20.04-64..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:47:46", "verb": "Waiting", @@ -24,7 +24,7 @@ "extra": "for google:ubuntu-20.04-64 (may242047-566476) to boot at 104.196.212.243..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:47:46", "verb": "Waiting", @@ -32,7 +32,7 @@ "extra": "for google:ubuntu-22.04-64 (may242047-566626) to boot at 34.75.76.3..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:32", "verb": "Allocated", @@ -40,7 +40,7 @@ "extra": "google:ubuntu-22.04-64 (may242047-566626)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:32", "verb": "Connecting", @@ -48,7 +48,7 @@ "extra": "to google:ubuntu-22.04-64 (may242047-566626)..." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:34", "verb": "Connected", @@ -56,7 +56,7 @@ "extra": "to google:ubuntu-22.04-64 (may242047-566626) at 34.75.76.3." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:34", "verb": "Sending", @@ -64,42 +64,42 @@ "extra": "project content to google:ubuntu-22.04-64 (may242047-566626)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:39", "verb": "Preparing", "task": "google:ubuntu-22.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:40", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:40", "verb": "Preparing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:41", "verb": "Executing", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:42", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/test-5" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:42", "verb": "Allocated", @@ -107,7 +107,7 @@ "extra": "google:ubuntu-20.04-64 (may242047-566476)." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:42", "verb": "Connecting", @@ -134,14 +134,14 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:43", "verb": "Restoring", "task": "google:ubuntu-22.04-64:tests/" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:43", "verb": "Connected", @@ -149,7 +149,7 @@ "extra": "to google:ubuntu-20.04-64 (may242047-566476) at 104.196.212.243." }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:43", "verb": "Sending", @@ -157,14 +157,14 @@ "extra": "project content to google:ubuntu-20.04-64 (may242047-566476)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:44", "verb": "Restoring", "task": "google:ubuntu-22.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:45", "verb": "Discarding", @@ -172,35 +172,35 @@ "extra": "google:ubuntu-22.04-64 (may242047-566626)..." }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:46", "verb": "Preparing", "task": "google:ubuntu-20.04-64" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:47", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:47", "verb": "Preparing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:48", "verb": "Executing", "task": "google:ubuntu-20.04-64:tests/test-1" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:48", "verb": "Restoring", @@ -226,21 +226,21 @@ } }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:49", "verb": "Restoring", "task": "google:ubuntu-20.04-64:tests/" }, { - "type": "action", + "type": "phase", "date": "2022-05-24", "time": "17:48:49", "verb": "Restoring", "task": "google:ubuntu-20.04-64" }, { - "type": "operation", + "type": "action", "date": "2022-05-24", "time": "17:48:50", "verb": "Discarding", diff --git a/tests/log-analyzer/data/with-failed-and-failed-restore-suite.json b/tests/log-analyzer/data/with-failed-and-failed-restore-suite.json new file mode 100644 index 00000000000..ed0930ef5b5 --- /dev/null +++ b/tests/log-analyzer/data/with-failed-and-failed-restore-suite.json @@ -0,0 +1,493 @@ +[ + { + "type": "action", + "date": "2022-05-24", + "time": "17:42:58", + "verb": "Allocating", + "task": null, + "extra": "google:ubuntu-22.04-64..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:42:58", + "verb": "Allocating", + "task": null, + "extra": "google:ubuntu-20.04-64..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:07", + "verb": "Waiting", + "task": null, + "extra": "for google:ubuntu-22.04-64 (may242043-312411) to boot at 34.148.59.204..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:07", + "verb": "Waiting", + "task": null, + "extra": "for google:ubuntu-20.04-64 (may242043-312500) to boot at 34.138.215.109..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:43", + "verb": "Allocated", + "task": null, + "extra": "google:ubuntu-22.04-64 (may242043-312411)." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:43", + "verb": "Connecting", + "task": null, + "extra": "to google:ubuntu-22.04-64 (may242043-312411)..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:45", + "verb": "Connected", + "task": null, + "extra": "to google:ubuntu-22.04-64 (may242043-312411) at 34.148.59.204." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:43:45", + "verb": "Sending", + "task": null, + "extra": "project content to google:ubuntu-22.04-64 (may242043-312411)..." + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:50", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:50", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:51", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:52", + "verb": "Executing", + "task": "google:ubuntu-22.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:52", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:53", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/test-2" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:54", + "verb": "Executing", + "task": "google:ubuntu-22.04-64:tests/test-2" + }, + { + "type": "info", + "date": "2022-05-24", + "time": "17:43:54", + "info_type": "Error", + "verb": "executing", + "task": "google:ubuntu-22.04-64:tests/test-2", + "extra": null, + "detail": { + "lines": [ + "-----\n", + "+ echo execute\n", + "execute\n", + "+ exit 1\n", + "-----\n", + ".\n" + ] + } + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:55", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/test-2" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:55", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:56", + "verb": "Executing", + "task": "google:ubuntu-22.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:56", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:57", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:58", + "verb": "Executing", + "task": "google:ubuntu-22.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:58", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:43:59", + "verb": "Preparing", + "task": "google:ubuntu-22.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:00", + "verb": "Executing", + "task": "google:ubuntu-22.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:00", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:01", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64:tests/" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:02", + "verb": "Restoring", + "task": "google:ubuntu-22.04-64" + }, + { + "type": "info", + "date": "2022-05-24", + "time": "17:44:02", + "info_type": "Error", + "verb": "restoring", + "task": "google:ubuntu-22.04-64", + "extra": null, + "detail": { + "lines": [ + "-----\n", + "+ echo 'Restore snapd-testing-tools project'\n", + "Restore snapd-testing-tools project\n", + "/bin/bash: line 26: PROJECT_PATH: unbound variable\n", + "-----\n", + ".\n" + ] + } + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:44:02", + "verb": "Discarding", + "task": null, + "extra": "google:ubuntu-22.04-64 (may242043-312411)..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:44:04", + "verb": "Allocated", + "task": null, + "extra": "google:ubuntu-20.04-64 (may242043-312500)." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:44:04", + "verb": "Connecting", + "task": null, + "extra": "to google:ubuntu-20.04-64 (may242043-312500)..." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:44:05", + "verb": "Connected", + "task": null, + "extra": "to google:ubuntu-20.04-64 (may242043-312500) at 34.138.215.109." + }, + { + "type": "action", + "date": "2022-05-24", + "time": "17:44:05", + "verb": "Sending", + "task": null, + "extra": "project content to google:ubuntu-20.04-64 (may242043-312500)..." + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:08", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:08", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:09", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:09", + "verb": "Executing", + "task": "google:ubuntu-20.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:10", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/test-3" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:10", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:11", + "verb": "Executing", + "task": "google:ubuntu-20.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:11", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/test-1" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:12", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:13", + "verb": "Executing", + "task": "google:ubuntu-20.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:13", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/test-4" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:14", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/test-2" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:14", + "verb": "Executing", + "task": "google:ubuntu-20.04-64:tests/test-2" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:15", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/test-2" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:15", + "verb": "Preparing", + "task": "google:ubuntu-20.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:16", + "verb": "Executing", + "task": "google:ubuntu-20.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:16", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/test-5" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:17", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64:tests/" + }, + { + "type": "phase", + "date": "2022-05-24", + "time": "17:44:17", + "verb": "Restoring", + "task": "google:ubuntu-20.04-64" + }, + { + "type": "info", + "date": "2022-05-24", + "time": "17:44:18", + "info_type": "Error", + "verb": "restoring", + "task": "google:ubuntu-20.04-64:tests/", + "extra": null, + "detail": null + }, + { + "type": "info", + "date": "2022-05-24", + "time": "17:44:18", + "info_type": "Error", + "verb": "restoring", + "task": "google:ubuntu-20.04-64", + "extra": null, + "detail": null + }, + { + "type": "result", + "date": "2022-05-24", + "time": "17:44:19", + "result_type": "Successful", + "level": "tasks", + "stage": null, + "number": "9", + "detail": null + }, + { + "type": "result", + "date": "2022-05-24", + "time": "17:44:19", + "result_type": "Aborted", + "level": "tasks", + "stage": null, + "number": "0", + "detail": null + }, + { + "type": "result", + "date": "2022-05-24", + "time": "17:44:19", + "result_type": "Failed", + "level": "tasks", + "stage": null, + "number": "1", + "detail": { + "lines": [ + " - google:ubuntu-22.04-64:tests/test-2\n" + ] + } + }, + { + "type": "result", + "date": "2022-05-24", + "time": "17:44:19", + "result_type": "Failed", + "level": "suite", + "stage": "restore", + "number": "1", + "detail": { + "lines": [ + " - google:ubuntu-20.04-64:tests/\n" + ] + } + }, + { + "type": "result", + "date": "2022-05-24", + "time": "17:44:19", + "result_type": "Failed", + "level": "project", + "stage": "restore", + "number": "2", + "detail": { + "lines": [ + " - google:ubuntu-20.04-64:project\n", + " - google:ubuntu-22.04-64:project\n" + ] + } + } +] \ No newline at end of file diff --git a/tests/log-analyzer/data/with-failed-and-failed-restore-suite.log b/tests/log-analyzer/data/with-failed-and-failed-restore-suite.log new file mode 100644 index 00000000000..919a43b07de --- /dev/null +++ b/tests/log-analyzer/data/with-failed-and-failed-restore-suite.log @@ -0,0 +1,79 @@ +2022-05-24 17:42:58 Project content is packed for delivery (1.30KB). +2022-05-24 17:42:58 Sequence of jobs produced with -seed=1653424978 +2022-05-24 17:42:58 If killed, discard servers with: spread -reuse-pid=96667 -discard +2022-05-24 17:42:58 Allocating google:ubuntu-22.04-64... +2022-05-24 17:42:58 Allocating google:ubuntu-20.04-64... +2022-05-24 17:43:07 Waiting for google:ubuntu-22.04-64 (may242043-312411) to boot at 34.148.59.204... +2022-05-24 17:43:07 Waiting for google:ubuntu-20.04-64 (may242043-312500) to boot at 34.138.215.109... +2022-05-24 17:43:43 Allocated google:ubuntu-22.04-64 (may242043-312411). +2022-05-24 17:43:43 Connecting to google:ubuntu-22.04-64 (may242043-312411)... +2022-05-24 17:43:45 Connected to google:ubuntu-22.04-64 (may242043-312411) at 34.148.59.204. +2022-05-24 17:43:45 Sending project content to google:ubuntu-22.04-64 (may242043-312411)... +2022-05-24 17:43:50 Preparing google:ubuntu-22.04-64 (may242043-312411)... +2022-05-24 17:43:50 Preparing google:ubuntu-22.04-64:tests/ (may242043-312411)... +2022-05-24 17:43:51 Preparing google:ubuntu-22.04-64:tests/test-3 (may242043-312411)... +2022-05-24 17:43:52 Executing google:ubuntu-22.04-64:tests/test-3 (may242043-312411) (1/10)... +2022-05-24 17:43:52 Restoring google:ubuntu-22.04-64:tests/test-3 (may242043-312411)... +2022-05-24 17:43:53 Preparing google:ubuntu-22.04-64:tests/test-2 (may242043-312411)... +2022-05-24 17:43:54 Executing google:ubuntu-22.04-64:tests/test-2 (may242043-312411) (2/10)... +2022-05-24 17:43:54 Error executing google:ubuntu-22.04-64:tests/test-2 (may242043-312411) : +----- ++ echo execute +execute ++ exit 1 +----- +. +2022-05-24 17:43:55 Restoring google:ubuntu-22.04-64:tests/test-2 (may242043-312411)... +2022-05-24 17:43:55 Preparing google:ubuntu-22.04-64:tests/test-4 (may242043-312411)... +2022-05-24 17:43:56 Executing google:ubuntu-22.04-64:tests/test-4 (may242043-312411) (3/10)... +2022-05-24 17:43:56 Restoring google:ubuntu-22.04-64:tests/test-4 (may242043-312411)... +2022-05-24 17:43:57 Preparing google:ubuntu-22.04-64:tests/test-1 (may242043-312411)... +2022-05-24 17:43:58 Executing google:ubuntu-22.04-64:tests/test-1 (may242043-312411) (4/10)... +2022-05-24 17:43:58 Restoring google:ubuntu-22.04-64:tests/test-1 (may242043-312411)... +2022-05-24 17:43:59 Preparing google:ubuntu-22.04-64:tests/test-5 (may242043-312411)... +2022-05-24 17:44:00 Executing google:ubuntu-22.04-64:tests/test-5 (may242043-312411) (5/10)... +2022-05-24 17:44:00 Restoring google:ubuntu-22.04-64:tests/test-5 (may242043-312411)... +2022-05-24 17:44:01 Restoring google:ubuntu-22.04-64:tests/ (may242043-312411)... +2022-05-24 17:44:02 Restoring google:ubuntu-22.04-64 (may242043-312411)... +2022-05-24 17:44:02 Error restoring google:ubuntu-22.04-64 (may242043-312411) : +----- ++ echo 'Restore snapd-testing-tools project' +Restore snapd-testing-tools project +/bin/bash: line 26: PROJECT_PATH: unbound variable +----- +. +2022-05-24 17:44:02 Discarding google:ubuntu-22.04-64 (may242043-312411)... +2022-05-24 17:44:04 Allocated google:ubuntu-20.04-64 (may242043-312500). +2022-05-24 17:44:04 Connecting to google:ubuntu-20.04-64 (may242043-312500)... +2022-05-24 17:44:05 Connected to google:ubuntu-20.04-64 (may242043-312500) at 34.138.215.109. +2022-05-24 17:44:05 Sending project content to google:ubuntu-20.04-64 (may242043-312500)... +2022-05-24 17:44:08 Preparing google:ubuntu-20.04-64 (may242043-312500)... +2022-05-24 17:44:08 Preparing google:ubuntu-20.04-64:tests/ (may242043-312500)... +2022-05-24 17:44:09 Preparing google:ubuntu-20.04-64:tests/test-3 (may242043-312500)... +2022-05-24 17:44:09 Executing google:ubuntu-20.04-64:tests/test-3 (may242043-312500) (6/10)... +2022-05-24 17:44:10 Restoring google:ubuntu-20.04-64:tests/test-3 (may242043-312500)... +2022-05-24 17:44:10 Preparing google:ubuntu-20.04-64:tests/test-1 (may242043-312500)... +2022-05-24 17:44:11 Executing google:ubuntu-20.04-64:tests/test-1 (may242043-312500) (7/10)... +2022-05-24 17:44:11 Restoring google:ubuntu-20.04-64:tests/test-1 (may242043-312500)... +2022-05-24 17:44:12 Preparing google:ubuntu-20.04-64:tests/test-4 (may242043-312500)... +2022-05-24 17:44:13 Executing google:ubuntu-20.04-64:tests/test-4 (may242043-312500) (8/10)... +2022-05-24 17:44:13 Restoring google:ubuntu-20.04-64:tests/test-4 (may242043-312500)... +2022-05-24 17:44:14 Preparing google:ubuntu-20.04-64:tests/test-2 (may242043-312500)... +2022-05-24 17:44:14 Executing google:ubuntu-20.04-64:tests/test-2 (may242043-312500) (9/10)... +2022-05-24 17:44:15 Restoring google:ubuntu-20.04-64:tests/test-2 (may242043-312500)... +2022-05-24 17:44:15 Preparing google:ubuntu-20.04-64:tests/test-5 (may242043-312500)... +2022-05-24 17:44:16 Executing google:ubuntu-20.04-64:tests/test-5 (may242043-312500) (10/10)... +2022-05-24 17:44:16 Restoring google:ubuntu-20.04-64:tests/test-5 (may242043-312500)... +2022-05-24 17:44:17 Restoring google:ubuntu-20.04-64:tests/ (may242043-312500)... +2022-05-24 17:44:17 Restoring google:ubuntu-20.04-64 (may242043-312500)... +2022-05-24 17:44:18 Error restoring google:ubuntu-20.04-64:tests/ (may242043-312500) : EOF +2022-05-24 17:44:18 Error restoring google:ubuntu-20.04-64 (may242043-312500) : EOF +2022-05-24 17:44:19 Successful tasks: 9 +2022-05-24 17:44:19 Aborted tasks: 0 +2022-05-24 17:44:19 Failed tasks: 1 + - google:ubuntu-22.04-64:tests/test-2 +2022-05-24 17:44:19 Failed suite restore: 1 + - google:ubuntu-20.04-64:tests/ +2022-05-24 17:44:19 Failed project restore: 2 + - google:ubuntu-20.04-64:project + - google:ubuntu-22.04-64:project diff --git a/tests/log-analyzer/task.yaml b/tests/log-analyzer/task.yaml index 0b71e7435c2..7add04199b8 100644 --- a/tests/log-analyzer/task.yaml +++ b/tests/log-analyzer/task.yaml @@ -1,9 +1,14 @@ summary: integration tests for log-analyzer tool +details: | + This test checks the log-analyzer properly retrieves the tests-to-reexecute + based on the spread log analysis. Also checks it properly retrieves the + tests by result status and all the executed tasks. + backends: [google] -# Github actions agents are just running in bionic and focal -systems: [ubuntu-18.04-64, ubuntu-20.04-64] +# Github actions agents are just running ubuntu jammy +systems: [ubuntu-22.04-64] prepare: | wget https://storage.googleapis.com/snapd-spread-tests/spread/spread-amd64.tar.gz @@ -31,7 +36,7 @@ execute: | # ubuntu-20.04 (F:0 P:0 A:5) # ubuntu-22.04 (F:0 P:0 A:5) # all-success.json - # When all the tests execute correctly, no aborted and no failed tests are listed + # When all the tests execute correctly, no tests are listed for re-execution # ubuntu-20.04 (F:0 P:5 A:0) # ubuntu-22.04 (F:0 P:5 A:0) # all-success-failed-restore.json @@ -62,6 +67,10 @@ execute: | # Tasks which execute correctly and fail to restore are not counted as failed # ubuntu-20.04 (F:0 P:1 A:4) # ubuntu-22.04 (F:0 P:1 A:4) + # with-failed-and-failed-restore-suite.json + # Just failed tasks are counted for re-execution + # ubuntu-20.04 (F:0 P:0 A:0) + # ubuntu-22.04 (F:1 P:1 A:0) ### CHECK HELP ### log-analyzer | MATCH "usage: log-analyzer list-failed-tasks " @@ -74,13 +83,15 @@ execute: | log-analyzer list-reexecute-tasks google: data/all-aborted.json | MATCH "^google:$" log-analyzer list-reexecute-tasks google:ubuntu-20.04-64: data/all-aborted.json | MATCH "^google:ubuntu-20.04-64:$" - # When all the tests pass and then fail to restore, the execution expression is returned - log-analyzer list-reexecute-tasks google: data/all-success-failed-restore.json | MATCH "^google:$" - log-analyzer list-reexecute-tasks google:ubuntu-20.04-64: data/all-success-failed-restore.json | MATCH "^google:ubuntu-20.04-64:$" + # When all the tests pass and then fail to restore, no tests are listed for re-execution + log-analyzer list-reexecute-tasks google: data/all-success-failed-restore.json | NOMATCH "google:" + compare_tasks_count "$(log-analyzer list-reexecute-tasks google: data/all-success-failed-restore.json)" 0 + log-analyzer list-reexecute-tasks google:ubuntu-20.04-64: data/all-success-failed-restore.json | NOMATCH "google:ubuntu-20.04-64:" - # When all the tests are successful, the execution expression is returned - log-analyzer list-reexecute-tasks google: data/all-success.json | MATCH "^google:$" - log-analyzer list-reexecute-tasks google:ubuntu-20.04-64: data/all-success.json | MATCH "^google:ubuntu-20.04-64:$" + # When all the tests are successful, no tests are listed for re-execution + log-analyzer list-reexecute-tasks google: data/all-success.json | NOMATCH "google:" + compare_tasks_count "$(log-analyzer list-reexecute-tasks google: data/all-success.json)" 0 + log-analyzer list-reexecute-tasks google:ubuntu-20.04-64: data/all-success.json | NOMATCH "google:ubuntu-20.04-64:" # When all the tests are failed, the execution expression is returned log-analyzer list-reexecute-tasks google: data/all-failed.json | MATCH "^google:$" @@ -117,6 +128,10 @@ execute: | log-analyzer list-reexecute-tasks google: data/aborted-and-failed-execute-and-restore.json | NOMATCH "google:ubuntu-22.04-64:tests/test-4" compare_tasks_count "$(log-analyzer list-reexecute-tasks google: data/aborted-and-failed-execute-and-restore.json)" 5 + # When some tests failed to execute and the suite and project fails to restore, just the failed test is re-executed + log-analyzer list-reexecute-tasks google: data/with-failed-and-failed-restore-suite.json | MATCH "google:ubuntu-22.04-64:tests/test-2" + compare_tasks_count "$(log-analyzer list-reexecute-tasks google: data/with-failed-and-failed-restore-suite.json)" 1 + ### CHECK ABORTED ### compare_tasks_count "$(log-analyzer list-aborted-tasks google: data/all-aborted.json)" 10 diff --git a/tests/log-analyzer/tests/test-1/task.yaml b/tests/log-analyzer/tests/test-1/task.yaml index 21cc04f382a..0bf4b7fedb6 100644 --- a/tests/log-analyzer/tests/test-1/task.yaml +++ b/tests/log-analyzer/tests/test-1/task.yaml @@ -1,5 +1,7 @@ summary: summary +details: test + prepare: | echo "prepare" diff --git a/tests/log-analyzer/tests/test-2/task.yaml b/tests/log-analyzer/tests/test-2/task.yaml index 21cc04f382a..0bf4b7fedb6 100644 --- a/tests/log-analyzer/tests/test-2/task.yaml +++ b/tests/log-analyzer/tests/test-2/task.yaml @@ -1,5 +1,7 @@ summary: summary +details: test + prepare: | echo "prepare" diff --git a/tests/log-analyzer/tests/test-3/task.yaml b/tests/log-analyzer/tests/test-3/task.yaml index 21cc04f382a..0bf4b7fedb6 100644 --- a/tests/log-analyzer/tests/test-3/task.yaml +++ b/tests/log-analyzer/tests/test-3/task.yaml @@ -1,5 +1,7 @@ summary: summary +details: test + prepare: | echo "prepare" diff --git a/tests/log-analyzer/tests/test-4/task.yaml b/tests/log-analyzer/tests/test-4/task.yaml index 21cc04f382a..0bf4b7fedb6 100644 --- a/tests/log-analyzer/tests/test-4/task.yaml +++ b/tests/log-analyzer/tests/test-4/task.yaml @@ -1,5 +1,7 @@ summary: summary +details: test + prepare: | echo "prepare" diff --git a/tests/log-analyzer/tests/test-5/task.yaml b/tests/log-analyzer/tests/test-5/task.yaml index 0577d308bde..bb02fd77a7c 100644 --- a/tests/log-analyzer/tests/test-5/task.yaml +++ b/tests/log-analyzer/tests/test-5/task.yaml @@ -1,5 +1,7 @@ summary: summary +details: test + prepare: | echo "prepare" diff --git a/tests/log-filter/task.yaml b/tests/log-filter/task.yaml new file mode 100644 index 00000000000..9d93d37c668 --- /dev/null +++ b/tests/log-filter/task.yaml @@ -0,0 +1,51 @@ +summary: test for the log filter tool + +details: | + This test checks the log-filter tool is able to read the spread output + and filter the log following a set of rules. It is also checked that the + output of the log-filter tool is the same than spread. + +backends: [google] + +# Github actions agents are just running ubuntu jammy +systems: [ubuntu-22.04-64] + +prepare: | + wget https://storage.googleapis.com/snapd-spread-tests/dependencies/spread-log-filter.tar.xz + tar -xf spread-log-filter.tar.xz + +restore: | + rm -rf spread-log-filter.tar.xz ./*.log + +execute: | + log-filter --help | MATCH 'usage: log-filter \[-h\] \[-o PATH\]' + log-filter -h | MATCH 'usage: log-filter \[-h\] \[-o PATH\]' + + # Run the tool for a real log + # The output should: + # 1. the output should go to test.filtered.log file + # 2. exclude: Preparing, Restoring, Error, Warning + # 3. show: debug lines with ###DEBUG + # 4. show: failed tests for google-nested + log-filter -o test.filtered.log -e Error -e Restoring -e Preparing -f "Debug=###DEBUG" -f "Failed=google-nested:" < spread-log-filter.log > output.log + + # Check the stdout is the same than the stdin + diff -Z spread-log-filter.log output.log + + # Check exclude + test "$(grep -c Restoring test.filtered.log)" -eq 0 + test "$(grep -c Preparing test.filtered.log)" -eq 0 + test "$(grep -c Error test.filtered.log)" -eq 0 + + # Check the non excluded + test "$(grep -c 'Debug output' test.filtered.log)" -eq "$(grep -c 'Debug output' spread-log-filter.log)" + + # Check the filters + test "$(grep -c '###DEBUG' test.filtered.log)" -eq "$(grep -c '###DEBUG' spread-log-filter.log)" + grep -A 1 'Failed suite prepare: 4' test.filtered.log | MATCH 'Failed suite restore: 1' + + # Check no repeated + test "$(grep -c 'Failed suite prepare: 4' test.filtered.log)" -eq 1 + test "$(grep -c 'Executing' test.filtered.log)" -eq "$(grep -c 'Executing' spread-log-filter.log)" + test "$(grep -c 'Aborted tasks' test.filtered.log)" -eq 1 + diff --git a/tests/log-parser/task.yaml b/tests/log-parser/task.yaml index 6c46af44b46..39b9b4ca6a1 100644 --- a/tests/log-parser/task.yaml +++ b/tests/log-parser/task.yaml @@ -1,9 +1,14 @@ summary: test for the log parser tool +details: | + This test checks the log-parser tool is able to read different spread + logs and produce a json file with the logs info. This json file contains + all the information from the log but structured in json format. + backends: [google] -# Github actions agents are just running in bionic and focal -systems: [ubuntu-18.04-64, ubuntu-20.04-64] +# Github actions agents are just running ubuntu jammy +systems: [ubuntu-22.04-64] execute: | log-parser --help | MATCH 'usage: log-parser \[-h\] \[-c CUT\]' @@ -82,25 +87,34 @@ execute: | jq -r '.[] | select( .type == "result") | select( .result_type == "Failed") | select(.level == "tasks") | .detail' spread-results.json | MATCH "degraded" # Check the filter - test "$(log-parser with-failed-and-aborted.log.spread -pd error | grep -c "Error preparing")" -eq 5 - test "$(log-parser with-failed-and-aborted.log.spread -pd error | grep -c "command -v restorecon")" -eq 4 + test "$(log-parser with-failed-and-aborted.log.spread | grep -c "Error preparing")" -eq 5 + test "$(log-parser with-failed-and-aborted.log.spread | grep -c "command -v restorecon")" -eq 4 - # Check the filter cuting the logs - test "$(log-parser with-failed-and-aborted.log.spread -pd error | wc -l)" -eq 184 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 0 | wc -l)" -eq 14 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 0 | grep -c "Error preparing")" -eq 5 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 0 | grep -c "")" -eq 0 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 2 | wc -l)" -eq 26 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 2 | grep -c "Error preparing")" -eq 5 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 2 | grep -c "")" -eq 5 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 3 | wc -l)" -eq 32 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 3 | grep -c "Error preparing")" -eq 5 - test "$(log-parser with-failed-and-aborted.log.spread -pd error -c 3 | grep -c "")" -eq 5 + # Check the filter cutting the logs + test "$(log-parser with-failed-and-aborted.log.spread | wc -l)" -eq 261 + test "$(log-parser with-failed-and-aborted.log.spread -c 0 | wc -l)" -eq 77 + test "$(log-parser with-failed-and-aborted.log.spread -c 0 | grep -c "Error preparing")" -eq 5 + test "$(log-parser with-failed-and-aborted.log.spread -c 0 | grep -c "")" -eq 0 + test "$(log-parser with-failed-and-aborted.log.spread -c 2 | wc -l)" -eq 91 + test "$(log-parser with-failed-and-aborted.log.spread -c 2 | grep -c "Error preparing")" -eq 5 + test "$(log-parser with-failed-and-aborted.log.spread -c 2 | grep -c "")" -eq 5 + test "$(log-parser with-failed-and-aborted.log.spread -c 3 | wc -l)" -eq 98 + test "$(log-parser with-failed-and-aborted.log.spread -c 3 | grep -c "Error preparing")" -eq 5 + test "$(log-parser with-failed-and-aborted.log.spread -c 3 | grep -c "")" -eq 5 # Check the results can be filtered - log-parser with-failed-and-aborted.log.spread -pr failed | grep -q "Failed tasks: 1" - log-parser with-failed-and-aborted.log.spread -pr failed | grep -c "Failed project prepare: 4" - log-parser with-failed-and-aborted.log.spread -pr aborted | grep -c "Aborted tasks: 24" - log-parser all-successful.log.spread -pr successful | grep -q "Successful tasks: 434" - log-parser all-successful.log.spread -pr failed | grep -v "Aborted tasks" + log-parser with-failed-and-aborted.log.spread | grep -q "Failed tasks: 1" + log-parser with-failed-and-aborted.log.spread | grep -c "Failed project prepare: 4" + log-parser with-failed-and-aborted.log.spread | grep -c "Aborted tasks: 24" + log-parser all-successful.log.spread | grep -q "Successful tasks: 434" + log-parser all-successful.log.spread | grep -v "Aborted tasks" + + # Check filtering the debug output + log-parser with-debug-output.log.spread -c 1 -dr "executed_tests=EXECUTED_TESTS=(.*)" -dr "apparmor_version=AppArmor parser version .*" + test "$(jq -r '.[0].detail.executed_tests[0]' spread-results.json | wc -w)" -eq 44 + test "$(jq -r '.[0].detail.apparmor_version[0]' spread-results.json)" = "AppArmor parser version 2.13.3" + # Check filtering the error output + log-parser with-error-output.log.spread -c 1 -er "executed_tests=EXECUTED_TESTS=(.*)" -er "apparmor_version=AppArmor parser version .*" + test "$(jq -r '.[0].detail.executed_tests[0]' spread-results.json | wc -w)" -eq 44 + test "$(jq -r '.[0].detail.apparmor_version[0]' spread-results.json)" = "AppArmor parser version 2.13.3" diff --git a/tests/log-parser/with-all-results.log.spread b/tests/log-parser/with-all-results.log.spread index c64ac9ac71d..933cccb398e 100644 --- a/tests/log-parser/with-all-results.log.spread +++ b/tests/log-parser/with-all-results.log.spread @@ -93,7 +93,7 @@ created 0 fifos 2022-05-18 18:07:57 Restoring google-nested:ubuntu-16.04-64:tests/nested/manual/cloud-init-never-used-not-vuln:firstboot (may181749-433163)... 2022-05-18 18:08:00 Preparing google-nested:ubuntu-16.04-64:tests/nested/manual/cloud-init-nocloud-not-vuln:firstboot (may181749-433163)... 2022-05-18 18:08:40 Executing google-nested:ubuntu-16.04-64:tests/nested/core/image-build (may181749-432987) (2/13)... -Error: 2022-05-18 18:09:34 Error preparing google-nested:ubuntu-16.04-64:tests/nested/manual/cloud-init-nocloud-not-vuln:firstboot (may181749-433163) : +2022-05-18 18:09:34 Error preparing google-nested:ubuntu-16.04-64:tests/nested/manual/cloud-init-nocloud-not-vuln:firstboot (may181749-433163) : ----- + /home/gopath/src/github.com/snapcore/snapd/tests/lib/prepare-restore.sh --prepare-project-each + set -e @@ -160,4 +160,3 @@ google-nested:ubuntu-16.04-64:tests/nested/classic/hotplug google-nested:ubuntu- 2022-05-18 16:45:15 Failed project restore: 2 - google:ubuntu-core-22-64:project - google:ubuntu-core-22-64:project -error: unsuccessful run \ No newline at end of file diff --git a/tests/log-parser/with-debug-output.log.spread b/tests/log-parser/with-debug-output.log.spread new file mode 100644 index 00000000000..f90830b57e9 --- /dev/null +++ b/tests/log-parser/with-debug-output.log.spread @@ -0,0 +1,81 @@ +2024-04-25 16:56:53 Debug output for external:ubuntu-core-20-64:tests/core/snapd-maintenance-msg (external:ubuntu-core-20-64) : +----- ++ '[' 1 '!=' 1 ']' ++ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/state.sh +++ SNAPD_STATE_PATH=/var/tmp/snapd-tools/snapd-state +++ SNAPD_STATE_FILE=/var/tmp/snapd-tools/snapd-state/snapd-state.tar +++ SNAPD_ACTIVE_UNITS=/var/tmp/snapd-tools/runtime-state/snapd-active-units ++ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/systems.sh ++ echo '# System information' +# System information ++ cat /etc/os-release +NAME="Ubuntu Core" +VERSION="20" +ID=ubuntu-core +PRETTY_NAME="Ubuntu Core 20" +VERSION_ID="20" +HOME_URL="https://snapcraft.io/" +BUG_REPORT_URL="https://bugs.launchpad.net/snappy/" ++ echo '# Kernel information' +# Kernel information ++ uname -a +Linux ubuntu 5.4.0-177-generic #197-Ubuntu SMP Thu Mar 28 22:45:47 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux ++ echo '# Apparmor information' +# Apparmor information ++ apparmor_parser --version +AppArmor parser version 2.13.3 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=55 compat=0 ip=0x7ff1c6d2e73a code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=52 compat=0 ip=0x7ff1c6d2e6d7 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=51 compat=0 ip=0x7ff1c6d2e707 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=44 compat=0 ip=0x7ff1c700ea5a code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=45 compat=0 ip=0x7ff1c700e8da code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=3 compat=0 ip=0x7ff1c700e511 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=202 compat=0 ip=0x7ff1c700c92e code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=231 compat=0 ip=0x7ff1c6cf0ab6 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu snapd[16017]: logger.go:93: DEBUG: pid=17276;uid=0;socket=/run/snapd.socket; GET /v2/changes?select=all 955.32µs 200 +Apr 25 16:56:53 ubuntu systemd[1]: snap.test-snapd-curl.curl-9e260fd8-e6ab-4b2a-82af-1c5db658cd84.scope: Succeeded. +Apr 25 16:56:53 ubuntu sudo[14547]: pam_unix(sudo:session): session closed for user root +Apr 25 16:56:53 ubuntu systemd[1]: snap.jq.jq-6dd86506-7d6f-4009-9ea0-77b6c34c607b.scope: Succeeded. +Apr 25 16:56:53 ubuntu sudo[17324]: external : TTY=unknown ; *** ; USER=root ; COMMAND=/bin/bash -c /bin/bash - +Apr 25 16:56:53 ubuntu sudo[17324]: pam_unix(sudo:session): session opened for user root by (uid=0) +Apr 25 16:56:53 ubuntu systemd-journald[13548]: Runtime Journal (/run/log/journal/b40777928f53498d900b3982055b5893) is 45.7M, max 79.2M, 33.5M free. +Apr 25 16:56:53 ubuntu snapd[16017]: logger.go:93: DEBUG: pid=17362;uid=0;socket=/run/snapd.socket; GET /v2/connections?select=all 521.714µs 200 ++ echo '# tasks executed on system' +# tasks executed on system ++ echo '' ++ cat /var/tmp/snapd-tools/runtime-state/runs - +EXECUTED_TESTS=google:ubuntu-16.04-64:tests/main/interfaces-many-snap-provided google:ubuntu-16.04-64:tests/main/snap-seccomp google:ubuntu-16.04-64:tests/main/install-hook-misbehaving google:ubuntu-16.04-64:tests/main/security-device-cgroups-helper google:ubuntu-16.04-64:tests/main/interfaces-device-buttons google:ubuntu-16.04-64:tests/main/upgrade-from-2.15 google:ubuntu-16.04-64:tests/main/buildmode google:ubuntu-16.04-64:tests/main/snapshot-basic google:ubuntu-16.04-64:tests/main/system-usernames:_daemon_ google:ubuntu-16.04-64:tests/main/try-snap-goes-away:test_snapd_tools google:ubuntu-16.04-64:tests/main/interfaces-accounts-service google:ubuntu-16.04-64:tests/main/snap-run-userdata-current google:ubuntu-16.04-64:tests/main/snapd-update-services google:ubuntu-16.04-64:tests/main/remove-errors google:ubuntu-16.04-64:tests/main/mounts-persist-refresh-content-snap google:ubuntu-16.04-64:tests/main/parallel-install-auto-aliases google:ubuntu-16.04-64:tests/main/install-errors:withreexec google:ubuntu-16.04-64:tests/main/searching google:ubuntu-16.04-64:tests/main/interfaces-mount-control google:ubuntu-16.04-64:tests/main/services-after-before-install google:ubuntu-16.04-64:tests/main/system-usernames-illegal google:ubuntu-16.04-64:tests/main/interfaces-system-files google:ubuntu-16.04-64:tests/main/interfaces-desktop-launch google:ubuntu-16.04-64:tests/main/snap-env:regular google:ubuntu-16.04-64:tests/main/refresh-devmode:remote google:ubuntu-16.04-64:tests/main/snapd-sigterm google:ubuntu-16.04-64:tests/main/interfaces-browser-support:disallow google:ubuntu-16.04-64:tests/main/install-store:reexec1 google:ubuntu-16.04-64:tests/main/parallel-install-aliases google:ubuntu-16.04-64:tests/main/user-data-handling google:ubuntu-16.04-64:tests/main/interfaces-shutdown-introspection google:ubuntu-16.04-64:tests/main/refresh:classic_remote google:ubuntu-16.04-64:tests/main/system-users-are-created:snap_daemon google:ubuntu-16.04-64:tests/main/snap-update-ns google:ubuntu-16.04-64:tests/main/find-private google:ubuntu-16.04-64:tests/main/interfaces-adb-support google:ubuntu-16.04-64:tests/main/interfaces-system-observe google:ubuntu-16.04-64:tests/main/refresh-devmode:fake google:ubuntu-16.04-64:tests/main/interfaces-content google:ubuntu-16.04-64:tests/main/server-snap:pythonServer google:ubuntu-16.04-64:tests/main/retry-network google:ubuntu-16.04-64:tests/main/snap-run-devmode-classic:core_first google:ubuntu-16.04-64:tests/main/system-core-alias google:ubuntu-16.04-64:tests/main/snap-run-devmode-classic:snapd_first +echo '' +------ diff --git a/tests/log-parser/with-error-output.log.spread b/tests/log-parser/with-error-output.log.spread new file mode 100644 index 00000000000..1f7d5d3b987 --- /dev/null +++ b/tests/log-parser/with-error-output.log.spread @@ -0,0 +1,81 @@ +2024-04-26 16:38:41 Error executing google:ubuntu-core-20-64:tests/main/snap-quota-thread (apr261545-458974) : +----- ++ '[' 1 '!=' 1 ']' ++ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/state.sh +++ SNAPD_STATE_PATH=/var/tmp/snapd-tools/snapd-state +++ SNAPD_STATE_FILE=/var/tmp/snapd-tools/snapd-state/snapd-state.tar +++ SNAPD_ACTIVE_UNITS=/var/tmp/snapd-tools/runtime-state/snapd-active-units ++ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/systems.sh ++ echo '# System information' +# System information ++ cat /etc/os-release +NAME="Ubuntu Core" +VERSION="20" +ID=ubuntu-core +PRETTY_NAME="Ubuntu Core 20" +VERSION_ID="20" +HOME_URL="https://snapcraft.io/" +BUG_REPORT_URL="https://bugs.launchpad.net/snappy/" ++ echo '# Kernel information' +# Kernel information ++ uname -a +Linux ubuntu 5.4.0-177-generic #197-Ubuntu SMP Thu Mar 28 22:45:47 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux ++ echo '# Apparmor information' +# Apparmor information ++ apparmor_parser --version +AppArmor parser version 2.13.3 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=55 compat=0 ip=0x7ff1c6d2e73a code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=52 compat=0 ip=0x7ff1c6d2e6d7 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=51 compat=0 ip=0x7ff1c6d2e707 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=44 compat=0 ip=0x7ff1c700ea5a code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=7 compat=0 ip=0x7ff1c6d20b84 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=45 compat=0 ip=0x7ff1c700e8da code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=1 compat=0 ip=0x7ff1c6d1c104 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=3 compat=0 ip=0x7ff1c700e511 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=13 compat=0 ip=0x7ff1c700fa4d code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=202 compat=0 ip=0x7ff1c700c92e code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=5 compat=0 ip=0x7ff1c6d1b773 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu audit[17276]: SECCOMP auid=1001 uid=0 gid=0 ses=79 pid=17276 comm="curl" exe="/snap/test-snapd-curl/27/usr/bin/curl" sig=0 arch=c000003e syscall=231 compat=0 ip=0x7ff1c6cf0ab6 code=0x7ffc0000 +Apr 25 16:56:53 ubuntu snapd[16017]: logger.go:93: DEBUG: pid=17276;uid=0;socket=/run/snapd.socket; GET /v2/changes?select=all 955.32µs 200 +Apr 25 16:56:53 ubuntu systemd[1]: snap.test-snapd-curl.curl-9e260fd8-e6ab-4b2a-82af-1c5db658cd84.scope: Succeeded. +Apr 25 16:56:53 ubuntu sudo[14547]: pam_unix(sudo:session): session closed for user root +Apr 25 16:56:53 ubuntu systemd[1]: snap.jq.jq-6dd86506-7d6f-4009-9ea0-77b6c34c607b.scope: Succeeded. +Apr 25 16:56:53 ubuntu sudo[17324]: external : TTY=unknown ; *** ; USER=root ; COMMAND=/bin/bash -c /bin/bash - +Apr 25 16:56:53 ubuntu sudo[17324]: pam_unix(sudo:session): session opened for user root by (uid=0) +Apr 25 16:56:53 ubuntu systemd-journald[13548]: Runtime Journal (/run/log/journal/b40777928f53498d900b3982055b5893) is 45.7M, max 79.2M, 33.5M free. +Apr 25 16:56:53 ubuntu snapd[16017]: logger.go:93: DEBUG: pid=17362;uid=0;socket=/run/snapd.socket; GET /v2/connections?select=all 521.714µs 200 ++ echo '# tasks executed on system' +# tasks executed on system ++ echo '' ++ cat /var/tmp/snapd-tools/runtime-state/runs - +EXECUTED_TESTS=google:ubuntu-16.04-64:tests/main/interfaces-many-snap-provided google:ubuntu-16.04-64:tests/main/snap-seccomp google:ubuntu-16.04-64:tests/main/install-hook-misbehaving google:ubuntu-16.04-64:tests/main/security-device-cgroups-helper google:ubuntu-16.04-64:tests/main/interfaces-device-buttons google:ubuntu-16.04-64:tests/main/upgrade-from-2.15 google:ubuntu-16.04-64:tests/main/buildmode google:ubuntu-16.04-64:tests/main/snapshot-basic google:ubuntu-16.04-64:tests/main/system-usernames:_daemon_ google:ubuntu-16.04-64:tests/main/try-snap-goes-away:test_snapd_tools google:ubuntu-16.04-64:tests/main/interfaces-accounts-service google:ubuntu-16.04-64:tests/main/snap-run-userdata-current google:ubuntu-16.04-64:tests/main/snapd-update-services google:ubuntu-16.04-64:tests/main/remove-errors google:ubuntu-16.04-64:tests/main/mounts-persist-refresh-content-snap google:ubuntu-16.04-64:tests/main/parallel-install-auto-aliases google:ubuntu-16.04-64:tests/main/install-errors:withreexec google:ubuntu-16.04-64:tests/main/searching google:ubuntu-16.04-64:tests/main/interfaces-mount-control google:ubuntu-16.04-64:tests/main/services-after-before-install google:ubuntu-16.04-64:tests/main/system-usernames-illegal google:ubuntu-16.04-64:tests/main/interfaces-system-files google:ubuntu-16.04-64:tests/main/interfaces-desktop-launch google:ubuntu-16.04-64:tests/main/snap-env:regular google:ubuntu-16.04-64:tests/main/refresh-devmode:remote google:ubuntu-16.04-64:tests/main/snapd-sigterm google:ubuntu-16.04-64:tests/main/interfaces-browser-support:disallow google:ubuntu-16.04-64:tests/main/install-store:reexec1 google:ubuntu-16.04-64:tests/main/parallel-install-aliases google:ubuntu-16.04-64:tests/main/user-data-handling google:ubuntu-16.04-64:tests/main/interfaces-shutdown-introspection google:ubuntu-16.04-64:tests/main/refresh:classic_remote google:ubuntu-16.04-64:tests/main/system-users-are-created:snap_daemon google:ubuntu-16.04-64:tests/main/snap-update-ns google:ubuntu-16.04-64:tests/main/find-private google:ubuntu-16.04-64:tests/main/interfaces-adb-support google:ubuntu-16.04-64:tests/main/interfaces-system-observe google:ubuntu-16.04-64:tests/main/refresh-devmode:fake google:ubuntu-16.04-64:tests/main/interfaces-content google:ubuntu-16.04-64:tests/main/server-snap:pythonServer google:ubuntu-16.04-64:tests/main/retry-network google:ubuntu-16.04-64:tests/main/snap-run-devmode-classic:core_first google:ubuntu-16.04-64:tests/main/system-core-alias google:ubuntu-16.04-64:tests/main/snap-run-devmode-classic:snapd_first +echo '' +------ diff --git a/tests/not/task.yaml b/tests/not/task.yaml index 64a5685c936..3377d3c23c3 100644 --- a/tests/not/task.yaml +++ b/tests/not/task.yaml @@ -1,5 +1,8 @@ summary: test for the not tool +details: | + Check the not tool works the same as the logical not (!). + backends: [google] execute: | diff --git a/tests/os.paths/task.yaml b/tests/os.paths/task.yaml index 7630a5227be..e9f34449324 100644 --- a/tests/os.paths/task.yaml +++ b/tests/os.paths/task.yaml @@ -1,5 +1,9 @@ summary: smoke test for the os.paths tool +details: | + Check the os.paths tool properly retrieves the snap-mount-dir, + media-dir and libexec-dir in the current system. + backends: [google] execute: | diff --git a/tests/os.query/task.yaml b/tests/os.query/task.yaml index 4c33a895736..65ef12d2e2c 100644 --- a/tests/os.query/task.yaml +++ b/tests/os.query/task.yaml @@ -1,6 +1,10 @@ summary: smoke test for the os.query tool -backends: [google] +details: | + Check the os.query tool properly detects the current system. Also + verify the version comparison works. + +backends: [google, openstack] execute: | os.query --help | MATCH 'usage: os.query is-core, is-classic' @@ -60,6 +64,8 @@ execute: | ! os.query is-debian os.query is-classic ! os.query is-core + ! os.query is-core-ge 20 + ! os.query is-core-le 20 os.query is-pc-amd64 ! os.query is-arm ;; @@ -69,27 +75,26 @@ execute: | os.query is-ubuntu 22.04 ! os.query is-ubuntu 20.04 ! os.query is-core + ! os.query is-core-ge 20 + ! os.query is-core-le 20 + ! os.query is-core-le 24 + ! os.query is-core-ge 24 ;; - ubuntu-22.10-64) + ubuntu-24.04-64) os.query is-classic - os.query is-ubuntu 22.10 + os.query is-ubuntu 24.04 ! os.query is-ubuntu 21.04 ! os.query is-core ;; - debian-10-64) + debian-11-64) os.query is-debian - os.query is-debian 10 + os.query is-debian 11 os.query is-classic ! os.query is-core - - # check ubuntu comparisons - ! os.query is-ubuntu-lt 20.04 - os.query is-ubuntu-ge 20.04 | MATCH "os.query: comparing non ubuntu system" - os.query is-ubuntu-lt 2>&1 | MATCH "os.query: version id is expected" ;; - debian-11-64) + debian-12-64) os.query is-debian - os.query is-debian 11 + os.query is-debian 12 os.query is-classic ! os.query is-core ;; @@ -99,16 +104,16 @@ execute: | os.query is-classic ! os.query is-core ;; - fedora-35-64) + fedora-39-64) os.query is-fedora - os.query is-fedora 35 + os.query is-fedora 39 ! os.query is-fedora rawhide os.query is-classic ! os.query is-core ;; - fedora-36-64) + fedora-40-64) os.query is-fedora - os.query is-fedora 36 + os.query is-fedora 40 ! os.query is-fedora rawhide os.query is-classic ! os.query is-core @@ -120,35 +125,32 @@ execute: | ;; amazon-linux-2-64) os.query is-amazon-linux + os.query is-amazon-linux 2 + ! os.query is-amazon-linux 2023 os.query is-classic ! os.query is-core ;; - centos-7-64) - os.query is-centos - os.query is-centos 7 + amazon-linux-2023-64) + os.query is-amazon-linux + os.query is-amazon-linux 2023 + ! os.query is-amazon-linux 2 os.query is-classic ! os.query is-core ;; - centos-8-64) - os.query is-centos - os.query is-centos 8 - ! os.query is-core - ;; centos-9-64) os.query is-centos 9 os.query is-centos ! os.query is-core ;; - opensuse-15.3-64) + opensuse-15.5-64) os.query is-opensuse - os.query is-opensuse 15.3 + os.query is-opensuse 15.5 os.query is-classic ! os.query is-core ;; - opensuse-15.4-64) + opensuse-15.6-64) os.query is-opensuse - os.query is-opensuse 15.4 - ! os.query is-opensuse tumbleweed + os.query is-opensuse 15.6 os.query is-classic ! os.query is-core ;; diff --git a/tests/quiet/task.yaml b/tests/quiet/task.yaml new file mode 100644 index 00000000000..23c7f51ca45 --- /dev/null +++ b/tests/quiet/task.yaml @@ -0,0 +1,12 @@ +summary: test for the quiet tool + +details: | + Check the quiet tool hides the command stdout and but shows the stderr + +backends: [google] + +execute: | + quiet echo test | NOMATCH test + quiet "cat nofile" 2>&1 | MATCH nofile + quiet "cat nofile" 2>&1 | MATCH "quiet: exit status 127" + quiet "cat nofile" 2>&1 | MATCH "quiet: end of output" diff --git a/tests/remote.exec/task.yaml b/tests/remote.exec/task.yaml index 7ceb6f6f920..249e8718c55 100644 --- a/tests/remote.exec/task.yaml +++ b/tests/remote.exec/task.yaml @@ -1,10 +1,13 @@ summary: smoke test for the remote.exec tool +details: | + Check the remote.exec tool is able to run commands in the + remote instance through ssh. + backends: [google] # Amazon linux is skipped because no sshpass available -# ubuntu-22.10-64 is skipped because no sshpass available -systems: [-amazon-linux-*, -ubuntu-22.10-64] +systems: [-amazon-linux-*] prepare: | tests.pkgs install sshpass diff --git a/tests/remote.pull/task.yaml b/tests/remote.pull/task.yaml index f60354a5b5e..658add64e1c 100644 --- a/tests/remote.pull/task.yaml +++ b/tests/remote.pull/task.yaml @@ -1,10 +1,13 @@ summary: smoke test for the remote.pull tool +details: | + Check the remote.pull tool is able to retrieve files from the + remote instance through scp + backends: [google] # Amazon linux is skipped because no sshpass available -# ubuntu-22.10-64 is skipped because no sshpass available -systems: [-amazon-linux-*, -ubuntu-22.10-64] +systems: [-amazon-linux-*] prepare: | tests.pkgs install sshpass @@ -12,18 +15,23 @@ prepare: | restore: | tests.pkgs remove sshpass - rm -rf testfile remote.setup.cfg /home/tools-user-1/* + rm -rf testfile testfile2 /tmp/testfile2 remote.setup.cfg /home/tools-user-1/* execute: | - remote.pull --help | MATCH 'usage: remote.pull ' - remote.pull -h | MATCH 'usage: remote.pull ' + remote.pull --help | MATCH 'usage: remote.pull \[LOCAL_PATH\]' + remote.pull -h | MATCH 'usage: remote.pull \[LOCAL_PATH\]' # check basic pull touch /home/tools-user-1/testfile remote.pull testfile . test -f testfile - # Check errors - remote.pull testfile 2>&1 | MATCH "remote.pull: local and remote paths are required" + # check pull without local dir + touch /tmp/testfile2 + remote.pull /tmp/testfile2 + test -f ./testfile2 + + # Check no parameters + remote.pull | MATCH 'usage: remote.pull \[LOCAL_PATH\]' rm -f remote.setup.cfg remote.pull /home/tools-user-1/testfile . 2>&1 | MATCH "remote.pull: config file \"$(pwd)/remote.setup.cfg\" not found, please run remote.setup command first" diff --git a/tests/remote.push/task.yaml b/tests/remote.push/task.yaml index c9e2cdbcda9..047e5cca070 100644 --- a/tests/remote.push/task.yaml +++ b/tests/remote.push/task.yaml @@ -1,10 +1,13 @@ summary: smoke test for the remote.push tool +details: | + Check the remote.push tool is able to send files from + localhost to the remote instance through scp + backends: [google] # Amazon linux is skipped because no sshpass available -# ubuntu-22.10-64 is skipped because no sshpass available -systems: [-amazon-linux-*, -ubuntu-22.10-64] +systems: [-amazon-linux-*] prepare: | tests.pkgs install sshpass @@ -15,15 +18,20 @@ restore: | rm -rf testfile remote.setup.cfg /home/tools-user-1/* execute: | - remote.push --help | MATCH 'usage: remote.push ' - remote.push -h | MATCH 'usage: remote.push ' + remote.push --help | MATCH 'usage: remote.push \[REMOTE_PATH\]' + remote.push -h | MATCH 'usage: remote.push \[REMOTE_PATH\]' # check basic push touch testfile remote.push testfile "/home/tools-user-1" test -f /home/tools-user-1/testfile - # Check errors - remote.push testfile 2>&1 | MATCH "remote.push: local and remote paths are required" + # check push without target dir + touch testfile2 + remote.push testfile2 + test -f /home/tools-user-1/testfile2 + + # Check no parameters + remote.push | MATCH 'usage: remote.push \[REMOTE_PATH\]' rm -f remote.setup.cfg remote.push testfile "/home/tools-user-1" 2>&1 | MATCH "remote.push: config file \"$(pwd)/remote.setup.cfg\" not found, please run remote.setup command first" diff --git a/tests/remote.refresh/task.yaml b/tests/remote.refresh/task.yaml index c24a75867ec..1b6a7cb47a5 100644 --- a/tests/remote.refresh/task.yaml +++ b/tests/remote.refresh/task.yaml @@ -1,4 +1,9 @@ -summary: smoke test for the remote.wait-for tool +summary: smoke test for the remote.refresh tool + +details: | + Check the remote.refresh tool properly handles refreshes in + the remote instance including the refresh for several snaps + which trigger reboots backends: [google-nested] @@ -10,14 +15,11 @@ environment: host: localhost port: 8022 unit: nested-vm - TARGET/xenial: xenial - TARGET/bionic: bionic + TARGET: xenial prepare: | if [ "$TARGET" = xenial ]; then wget -O pc.img.xz https://storage.googleapis.com/snapd-spread-tests/images/booted/pc-amd64-16-stable-core_beta_2.56.2.img.xz - elif [ "$TARGET" = bionic ]; then - wget -O pc.img.xz https://storage.googleapis.com/snapd-spread-tests/images/booted/pc-amd64-18-stable-snapd_beta_2.56.2.img.xz fi unxz pc.img.xz @@ -27,7 +29,7 @@ prepare: | remote.setup config --host "$host" --port "$port" --user "$user" --pass "$pass" restore: | - tests.systemd stop-and-remove-unit "$unit" + tests.systemd stop-unit --remove "$unit" rm -f pc.img "$(remote.setup get-config-path)" execute: | diff --git a/tests/remote.retry/task.yaml b/tests/remote.retry/task.yaml index 4a6f1315de4..424714e7217 100644 --- a/tests/remote.retry/task.yaml +++ b/tests/remote.retry/task.yaml @@ -1,10 +1,14 @@ summary: smoke test for the remote.retry tool +details: | + This test checks the remote.retry tool properly handles retrying + a command in the remote instance. Also verifies that on failure + the exit code from the final attempt is returned. + backends: [google] # Amazon linux is skipped because no sshpass available -# ubuntu-22.10-64 is skipped because no sshpass available -systems: [-amazon-linux-*, -ubuntu-22.10-64] +systems: [-amazon-linux-*] prepare: | tests.pkgs install sshpass diff --git a/tests/remote.setup/task.yaml b/tests/remote.setup/task.yaml index a600f8c58ee..9ee820b8b02 100644 --- a/tests/remote.setup/task.yaml +++ b/tests/remote.setup/task.yaml @@ -1,5 +1,10 @@ summary: smoke test for the remote.setup tool +details: | + Check the remote.setup tool properly sets up up the + information required to allow connecting to the remote + instance through ssh. + backends: [google] restore: | diff --git a/tests/remote.wait-for/task.yaml b/tests/remote.wait-for/task.yaml index b0cd9a05805..db3a050313f 100644 --- a/tests/remote.wait-for/task.yaml +++ b/tests/remote.wait-for/task.yaml @@ -1,5 +1,10 @@ summary: smoke test for the remote.wait-for tool +details: | + Check the remote.wait-for tool waits properly for several + events in the remote instance. Supported events are: + device-initialized, reboot, refresh, ssh, no-ssh, etc + backends: [google-nested] systems: [ubuntu-20.04-64] @@ -10,14 +15,11 @@ environment: host: localhost port: 8022 unit: nested-vm - TARGET/xenial: xenial - TARGET/bionic: bionic + TARGET: xenial prepare: | if [ "$TARGET" = xenial ]; then wget -O pc.img.xz https://storage.googleapis.com/snapd-spread-tests/images/booted/pc-amd64-16-stable-core_beta_2.56.2.img.xz - elif [ "$TARGET" = bionic ]; then - wget -O pc.img.xz https://storage.googleapis.com/snapd-spread-tests/images/booted/pc-amd64-18-stable-snapd_beta_2.56.2.img.xz fi unxz pc.img.xz @@ -27,7 +29,7 @@ prepare: | remote.setup config --host "$host" --port "$port" --user "$user" --pass "$pass" restore: | - tests.systemd stop-and-remove-unit "$unit" + tests.systemd stop-unit --remove "$unit" rm -f pc.img "$(remote.setup get-config-path)" execute: | @@ -51,7 +53,7 @@ execute: | # Check waiting when reboot remote.exec "sudo reboot" || true remote.wait-for no-ssh --wait 1 -n 20 - remote.wait-for ssh --wait 1 -n 60 + remote.wait-for ssh --wait 1 -n 120 # Check waiting for reboot initial_boot_id="$(remote.exec "cat /proc/sys/kernel/random/boot_id")" diff --git a/tests/repack-kernel/task.yaml b/tests/repack-kernel/task.yaml index 90a946efacc..86e210222a2 100644 --- a/tests/repack-kernel/task.yaml +++ b/tests/repack-kernel/task.yaml @@ -1,5 +1,10 @@ summary: tests for the repack-kernel tool +details: | + Check the repack-kernel tools properly handles extraction of the + kernel snap to a workspace directory, and then repacks it back + to a snap + backends: [google] # ubuntu-core-initramfs seems to be only available on ubuntu-20.04 diff --git a/tests/retry/task.yaml b/tests/retry/task.yaml index d17122dd908..d0b329c2083 100644 --- a/tests/retry/task.yaml +++ b/tests/retry/task.yaml @@ -1,5 +1,9 @@ summary: smoke test for the retry tool +details: | + Check the retry tool allows retrying a command. Verify that on + failure the exit code from the final attempt is returned + backends: [google] execute: | diff --git a/tests/snaps.cleanup/task.yaml b/tests/snaps.cleanup/task.yaml index 97b34fae7fc..380c455bdb0 100644 --- a/tests/snaps.cleanup/task.yaml +++ b/tests/snaps.cleanup/task.yaml @@ -1,5 +1,10 @@ summary: smoke test for the snaps.cleanup tool +details: | + Check the snaps.cleanup tool handles properly the + removal of the installed snaps in the current system. + The test also verifies the fundamental snaps are not removed + backends: [google] systems: [ubuntu-16.04-64, ubuntu-18.04-64, ubuntu-20.04-64, ubuntu-22.04-64] diff --git a/tests/snaps.name/task.yaml b/tests/snaps.name/task.yaml index 5078eddc2a0..45e9deae1a9 100644 --- a/tests/snaps.name/task.yaml +++ b/tests/snaps.name/task.yaml @@ -1,5 +1,10 @@ summary: smoke test for the snaps.name tool +details: | + Check the snaps.name tool properly retrieves the names of the + gadget and kernel snaps installed in the system. Also verifies + the snap-suffix command works properly. + backends: [google] execute: | @@ -10,4 +15,16 @@ execute: | test -z "$(snaps.name kernel)" test "$(snaps.name core)" = "core" + if os.query is-core18; then + test "$(snaps.name snap-suffix)" = "-core18" + elif os.query is-core20; then + test "$(snaps.name snap-suffix)" = "-core20" + elif os.query is-core22; then + test "$(snaps.name snap-suffix)" = "-core22" + elif os.query is-core24; then + test "$(snaps.name snap-suffix)" = "-core24" + else + test -z "$(snaps.name snap-suffix)" + fi + snaps.name my-snap 2>&1 | MATCH "snaps.name: unknown snap my-snap" diff --git a/tests/spread-filter/HACKING.md b/tests/spread-filter/HACKING.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/README.md b/tests/spread-filter/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/res b/tests/spread-filter/res new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/tests/spread-filter/res @@ -0,0 +1 @@ + diff --git a/tests/spread-filter/rules.yaml b/tests/spread-filter/rules.yaml new file mode 100644 index 00000000000..e8532b2e7d5 --- /dev/null +++ b/tests/spread-filter/rules.yaml @@ -0,0 +1,33 @@ +rules: + tests: + from: + - tests/main/.* + - tests/core/.* + - tests/nested/.* + - tests/completion/.* + - tests/cross/.* + - tests/perf/.* + - tests/regression/.* + - tests/smoke/. + - tests/unit/.* + - tests/upgrade/.* + to: [$SELF] + + nested: + from: [tests/lib/nested.sh] + to: [tests/nested/] + + unit: + from: [.*_test.go] + to: + - tests/unit/go + - tests/unit/c-unit-tests-clang + - tests/unit/c-unit-tests-gcc + + docs: + from: [.*.md] + to: [$NONE] + + rest: + from: [.*] + to: [tests/] diff --git a/tests/spread-filter/source/file1 b/tests/spread-filter/source/file1 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/file2 b/tests/spread-filter/source/file2 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib1/file3 b/tests/spread-filter/source/lib1/file3 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib1/lib1 b/tests/spread-filter/source/lib1/lib1 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib1/lib1_test.py b/tests/spread-filter/source/lib1/lib1_test.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib1/task.yaml b/tests/spread-filter/source/lib1/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/source/lib1/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/source/lib2/lib2 b/tests/spread-filter/source/lib2/lib2 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib2/lib2_test.py b/tests/spread-filter/source/lib2/lib2_test.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/source/lib2/lib2_test.py.back b/tests/spread-filter/source/lib2/lib2_test.py.back new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/task.yaml b/tests/spread-filter/task.yaml new file mode 100644 index 00000000000..38b3f81ee51 --- /dev/null +++ b/tests/spread-filter/task.yaml @@ -0,0 +1,91 @@ +summary: test for the spread-filter utility + +details: | + Check that the spread-filter utility properly retrieves the list of tests + to execute, following the rules defined for the project and based on a + set of changes. + +backends: [google] + +systems: [ubuntu-22.04-64] + +execute: | + spread-filter --help | MATCH 'usage: spread-filter' + spread-filter -h | MATCH 'usage: spread-filter' + + # Scenario: 1 test changed + spread-filter -r rules.yaml -p google:ubuntu-22.04-64 -c tests/main/test1/task.yaml > res + MATCH "^google:ubuntu-22.04-64:tests/main/test1$" < res + + # Scenario: 2 tests changed + spread-filter -r rules.yaml -p google:ubuntu -c tests/main/test1/task.yaml -c tests/core/test1/task.yaml > res + MATCH "^google:ubuntu:tests/main/test1 google:ubuntu:tests/core/test1$" < res + + # Scenario: 2 files on the same test dir + spread-filter -r rules.yaml -p google:ubuntu -c tests/core/test2/task.yaml -c tests/core/test2/otherfile.py > res + MATCH "^google:ubuntu:tests/core/test2$" < res + + # Scenario: 2 files on the same test dir but 1 file does not exist (deleted) + spread-filter -r rules.yaml -p google:ubuntu -c tests/core/test2/task.yaml -c tests/core/test2/noexist > res + MATCH "^google:ubuntu:tests/core/test2$" < res + + # Scenario: 3 files on the same test dir but 2 files are in subdir and 1 file does not exist (deleted) + spread-filter -r rules.yaml -p google:ubuntu -c tests/main/test2/otherfile -c tests/main/test2/snap/bin/sh -c tests/main/test2/snap/meta/noexist > res + MATCH "^google:ubuntu:tests/main/test2$" < res + + # Scenario: 1 file and 1 subdirectory changed + spread-filter -r rules.yaml -p google:ubuntu -c tests/main/test2/otherfile -c tests/main/test2/snap > res + MATCH "^google:ubuntu:tests/main/test2$" < res + + # Scenario: 1 test and other file changed (check just the big run survives) + spread-filter -r rules.yaml -p google:ubuntu -c tests/main/test2/task.yaml -c source/lib1/lib1 > res + MATCH "^google:ubuntu:tests/$" < res + + # Scenario: 2 unit tests changed + spread-filter -r rules.yaml -p google:ubuntu -c source/lib1/lib1_test.go -c source/lib2/lib2_test.go > res + MATCH "^google:ubuntu:tests/unit/c-unit-tests-clang google:ubuntu:tests/unit/c-unit-tests-gcc google:ubuntu:tests/unit/go$" < res + + # Scenario: 1 unit tests and 1 test changed + spread-filter -r rules.yaml -p google:ubuntu -c source/lib1/lib1_test.go -c tests/main/test1/noexist.go > res + MATCH "^google:ubuntu:tests/unit/c-unit-tests-clang google:ubuntu:tests/unit/c-unit-tests-gcc google:ubuntu:tests/main/test1 google:ubuntu:tests/unit/go$" < res + + # Scenario: a doc file changed + spread-filter -r rules.yaml -p google:ubuntu -c README.md > res + test "$(wc -w < res)" -eq 0 + + # Scenario: a doc file which does not exist changed (deleted) + spread-filter -r rules.yaml -p google:ubuntu -c DELETED.md > res + test "$(wc -w < res)" -eq 0 + + # Scenario: a doc file and a the nested library changed + spread-filter -r rules.yaml -p google:ubuntu -c README.md -c tests/lib/nested.sh > res + MATCH "^google:ubuntu:tests/nested/$" < res + + # Scenario: 1 test and also another which is substring of previous one changed + spread-filter -r rules.yaml -p google:ubuntu -c README.md -c tests/main/test1/task.yaml -c tests/main/test1b/task.yaml > res + MATCH "^google:ubuntu:tests/main/test1b google:ubuntu:tests/main/test1$" < res + + # Scenario: a file in the test suite but not in a test dir changed + spread-filter -r rules.yaml -p google:ubuntu -c tests/core/other/lib1 > res + test "$(wc -w < res)" -eq 0 + + # Scenario: the nested lib and a nested test are changed (check the test is cleaned) + spread-filter -r rules.yaml -p google:ubuntu -c tests/lib/nested.sh -c tests/nested/test1/task.yaml > res + MATCH "^google:ubuntu:tests/nested/$" < res + + # Scenario: the nested lib, a source file and a nested test are changed (check just tests/ survives) + spread-filter -r rules.yaml -p google:ubuntu -c tests/lib/nested.sh -c source/lib1/lib1 -c tests/nested/test1/task.yaml > res + MATCH "^google:ubuntu:tests/$" < res + + # Scenario: check -v parameter works + spread-filter -r rules.yaml -p google:ubuntu -c tests/lib/nested.sh -v > res + MATCH "cleaning executions" < res + + # Scenario: check mandatory parameters + ARG_TEXT="spread-filter: error: the following arguments are required" + spread-filter -r rules.yaml -c tests/lib/nested.sh 2>&1 | MATCH "$ARG_TEXT" + spread-filter -p google:ubuntu -c tests/lib/nested.sh 2>&1 | MATCH "$ARG_TEXT" + + # Scenario: check the rules file + FILE_TEXT="spread-filter: rules file 'noexist.yaml' does not exist" + spread-filter -r noexist.yaml -p google:ubuntu -c tests/lib/nested.sh 2>&1 | MATCH "$FILE_TEXT" diff --git a/tests/spread-filter/tests/core/other/lib1 b/tests/spread-filter/tests/core/other/lib1 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/core/other/lib2 b/tests/spread-filter/tests/core/other/lib2 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/core/test1/helper.py b/tests/spread-filter/tests/core/test1/helper.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/core/test1/task.yaml b/tests/spread-filter/tests/core/test1/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/core/test1/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/core/test2/otherfile.py b/tests/spread-filter/tests/core/test2/otherfile.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/core/test2/task.yaml b/tests/spread-filter/tests/core/test2/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/core/test2/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/lib/lib1.sh b/tests/spread-filter/tests/lib/lib1.sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/lib2.sh b/tests/spread-filter/tests/lib/lib2.sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/nested.sh b/tests/spread-filter/tests/lib/nested.sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/tools/suite/test1/helper.sh b/tests/spread-filter/tests/lib/tools/suite/test1/helper.sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/tools/suite/test1/task.yaml b/tests/spread-filter/tests/lib/tools/suite/test1/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/lib/tools/suite/test1/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/lib/tools/suite/test2/snap/bin/sh b/tests/spread-filter/tests/lib/tools/suite/test2/snap/bin/sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/tools/suite/test2/snap/meta/snap.yaml b/tests/spread-filter/tests/lib/tools/suite/test2/snap/meta/snap.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/tools/suite/test2/snap/otherfile b/tests/spread-filter/tests/lib/tools/suite/test2/snap/otherfile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/lib/tools/suite/test2/task.yaml b/tests/spread-filter/tests/lib/tools/suite/test2/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/lib/tools/suite/test2/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/main/test1/task.yaml b/tests/spread-filter/tests/main/test1/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/main/test1/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/main/test11/task.yaml b/tests/spread-filter/tests/main/test11/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/main/test11/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/main/test1b/logs/log1.txt b/tests/spread-filter/tests/main/test1b/logs/log1.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/main/test1b/logs/log2.txt b/tests/spread-filter/tests/main/test1b/logs/log2.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/main/test1b/task.yaml b/tests/spread-filter/tests/main/test1b/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/main/test1b/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/main/test2/snap/bin/sh b/tests/spread-filter/tests/main/test2/snap/bin/sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/main/test2/snap/meta/snap.yaml b/tests/spread-filter/tests/main/test2/snap/meta/snap.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/main/test2/snap/otherfile b/tests/spread-filter/tests/main/test2/snap/otherfile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/main/test2/task.yaml b/tests/spread-filter/tests/main/test2/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/main/test2/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/nested/test1/task.yaml b/tests/spread-filter/tests/nested/test1/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/nested/test1/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/nested/test2/snap/bin/sh b/tests/spread-filter/tests/nested/test2/snap/bin/sh new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/nested/test2/snap/meta/snap.yaml b/tests/spread-filter/tests/nested/test2/snap/meta/snap.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/nested/test2/snap/otherfile b/tests/spread-filter/tests/nested/test2/snap/otherfile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-filter/tests/nested/test2/task.yaml b/tests/spread-filter/tests/nested/test2/task.yaml new file mode 100644 index 00000000000..ef424a8b447 --- /dev/null +++ b/tests/spread-filter/tests/nested/test2/task.yaml @@ -0,0 +1,6 @@ +summary: test file + +details: test file + +execute: | + echo "works" diff --git a/tests/spread-filter/tests/nested/test2/task.yaml.old b/tests/spread-filter/tests/nested/test2/task.yaml.old new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/spread-manager/checks/task1/task.yaml b/tests/spread-manager/checks/task1/task.yaml index df2d11f370e..a2a5929892a 100644 --- a/tests/spread-manager/checks/task1/task.yaml +++ b/tests/spread-manager/checks/task1/task.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: test + prepare: | echo "preparing" diff --git a/tests/spread-manager/checks/task2/task.yaml b/tests/spread-manager/checks/task2/task.yaml index 047716317b1..7ae94af14f7 100644 --- a/tests/spread-manager/checks/task2/task.yaml +++ b/tests/spread-manager/checks/task2/task.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: test + manual: false prepare: | diff --git a/tests/spread-manager/checks/task3/task.yaml b/tests/spread-manager/checks/task3/task.yaml index 896d23d798f..02a2c23fb0b 100644 --- a/tests/spread-manager/checks/task3/task.yaml +++ b/tests/spread-manager/checks/task3/task.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: test + manual: true prepare: | diff --git a/tests/spread-manager/checks/task4/task.yaml b/tests/spread-manager/checks/task4/task.yaml index e64e4c94626..8941e006ce7 100644 --- a/tests/spread-manager/checks/task4/task.yaml +++ b/tests/spread-manager/checks/task4/task.yaml @@ -1,5 +1,7 @@ summary: this is the summary +details: test + #manual: true prepare: | diff --git a/tests/spread-manager/task.yaml b/tests/spread-manager/task.yaml index b3f115ab4ab..817a08fe005 100644 --- a/tests/spread-manager/task.yaml +++ b/tests/spread-manager/task.yaml @@ -1,5 +1,9 @@ summary: smoke test for the spread-manager tool +details: | + Check the spread-manager tool allows setting a list of tests as manual. + Also checks manual tag can be removed for a list of tests. + backends: [google] systems: [ ubuntu-20.04-64 ] diff --git a/tests/spread-shellcheck/task.yaml b/tests/spread-shellcheck/task.yaml index 51037cac4af..bcbdb1ddfd7 100644 --- a/tests/spread-shellcheck/task.yaml +++ b/tests/spread-shellcheck/task.yaml @@ -1,5 +1,11 @@ summary: smoke test for the spread-shellcheck tool +details: | + Check the spread-shellcheck properly runs the shellcheck + tool in all the sections of the spread tasks. Also check the + tool can run in a directory tree and skips checks when + it finds "shellcheck disable". + backends: [google] systems: [ ubuntu-20.04-64 ] diff --git a/tests/tests.backup/task.yaml b/tests/tests.backup/task.yaml index 43f65d04d04..140abeb0add 100644 --- a/tests/tests.backup/task.yaml +++ b/tests/tests.backup/task.yaml @@ -1,5 +1,9 @@ summary: tests for the tests.backup tool +details: | + Check the tests.backup tool properly backs up and + restores a specific directory. + backends: [google] execute: | diff --git a/tests/tests.cleanup/task.yaml b/tests/tests.cleanup/task.yaml index d753eb0f3f9..d230365e713 100644 --- a/tests/tests.cleanup/task.yaml +++ b/tests/tests.cleanup/task.yaml @@ -1,5 +1,9 @@ summary: tests for the tests.cleanup tool +details: | + Check the tests.cleanup tool allows to defer, pop and + restore commands in tests. + backends: [google] systems: [ubuntu-18.04-64] diff --git a/tests/tests.pkgs/task.yaml b/tests/tests.pkgs/task.yaml index b4573913c27..e3d5f96453d 100644 --- a/tests/tests.pkgs/task.yaml +++ b/tests/tests.pkgs/task.yaml @@ -1,5 +1,10 @@ summary: Smoke test for tests.pkgs tool +details: | + Check the tests.pkgs tool allows managing native packages independently + of the system being used. Verify that packages can be installed, queried + and removed among other operations. + backends: [google] execute: | @@ -10,11 +15,9 @@ execute: | # pkgs tool presents the usage screen when invoked without arguments # or with the -h or --help options. - tests.pkgs | MATCH 'usage: tests.pkgs {install,remove} \[PACKAGE...\]' - tests.pkgs -h | MATCH 'usage: tests.pkgs {install,remove} \[PACKAGE...\]' - tests.pkgs --help | MATCH 'usage: tests.pkgs {install,remove} \[PACKAGE...\]' - - # Update the packages db + tests.pkgs | MATCH 'usage: tests.pkgs install \[--no-install-recommends\] \[PACKAGE...\]' + tests.pkgs -h | MATCH 'usage: tests.pkgs install \[--no-install-recommends\] \[PACKAGE...\]' + tests.pkgs --help | MATCH 'usage: tests.pkgs install \[--no-install-recommends\] \[PACKAGE...\]' # Check the test pkg is not installed not tests.pkgs is-installed test-snapd-pkg-1 @@ -29,6 +32,11 @@ execute: | tests.pkgs query test-snapd-pkg-1 not tests.pkgs is-installed test-snapd-pkg-1 + # Install a package with --no-install-recommends option + tests.pkgs install --no-install-recommends test-snapd-pkg-1 + tests.pkgs query test-snapd-pkg-1 + tests.pkgs remove test-snapd-pkg-1 + # Install 2 test pkgs and check they are is installed tests.pkgs install test-snapd-pkg-1 test-snapd-pkg-2 tests.pkgs is-installed test-snapd-pkg-1 @@ -39,7 +47,25 @@ execute: | not tests.pkgs is-installed test-snapd-pkg-1 not tests.pkgs is-installed test-snapd-pkg-2 + # Download curl package, trusty does not support apt download + if not os.query is-trusty; then + tests.pkgs download curl + if os.query is-opensuse; then + find . -maxdepth 4 -name 'curl.*' + else + find . -maxdepth 1 -name 'curl.*' + fi + fi + # Check the message when a command is not supported tests.pkgs noexist test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown command noexist' tests.pkgs -install test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown option -install' + # Install the test package, verify its installation and query it + # Run this only on amd64 and skip Trusty + if ( os.query is-debian || os.query is-ubuntu-ge 1604 ) && os.query is-pc-amd64 ; then + dpkg --add-architecture i386 + tests.pkgs install test-snapd-pkg-3 + tests.pkgs is-installed test-snapd-pkg-3 + tests.pkgs remove test-snapd-pkg-3 + fi diff --git a/tests/tests.systemd/task.yaml b/tests/tests.systemd/task.yaml index b6144b354f4..b8d3d3f2e84 100644 --- a/tests/tests.systemd/task.yaml +++ b/tests/tests.systemd/task.yaml @@ -1,11 +1,16 @@ summary: smoke test for the tests.systemd tool +details: | + Check the tests.systemd properly manages systemd services. + Verify the tool is able to create units, wait for status and + stop units. + backends: [google] systems: [-ubuntu-14.04-64] restore: | - tests.systemd stop-and-remove-unit my-test || true + tests.systemd stop-unit --remove my-test execute: | tests.systemd | MATCH 'usage: tests.systemd create-and-start-unit' @@ -15,30 +20,50 @@ execute: | # check a simple unit tests.systemd create-and-start-unit my-test "/bin/sleep 500" systemctl is-active my-test - tests.systemd stop-and-remove-unit my-test + tests.systemd stop-unit --remove my-test not systemctl is-active my-test # check the wait-for-service works when unit is inactive tests.systemd create-and-start-unit my-test "/bin/sleep 5" - tests.systemd wait-for-service my-test active - tests.systemd wait-for-service my-test inactive - tests.systemd stop-and-remove-unit my-test + tests.systemd wait-for-service --state active my-test + tests.systemd wait-for-service --state inactive my-test + tests.systemd stop-unit --remove my-test systemctl list-unit-files | NOMATCH my-test + # check the wait-for-service works when unit is inactive + tests.systemd create-and-start-unit my-test "/bin/sleep 10" + tests.systemd wait-for-service --state active my-test + not tests.systemd wait-for-service --state inactive --wait 1 -n 3 my-test + tests.systemd wait-for-service --state inactive --wait 2 --attempts 5 my-test + tests.systemd stop-unit --remove my-test + systemctl list-unit-files | NOMATCH my-test + + # Check stop-unit + tests.systemd create-and-start-unit my-test-1 "/bin/sleep 10" + tests.systemd create-and-start-unit my-test-2 "/bin/sleep 10" + tests.systemd stop-unit my-test-1 my-test-2 + not systemctl is-active my-test-1 + not systemctl is-active my-test-2 + systemctl is-enabled my-test-1 + systemctl is-enabled my-test-2 + tests.systemd stop-unit --remove my-test-1 my-test-2 + not systemctl is-enabled my-test-1 + not systemctl is-enabled my-test-2 + # check missing parameters and start twice the same unit tests.systemd create-and-start-unit 2>&1 | MATCH "tests.systemd: unit name cannot be empty" tests.systemd create-and-start-unit my-test 2>&1 | MATCH "tests.systemd: unit command line cannot be empty" tests.systemd create-and-start-unit my-test "/bin/sleep 5" - tests.systemd create-and-start-unit my-test "/bin/sleep 5" 2>&1 | MATCH "tests.systemd: unit service file already exist" - tests.systemd stop-and-remove-unit 2>&1 | MATCH "tests.systemd: unit name cannot be empty" - tests.systemd stop-and-remove-unit 2>&1 | MATCH "tests.systemd: unit name cannot be empty" - tests.systemd stop-and-remove-unit my-test + tests.systemd create-and-start-unit my-test "/bin/sleep 5" | MATCH "tests.systemd: unit service file already exist, it is going to be overwritten" + tests.systemd stop-unit 2>&1 | MATCH "tests.systemd: at least a unit name is required" + tests.systemd stop-unit --remove 2>&1 | MATCH "tests.systemd: at least a unit name is required" + tests.systemd stop-unit --remove my-test # check unit override tests.systemd create-and-start-unit my-test "/bin/sleep 100" "[Unit]\nAfter=foo" systemctl cat my-test | MATCH "^ExecStart=/bin/sleep 100$" systemctl cat my-test | MATCH "^After=foo$" - tests.systemd stop-and-remove-unit my-test + tests.systemd stop-unit --remove my-test # check a unit can be removed when it already was removed - tests.systemd stop-and-remove-unit my-test + tests.systemd stop-unit --remove my-test diff --git a/tools/os.query b/tools/os.query index 5ae9c0398b2..0692560d121 100755 --- a/tools/os.query +++ b/tools/os.query @@ -3,8 +3,9 @@ show_help() { echo "usage: os.query is-core, is-classic" echo " os.query is-core16, is-core18, is-core20, is-core22, is-core24" - echo " os.query is-trusty, is-xenial, is-bionic, is-focal, is-jammy" - echo " os.query is-ubuntu [ID], is-debian [ID], is-fedora [ID], is-amazon-linux, is-arch-linux, is-centos [ID], is-opensuse [ID]" + echo " os.query is-core-gt, is-core-ge, is-core-lt, is-core-le" + echo " os.query is-trusty, is-xenial, is-bionic, is-focal, is-jammy, is-noble" + echo " os.query is-ubuntu [ID], is-debian [ID], is-fedora [ID], is-amazon-linux [ID], is-arch-linux, is-centos [ID], is-opensuse [ID]" echo " os.query is-ubuntu-gt [ID], is-ubuntu-ge [ID], is-ubuntu-lt [ID], is-ubuntu-le [ID]" echo " os.query is-pc-amd64, is-pc-i386, is-arm, is-armhf, is-arm64, is-s390x" echo "" @@ -12,63 +13,67 @@ show_help() { } is_core() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release - fi + grep -qFx 'ID=ubuntu-core' /etc/os-release } is_core16() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-16-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="16"' /etc/os-release - fi + grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="16"' /etc/os-release } is_core18() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-18-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="18"' /etc/os-release - fi + grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="18"' /etc/os-release } is_core20() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-20-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="20"' /etc/os-release - fi + grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="20"' /etc/os-release } is_core22() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-22-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="22"' /etc/os-release - fi + grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="22"' /etc/os-release } is_core24() { - # We need to check $SPREAD_SYSTEM var because in snapd the os-release file does - # not contain the ubuntu-core info while the system is being prepared - if [ -n "$SPREAD_SYSTEM" ]; then - [[ "$SPREAD_SYSTEM" == ubuntu-core-24-* ]] - else - grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="24"' /etc/os-release + grep -qFx 'ID=ubuntu-core' /etc/os-release && grep -qFx 'VERSION_ID="24"' /etc/os-release +} + +is_core_gt() { + local VERSION=$1 + if [ -z "$VERSION" ]; then + echo "os.query: version id is expected" + exit 1 fi + + is_core && compare_ubuntu "$VERSION" "-gt" +} + +is_core_ge() { + local VERSION=$1 + if [ -z "$VERSION" ]; then + echo "os.query: version id is expected" + exit 1 + fi + + is_core && compare_ubuntu "$VERSION" "-ge" +} + +is_core_lt() { + local VERSION=$1 + if [ -z "$VERSION" ]; then + echo "os.query: version id is expected" + exit 1 + fi + + is_core && compare_ubuntu "$VERSION" "-lt" +} + +is_core_le() { + local VERSION=$1 + if [ -z "$VERSION" ]; then + echo "os.query: version id is expected" + exit 1 + fi + + is_core && compare_ubuntu "$VERSION" "-le" } is_classic() { @@ -95,6 +100,10 @@ is_jammy() { grep -qFx 'UBUNTU_CODENAME=jammy' /etc/os-release } +is_noble() { + grep -qFx 'UBUNTU_CODENAME=noble' /etc/os-release +} + is_ubuntu() { VERSION=$1 if [ -z "$VERSION" ]; then @@ -105,19 +114,19 @@ is_ubuntu() { } is_ubuntu_gt() { - compare_ubuntu "${1:-}" "-gt" + is_classic && compare_ubuntu "${1:-}" "-gt" } is_ubuntu_ge() { - compare_ubuntu "${1:-}" "-ge" + is_classic && compare_ubuntu "${1:-}" "-ge" } is_ubuntu_lt() { - compare_ubuntu "${1:-}" "-lt" + is_classic && compare_ubuntu "${1:-}" "-lt" } is_ubuntu_le() { - compare_ubuntu "${1:-}" "-le" + is_classic && compare_ubuntu "${1:-}" "-le" } compare_ubuntu() { @@ -129,7 +138,7 @@ compare_ubuntu() { exit 1 fi - if ! grep -qFx 'ID=ubuntu' /etc/os-release; then + if ! grep -q 'ID=ubuntu' /etc/os-release; then echo "os.query: comparing non ubuntu system" return 1 fi @@ -151,7 +160,6 @@ compare_ubuntu() { test "$SYS_VERSION" "$OPERAND" "$NUM_VERSION" } - is_debian() { VERSION=$1 if [ -z "$VERSION" ]; then @@ -183,7 +191,12 @@ is_fedora() { } is_amazon_linux() { - grep -qFx 'ID="amzn"' /etc/os-release + VERSION=$1 + if [ -z "$VERSION" ]; then + grep -qFx 'ID="amzn"' /etc/os-release + else + grep -qFx 'ID="amzn"' /etc/os-release && grep -qFx "VERSION_ID=\"$VERSION\"" /etc/os-release + fi } is_centos() { diff --git a/tools/quiet b/tools/quiet new file mode 100755 index 00000000000..48c1f2aa1e5 --- /dev/null +++ b/tools/quiet @@ -0,0 +1,32 @@ +#!/bin/bash + +# use "quiet foo" when you expect "foo" to produce a lot of output +# that isn't useful unless foo itself fails. +quiet() ( + # note this is a subshell (parens instead of braces around the function) + # so this set only affects this function and not the caller + { set +x; } >&/dev/null + + # not strictly needed because it's a subshell, but good practice + local tf retval + + tf="$(mktemp)" + + set +e + "$@" >& "$tf" + retval=$? + set -e + + if [ "$retval" != "0" ]; then + echo "quiet: $*" >&2 + echo "quiet: exit status $retval. Output follows:" >&2 + cat "$tf" >&2 + echo "quiet: end of output." >&2 + fi + + rm -f -- "$tf" + + return $retval +) + +quiet "$@" diff --git a/tools/snaps.name b/tools/snaps.name index f75e79482d6..e562e9266e9 100755 --- a/tools/snaps.name +++ b/tools/snaps.name @@ -1,7 +1,7 @@ #!/bin/bash show_help() { - echo "usage: snaps.name gadget, kernel, core" + echo "usage: snaps.name gadget, kernel, core, snap-suffix" echo "" echo "get the name of a specific snap for the current system" } @@ -25,6 +25,18 @@ core_name(){ echo "$core_name" } +snap_suffix(){ + if os.query is-core18; then + echo "-core18" + elif os.query is-core20; then + echo "-core20" + elif os.query is-core22; then + echo "-core22" + elif os.query is-core24; then + echo "-core24" + fi +} + main() { if [ $# -eq 0 ]; then show_help @@ -49,6 +61,10 @@ main() { core_name exit ;; + snap-suffix) + snap_suffix + exit + ;; *) echo "snaps.name: unknown snap $1" >&2 exit 1 diff --git a/tools/tests.pkgs b/tools/tests.pkgs index 97677e09fb6..89c51a7a3a3 100755 --- a/tools/tests.pkgs +++ b/tools/tests.pkgs @@ -1,8 +1,12 @@ #!/bin/bash -e show_help() { - echo "usage: tests.pkgs {install,remove} [PACKAGE...]" - echo " tests.pkgs {is-installed,query} [PACKAGE]" + echo "usage: tests.pkgs install [--no-install-recommends] [PACKAGE...]" + echo " tests.pkgs remove [PACKAGE...]" + echo " tests.pkgs download [PACKAGE...]" + echo " tests.pkgs is-installed [PACKAGE]" + echo " tests.pkgs query [PACKAGE]" + echo " tests.pkgs list-installed" echo echo "Package names are standardized based on Debian package names" echo "internally, package names are re-mapped to fit the convention" @@ -19,6 +23,16 @@ cmd_install() { unsupported } +cmd_install_local() { + # This is re-defined by the backend file. + unsupported +} + +cmd_download() { + # This is re-defined by the backend file. + unsupported +} + cmd_is_installed() { # This is re-defined by the backend file. unsupported @@ -112,7 +126,7 @@ main() { shift break ;; - install|remove|query|is-installed|list-installed) + install|remove|query|is-installed|list-installed|download) action="$1" shift break # consume remaining arguments @@ -130,7 +144,8 @@ main() { case "$action" in install) - cmd_install "$(remap_many "$@")" + # shellcheck disable=SC2046 + cmd_install $(remap_many "$@") ;; is-installed) cmd_is_installed "$(remap_one "$@")" @@ -142,7 +157,11 @@ main() { cmd_list_installed ;; remove) - cmd_remove "$(remap_many "$@")" + # shellcheck disable=SC2046 + cmd_remove $(remap_many "$@") + ;; + download) + cmd_download "$(remap_many "$@")" ;; *) echo "tests.pkgs: unknown action $action" >&2 diff --git a/tools/tests.pkgs.apt.sh b/tools/tests.pkgs.apt.sh index 71d2a539417..b0814dd5ab3 100644 --- a/tools/tests.pkgs.apt.sh +++ b/tools/tests.pkgs.apt.sh @@ -22,6 +22,15 @@ remap_one() { test-snapd-pkg-2) echo "robotfindskitten" ;; + test-snapd-pkg-3) + if os.query is-debian || os.query is-trusty; then + echo cpp:i386 + elif os.query is-xenial || os.query is-bionic; then + echo cpp-5:i386 + else + echo cpp-9:i386 + fi + ;; *) echo "$1" ;; @@ -29,34 +38,48 @@ remap_one() { } cmd_install() { - set -x apt-get update - # shellcheck disable=SC2068 - apt-get install --yes $@ - set +x + + local APT_FLAGS="--yes" + while [ -n "$1" ]; do + case "$1" in + --no-install-recommends) + APT_FLAGS="$APT_FLAGS --no-install-recommends" + shift + ;; + *) + break + ;; + esac + done + # shellcheck disable=SC2086 + apt-get install $APT_FLAGS "$@" } cmd_is_installed() { - set -x - dpkg -S "$1" >/dev/null 2>&1 - set +x + dpkg -l "$1" | grep -E "ii +$1" >/dev/null 2>&1 } cmd_query() { - set -x apt-cache policy "$1" - set +x } cmd_list_installed() { - set -x - apt list --installed | cut -d/ -f1 | sort - set +x + apt list --installed | cut -d ' ' -f 1,3 | sed -e 's@/.*\s@:@g' | sort } cmd_remove() { - set -x - # shellcheck disable=SC2068 - apt-get remove --yes $@ - set +x + # Allow removing essential packages, that may get installed when using i386 + # packages on amd64 system. Normally they would be really essential but in + # this case they are not really as essential. + local REMOVE_FLAGS="--allow-remove-essential" + if os.query is-trusty; then + REMOVE_FLAGS="" + fi + # shellcheck disable=SC2086 + apt-get remove --yes $REMOVE_FLAGS "$@" +} + +cmd_download() { + apt download $@ >/dev/null 2>&1 } diff --git a/tools/tests.pkgs.dnf-yum.sh b/tools/tests.pkgs.dnf-yum.sh index 2e83610e7b2..cbf1c9e2f7a 100644 --- a/tools/tests.pkgs.dnf-yum.sh +++ b/tools/tests.pkgs.dnf-yum.sh @@ -27,45 +27,58 @@ remap_one() { } cmd_install() { - set -x - # shellcheck disable=SC2068 - if [ "$(command -v dnf)" != "" ]; then - dnf install -y $@ - else - yum install -y $@ + local CMD="dnf" + if [ -z "$(command -v dnf)" ]; then + CMD="yum" fi - set +x + local DNF_YUM_FLAGS="-y" + + while [ -n "$1" ]; do + case "$1" in + --no-install-recommends) + DNF_YUM_FLAGS="$DNF_YUM_FLAGS --setopt=install_weak_deps=False" + shift + ;; + *) + break + ;; + esac + done + + # shellcheck disable=SC2068,SC2086 + $CMD install $DNF_YUM_FLAGS $@ } cmd_is_installed() { - set -x rpm -qi "$1" >/dev/null 2>&1 - set +x } cmd_query() { - set -x if [ "$(command -v dnf)" != "" ]; then dnf info "$1" else yum info "$1" fi - set +x } cmd_list_installed() { - set -x rpm -qa | sort - set +x } cmd_remove() { - set -x # shellcheck disable=SC2068 if [ "$(command -v dnf)" != "" ]; then dnf remove -y $@ else yum remove -y $@ fi - set +x +} + +cmd_download() { + # shellcheck disable=SC2068 + if [ "$(command -v dnf)" != "" ]; then + dnf download $@ >/dev/null 2>&1 + else + yum reinstall --downloadonly $@ >/dev/null 2>&1 + fi } diff --git a/tools/tests.pkgs.pacman.sh b/tools/tests.pkgs.pacman.sh index d6c71e620b3..5de68ecc73f 100644 --- a/tools/tests.pkgs.pacman.sh +++ b/tools/tests.pkgs.pacman.sh @@ -25,7 +25,7 @@ remap_one() { echo "python-gobject" ;; test-snapd-pkg-1) - echo "curseofwar" + echo "cmus" ;; test-snapd-pkg-2) echo "robotfindskitten" @@ -37,33 +37,39 @@ remap_one() { } cmd_install() { - set -x - # shellcheck disable=SC2068 - pacman -S --noconfirm $@ - set +x + local PACMAN_FLAGS="--noconfirm" + while [ -n "$1" ]; do + case "$1" in + --no-install-recommends) + # Pacman only ever installs the required dependencies + shift + ;; + *) + break + ;; + esac + done + # shellcheck disable=SC2068,SC2086 + pacman -S $PACMAN_FLAGS $@ } cmd_is_installed() { - set -x pacman -Qi "$1" >/dev/null 2>&1 - set +x } cmd_query() { - set -x pacman -Si "$1" - set +x } cmd_list_installed() { - set -x pacman -Qe | awk '{ print $1 }' | sort - set +x } cmd_remove() { - set -x # shellcheck disable=SC2068 pacman -Rnsc --noconfirm $@ - set +x +} + +cmd_download() { + pacman -Sw --noconfirm --cachedir "${PWD:-.}" $@ >/dev/null 2>&1 } diff --git a/tools/tests.pkgs.zypper.sh b/tools/tests.pkgs.zypper.sh index 1475c9ff4f5..688c66ae52d 100644 --- a/tools/tests.pkgs.zypper.sh +++ b/tools/tests.pkgs.zypper.sh @@ -31,33 +31,40 @@ remap_one() { } cmd_install() { - set -x - # shellcheck disable=SC2068 - zypper install -y $@ - set +x + local ZYPPER_FLAGS="-y" + while [ -n "$1" ]; do + case "$1" in + --no-install-recommends) + ZYPPER_FLAGS="$ZYPPER_FLAGS --no-recommends" + shift + ;; + *) + break + ;; + esac + done + + # shellcheck disable=SC2068,SC2086 + zypper install $ZYPPER_FLAGS $@ } cmd_is_installed() { - set -x rpm -qi "$1" >/dev/null 2>&1 - set +x } cmd_query() { - set -x zypper info "$1" - set +x } cmd_list_installed() { - set -x rpm -qa | sort - set +x } cmd_remove() { - set -x # shellcheck disable=SC2068 zypper remove -y $@ - set +x +} + +cmd_download() { + zypper --pkg-cache-dir "${PWD:-.}" download $@ >/dev/null 2>&1 } diff --git a/tools/tests.systemd b/tools/tests.systemd index bf6fc6cd037..fc63338b27c 100755 --- a/tools/tests.systemd +++ b/tools/tests.systemd @@ -2,8 +2,8 @@ show_help() { echo "usage: tests.systemd create-and-start-unit " - echo " tests.systemd stop-and-remove-unit " - echo " tests.systemd wait-for-service " + echo " tests.systemd stop-unit [--remove] ..." + echo " tests.systemd wait-for-service [-n|--attempts retries] [--wait seconds] [--state STATE] " } # Create and start a persistent systemd unit that survives reboots. Use as: @@ -25,15 +25,14 @@ create_and_start_unit() { return 1 fi if [ -f "/etc/systemd/system/$name.service" ]; then - echo "tests.systemd: unit service file already exist" - return 1 + echo "tests.systemd: unit service file already exist, it is going to be overwritten" fi printf '[Unit]\nDescription=Support for test %s\n[Service]\nType=simple\nExecStart=%s\n[Install]\nWantedBy=multi-user.target\n' "$name" "$start_line" > "/etc/systemd/system/$name.service" if [ -n "$override" ]; then mkdir -p "/etc/systemd/system/$name.service.d" # shellcheck disable=SC2059 - printf "$override" >> "/etc/systemd/system/$name.service.d/override.conf" + printf "$override" > "/etc/systemd/system/$name.service.d/override.conf" fi systemctl daemon-reload @@ -42,32 +41,96 @@ create_and_start_unit() { wait_for_service "$name" } -stop_and_remove_unit() { - local name=$1 +_stop_unit() { + local unit=$1 + + if systemctl is-active "$unit"; then + retries=20 + while systemctl status "$unit" | grep -q "Active: activating"; do + if [ $retries -eq 0 ]; then + echo "tests.systemd: unit $unit could not be stopped" + systemctl status "$unit" + exit 1 + fi + retries=$(( retries - 1 )) + sleep 1 + done + + systemctl stop "$unit" + fi +} - if [ -z "$name" ]; then - echo "tests.systemd: unit name cannot be empty" +stop_unit() { + local remove=false + while [ $# -gt 0 ]; do + case "$1" in + --remove) + remove=true + shift + ;; + *) + break + ;; + esac + done + + if [ $# -eq 0 ]; then + echo "tests.systemd: at least a unit name is required" return 1 fi - systemctl stop "$name" || true - systemctl disable "$name" || true + for unit in "$@"; do + _stop_unit "$unit" + if [ "$remove" = true ]; then + if systemctl is-enabled "$unit"; then + systemctl disable "$unit" + fi + rm -f "/etc/systemd/system/$unit.service" + rm -rf "/etc/systemd/system/$unit.service.d" + fi + done - rm -f "/etc/systemd/system/$name.service" - rm -rf "/etc/systemd/system/$name.service.d" systemctl daemon-reload } wait_for_service() { - local service_name="$1" - local state="${2:-active}" + if [ $# -eq 0 ]; then + show_help + exit 0 + fi + + local attempts=300 + local wait=1 + local state="active" + local service_name + + while [ $# -gt 0 ]; do + case "$1" in + --wait) + wait="$2" + shift 2 + ;; + -n|--attempts) + attempts="$2" + shift 2 + ;; + --state) + state="$2" + shift 2 + ;; + *) + service_name=$1 + break + ;; + esac + done if [ -z "$service_name" ]; then echo "tests.systemd: unit name cannot be empty" return 1 fi - for i in $(seq 300); do + for i in $(seq "$attempts"); do if systemctl show -p ActiveState "$service_name" | grep -q "ActiveState=$state"; then return fi @@ -75,7 +138,7 @@ wait_for_service() { if [ "$i" -gt 0 ] && [ $(( i % 60 )) = 0 ]; then systemctl status "$service_name" || true fi - sleep 1 + sleep "$wait" done echo "tests.systemd: service $service_name did not become $state" diff --git a/utils/check-test-format b/utils/check-test-format index 74b28ee9a60..25c85212aa3 100755 --- a/utils/check-test-format +++ b/utils/check-test-format @@ -23,12 +23,13 @@ SUPPORTED_KEYS = [ "warn-timeout", "kill-timeout", "environment", + "artifacts", "prepare", "restore", "debug", "execute", ] -MANDATORY_KEYS = ["summary", "execute"] +MANDATORY_KEYS = ["summary", "details", "execute"] def check_mandatory_keys(task_keys): @@ -92,7 +93,6 @@ def check_task_format(filepath): return True - def check_dir(directory): if not os.path.isdir(directory): print("Format checks failed for directory {}".format(directory)) @@ -106,11 +106,27 @@ def check_dir(directory): return status +def check_tests(tests): + status = True + for test in tests: + if not os.path.isfile(test): + print("Format checks failed for test {}".format(test)) + print(" - The path is not a file") + status = False + continue + + if not check_task_format(test): + status = False + + return status def _make_parser(): parser = argparse.ArgumentParser() parser.add_argument( - "directory", help="path to the directory to check recursively" + "--dir", help="path to the directory to check recursively" + ) + parser.add_argument( + "--tests", help="list of tests path to check", nargs='+' ) return parser @@ -119,8 +135,16 @@ def main(): parser = _make_parser() args = parser.parse_args() - sys.exit(not check_dir(args.directory)) + status = 0 + if args.tests: + if not check_tests(args.tests): + status = 1 + + if args.dir: + if not check_dir(args.dir): + status = 1 + sys.exit(status) if __name__ == "__main__": main() diff --git a/utils/log-analyzer b/utils/log-analyzer index 42b6595704c..79ef43af227 100755 --- a/utils/log-analyzer +++ b/utils/log-analyzer @@ -208,9 +208,9 @@ list_reexecute_tasks() { echo "$exec_exp" return fi - # When all the tests were successful, then the execution expression is used to reexecute + + # When all the tests were successful, then no tests need to be reexecuted if [ "$(echo "$reexec_tasks" | wc -w)" = 0 ]; then - echo "$exec_exp" return fi echo "$reexec_tasks" @@ -258,7 +258,7 @@ list_executed_tasks() { local all_tasks executed_tasks all_tasks="$(list_all_tasks "$exec_exp")" - executed_tasks="$(jq -r '.[] | select( .type == "action") | select( .verb == "Executing") | .task' "$log")" + executed_tasks="$(jq -r '.[] | select( .type == "phase") | select( .verb == "Executing") | .task' "$log")" _intersection_tasks_lists "$executed_tasks" "$all_tasks" } diff --git a/utils/log-filter b/utils/log-filter new file mode 100755 index 00000000000..bb530ff6cf5 --- /dev/null +++ b/utils/log-filter @@ -0,0 +1,208 @@ +#!/usr/bin/env python3 + +import argparse +import io +import re +import sys +import typing + +import log_helper as helper + +# Rules are applied to filter content in the following operation details: +# ERROR: The error shoes the bash output when a task fails +# DEBUG: The debug includes the output of the debug script for task/suite errors +# WARNING: The last lines from the task execution output +# FAILED: Include a list of failed tests in the results section +SUPPORTED_RULES = [helper.Result.FAILED.value] + helper.ExecutionInfo.list() + + +def print_line(line: str) -> None: + if not line: + print() + else: + print(line.strip()) + + +def write_line(line: str, to_stream: typing.TextIO) -> None: + if not line: + print("\n", file=to_stream) + else: + print(line.strip(), file=to_stream, end="\n") + + +def compile_rules(rules: list[str], operation: str) -> list[re.Pattern[str]]: + patterns = [] + regex_list = [] + + for rule in rules: + parts = rule.split("=", 1) + if len(parts) != 2: + raise ValueError( + "Error: Rule '{}' does not follow the OPERATION=PATTERN format".format( + rule + ) + ) + + rule_operation = parts[0] + rule_pattern = parts[1] + + if rule_operation not in SUPPORTED_RULES: + raise ValueError( + "Error: Rule operation '{}' not in supported list: {}".format( + rule_operation, SUPPORTED_RULES + ) + ) + + if operation == rule_operation: + patterns.append(rule_pattern) + + for pattern in patterns: + regex_list.append(re.compile(pattern)) + return regex_list + + +def process_detail_line( + line: str, regex_list: list[re.Pattern[str]], to_stream: typing.TextIO +) -> None: + if not regex_list: + write_line(line, to_stream) + else: + for regex in regex_list: + matches = regex.findall(line) + for match in matches: + write_line(match, to_stream) + + +def process_detail( + from_stream: typing.TextIO, + start_line: str, + regex_list: list[re.Pattern[str]], + to_stream: typing.TextIO, +) -> str: + """Process lines from the start of the details section until the last line, + returns the first line right after the details section + """ + write_line(start_line, to_stream) + for line in sys.stdin: + print_line(line) + + if not line: + continue + + # Check if the detail is finished + if helper.is_detail_finished(line): + return line + + # Print all the lines + process_detail_line(line, regex_list, to_stream) + + return "" + + +def skip_detail(from_stream: typing.TextIO) -> str: + """Skip lines from the start of the details section until the last line, + returns the first line right after the details section + """ + for line in sys.stdin: + print_line(line) + if not line: + continue + + # Check if the detail is finished + if helper.is_detail_finished(line): + return line + + return "" + + +def process_spread_output( + output_file: str, exclude_lines: set[str], filter_rules: list[str] +) -> None: + error_regex = compile_rules(filter_rules, helper.ExecutionInfo.ERROR.value) + debug_regex = compile_rules(filter_rules, helper.ExecutionInfo.DEBUG.value) + failed_regex = compile_rules(filter_rules, helper.Result.FAILED.value) + warning_regex = compile_rules(filter_rules, helper.ExecutionInfo.WARNING.value) + + with open(output_file, "a") as myfile: + for line in sys.stdin: + print_line(line) + + while helper.is_detail_start(line): + regex_list = [] + if helper.is_operation(line, helper.ExecutionInfo.DEBUG): + if helper.ExecutionInfo.DEBUG.value in exclude_lines: + line = skip_detail(sys.stdin) + continue + else: + regex_list = debug_regex + + if helper.is_operation(line, helper.ExecutionInfo.ERROR): + if helper.ExecutionInfo.ERROR.value in exclude_lines: + line = skip_detail(sys.stdin) + continue + else: + regex_list = error_regex + + if helper.is_operation(line, helper.ExecutionInfo.WARNING): + if helper.ExecutionInfo.WARNING.value in exclude_lines: + line = skip_detail(sys.stdin) + continue + else: + regex_list = warning_regex + + if helper.is_operation(line, helper.Result.FAILED): + if helper.Result.FAILED.value in exclude_lines: + line = skip_detail(sys.stdin) + continue + else: + regex_list = failed_regex + + line = process_detail(sys.stdin, line, regex_list, myfile) + + if ( + not exclude_lines + or not helper.is_any_operation(line) + or not helper.get_operation(line) in exclude_lines + ): + write_line(line, myfile) + + +def _make_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser( + description=""" +This tool is used to save a filtered version of the spread output. It parses the spread output and filters +sections and debug/error details to the file passed as parameter (all the lines are printed). +When a output file is not provided the debug output is sent to spread_filtered.log +""" + ) + parser.add_argument( + "-o", + "--output-file", + metavar="PATH", + default="spread.filtered.log", + help="path to the filtered output file", + ) + parser.add_argument( + "-e", + "--exclude", + action="append", + default=[], + choices=helper.OPERATIONS, + help="A line section to exclude from the output", + ) + parser.add_argument( + "-f", + "--filter", + action="append", + metavar="OPERATION=PATTERN", + default=[], + help="It is used to extract specific data from errors. Allowed operations are Error, Debug, Failed and WARNING:", + ) + + return parser + + +if __name__ == "__main__": + parser = _make_parser() + args = parser.parse_args() + process_spread_output(args.output_file, args.exclude, args.filter) diff --git a/utils/log-parser b/utils/log-parser index 4d6cd5a11d2..c4494f5fe47 100755 --- a/utils/log-parser +++ b/utils/log-parser @@ -12,51 +12,17 @@ import os import re import sys -# Info types -ERROR_TYPE = 'Error' -DEBUG_TYPE = 'Debug' -WARN_TYPE = 'WARNING:' - -# Results -FAILED_TYPE = 'Failed' -ABORTED_TYPE = 'Aborted' -SUCCESSFUL_TYPE = 'Successful' - -# Printable names -ALL = 'all' -NONE = 'none' -ACTION = 'action' -OPERATION = 'operation' -INFO = 'info' -ERROR = 'error' -ERROR_DEBUG = 'error-debug' -FAILED = 'failed' -ABORTED = 'aborted' -SUCCESSFUL = 'successful' - -RESULT = 'result' -START = 'Found' -SPREAD_FILE = 'spread.yaml' - -EXEC_VERBS = ['Preparing', 'Executing', 'Restoring'] -INFO_TYPES = [ERROR_TYPE, DEBUG_TYPE, WARN_TYPE] -OPERATIONS = [ - 'Rebooting', 'Discarding', 'Allocating', 'Waiting', - 'Allocated', 'Connecting', 'Connected', 'Sending' - ] -RESULTS = ['Successful', 'Aborted', 'Failed'] -FAILED_LEVELS = ['task', 'suite', 'project'] -FAILED_STAGES = ['prepare', 'restore'] +import log_helper as helper -class Action: +class Phase: """ - Action represents the main spread tasks actions - The actions can be: Preparing, Executing and Restoring + Phase represents the task/suite/project action in terms of: + Preparing, Executing and Restoring """ def __init__(self, verb, task, date, time, source_line): - self.type = ACTION + self.type = "phase" self.verb = verb self.time = time self.date = date @@ -66,14 +32,14 @@ class Action: def __repr__(self): return self.source_line - def __dict__(self): + def to_dict(self): return { - 'type': 'action', - 'date': self.date, - 'time': self.time, - 'verb': self.verb, - 'task': self.task - } + "type": self.type, + "date": self.date, + "time": self.time, + "verb": self.verb, + "task": self.task, + } class Result: @@ -82,9 +48,10 @@ class Result: The results can be: Successful, failed and aborted """ - def __init__(self, result_type, level, stage, number, date, time, - detail, source_line): - self.type = RESULT + def __init__( + self, result_type, level, stage, number, date, time, detail, source_line + ): + self.type = "result" self.result_type = result_type self.level = level self.stage = stage @@ -96,34 +63,33 @@ class Result: def __repr__(self): if self.detail: - return '{}{}'.format(self.source_line, str(self.detail)) + return "{}{}".format(self.source_line, str(self.detail)) return self.source_line - def __dict__(self): + def to_dict(self): prepared_detail = None if self.detail: - prepared_detail = self.detail.__dict__() + prepared_detail = self.detail.to_dict() return { - 'type': self.type, - 'date': self.date, - 'time': self.time, - 'result_type': self.result_type, - 'level': self.level, - 'stage': self.stage, - 'number': self.number, - 'detail': prepared_detail - } + "type": self.type, + "date": self.date, + "time": self.time, + "result_type": self.result_type, + "level": self.level, + "stage": self.stage, + "number": self.number, + "detail": prepared_detail, + } class Info: """ - Info represents the extra tasks information which is included in the - spread log. The info can be: Error, Debug and Warning + Info represents the tasks status information which is included + in the spread log. The info can be: Error, Debug and Warning. """ - def __init__(self, info_type, verb, task, extra, date, time, - detail, source_line): - self.type = INFO + def __init__(self, info_type, verb, task, extra, date, time, detail, source_line): + self.type = "info" self.info_type = info_type self.verb = verb self.time = time @@ -135,23 +101,57 @@ class Info: def __repr__(self): if self.detail: - return '{}{}'.format(self.source_line, self.detail) + return "{}{}".format(self.source_line, self.detail) return self.source_line - def __dict__(self): + def to_dict(self): prepared_detail = None if self.detail: - prepared_detail = self.detail.__dict__() + prepared_detail = self.detail.to_dict() return { - 'type': self.type, - 'date': self.date, - 'time': self.time, - 'info_type': self.info_type, - 'verb': self.verb, - 'task': self.task, - 'extra': self.extra, - 'detail': prepared_detail - } + "type": self.type, + "date": self.date, + "time": self.time, + "info_type": self.info_type, + "verb": self.verb, + "task": self.task, + "extra": self.extra, + "detail": prepared_detail, + } + + +class Rule: + """ + Rule represent the KEY=PATTERN used to extract information from a set of lines + """ + + def __init__(self, rule): + parts = rule.split("=", 1) + if len(parts) != 2: + raise ValueError( + "Error: Rule '{}' does not follow the KEY=PATTERN format".format(rule) + ) + + self.key = parts[0] + self.pattern = parts[1] + + try: + re.compile(self.pattern) + except re.error as err: + raise ValueError( + "Error: pattern '{}' cannot be compiled: {}".format(self.pattern, err) + ) + + def filter(self, lines) -> list[str]: + regex = re.compile(self.pattern) + all_matches = [] + for line in lines: + matches = regex.findall(line) + for match in matches: + if match: + all_matches.append(match) + + return all_matches class Detail: @@ -159,34 +159,48 @@ class Detail: Detail represents the extra lines which are displayed after the info """ - def __init__(self, lines_limit, lines): + def __init__(self, lines_limit: int, lines: list[str], rules: list[str]) -> None: self.lines_limit = lines_limit self.lines = lines + self.data = dict[str, list[str]]() + self._process_rules(rules) - def _get_lines(self): + def _get_lines(self) -> list[str]: if self.lines_limit < 0 or self.lines_limit > len(self.lines): return self.lines # Use self.lines_limit-1 because the last line is a '.' and we don't # want to count it as a line in the log details - return self.lines[-self.lines_limit-1:] + return self.lines[-self.lines_limit - 1 :] + + def _process_rules(self, rules) -> None: + for rule in rules: + key = rule.key + matches = rule.filter(self.lines) + self.data[key] = matches def __repr__(self): - return ''.join(self._get_lines()) + return "".join(self._get_lines()) + + def to_dict(self) -> dict[str, list[str]]: + details_dict = {"lines": self.lines[-self.lines_limit - 1 :]} + for key in self.data.keys(): + details_dict[key] = self.data[key] - def __dict__(self): - return {'lines': self.lines[-self.lines_limit-1:]} + return details_dict -class Operation: +class Action: """ - Operation represents other actions that the spread running can do while + The actions are general operations that the spread can do while executing tests like: Rebooting, Discarding, Allocating, Waiting, Allocated, Connecting, Connected, Sending """ - def __init__(self, verb, task, extra, date, time, source_line): - self.type = OPERATION + def __init__( + self, verb: str, task: str, extra: str, date: str, time: str, source_line: str + ) -> None: + self.type = "action" self.verb = verb self.time = time self.extra = extra @@ -197,113 +211,90 @@ class Operation: def __repr__(self): return self.source_line - def __dict__(self): + def to_dict(self) -> dict[str, str]: return { - 'type': self.type, - 'date': self.date, - 'time': self.time, - 'verb': self.verb, - 'task': self.task, - 'extra': self.extra - } + "type": self.type, + "date": self.date, + "time": self.time, + "verb": self.verb, + "task": self.task, + "extra": self.extra, + } class LogReader: """ LogReader manages the spread log, it allows to read, export and print """ - def __init__(self, filepath, output_type, lines_limit, store_setup): + + def __init__( + self, + filepath: str, + output_type: str, + lines_limit: str, + error_rules: str, + debug_rules: str, + ) -> None: self.filepath = filepath self.output_type = output_type self.lines_limit = lines_limit - self.store_setup = store_setup - self.lines = [] + self.lines = list[str]() self.iter = 0 - self.full_log = [] + self.full_log = list[str]() + self.error_rules = [Rule(rule) for rule in error_rules] + self.debug_rules = [Rule(rule) for rule in debug_rules] def __repr__(self): - return str(self.__dict__()) + return str(self.to_dict()) - def __dict__(self): - return {'full_log': self.full_log} + def to_dict(self) -> dict: + return {"full_log": self.full_log} - def print_log(self, details, results): + def print_log(self) -> None: if not self.full_log: return - # Print the details - if details == ALL: - print(''.join(str(x) for x in self.full_log)) - elif details == NONE: - pass - elif details == ERROR: - print(''.join(str(x) for x in self.full_log if x.type == INFO and - x.info_type == ERROR_TYPE)) - elif details == ERROR_DEBUG: - print(''.join(str(x) for x in self.full_log if x.type == INFO and - (x.info_type == ERROR_TYPE or x.info_type == DEBUG_TYPE))) - else: - print(''.join(str(x) for x in self.full_log if x.type == details)) - - # Print the results - if results == ALL: - print(''.join(str(x) for x in self.full_log if x.type == RESULT)) - elif results == NONE: - pass - elif results == FAILED: - print(''.join(str(x) for x in self.full_log if x.type == RESULT and - x.result_type == FAILED_TYPE)) - elif results == ABORTED: - print(''.join(str(x) for x in self.full_log if x.type == RESULT and - x.result_type == ABORTED_TYPE)) - else: - print(''.join(str(x) for x in self.full_log if x.type == RESULT and - x.result_type == SUCCESSFUL_TYPE)) + print("".join(str(x) for x in self.full_log)) - def export_log(self, filepath): + def export_log(self, filepath: str) -> None: prepared_log = [] for item in self.full_log: if isinstance(item, str): prepared_log.append(item) else: - prepared_log.append(item.__dict__()) - with open(filepath, 'w') as json_file: + prepared_log.append(item.to_dict()) + with open(filepath, "w") as json_file: json.dump(prepared_log, json_file, indent=4) - def _next_line(self): + def _next_line(self) -> str: self.iter = self.iter + 1 - return self.lines[self.iter-1] + return self.lines[self.iter - 1] - def check_log_exists(self): + def check_log_exists(self) -> bool: return os.path.exists(self.filepath) - def read_spread_log(self): - with open(self.filepath) as filepath: - self.lines = filepath.readlines() + def read_spread_log(self) -> None: + try: + with open(self.filepath, "r", encoding="utf-8") as filepath: + self.lines = filepath.readlines() + except UnicodeDecodeError: + with open(self.filepath, "r", encoding="latin-1") as filepath: + self.lines = filepath.readlines() - # Find the start of the log, the log file could include - # initial lines which are not part of the spread log itself self.iter = 0 - if self.store_setup: - while self.iter < len(self.lines): - line = self._next_line() - if self._match_start(line): - break - self.full_log.append(line) - - if self.iter >= len(self.lines): - # Start not found, the log is either empty, corrupted or cut - self.iter = 0 # Then iterate line by line analyzing the log while self.iter < len(self.lines): line = self._next_line() + if not helper.is_any_operation(line): + continue + # The line is a task execution; preparing, executing, restoring - if self._match_task(line): - action = self._get_action(line) - if action: - self.full_log.append(action) + if self._match_phase(line): + phase = self._get_phase(line) + if phase: + self.full_log.append(phase) continue # The line shows info: error, debug, warning @@ -315,10 +306,10 @@ class LogReader: # The line is another operation: Rebooting, Discarding, Allocating # Waiting, Allocated, Connecting, Connected, Sending' - if self._match_operation(line): - operation = self._get_operation(line) - if operation: - self.full_log.append(operation) + if self._match_action(line): + action = self._get_action(line) + if action: + self.full_log.append(action) continue # The line is a result: Successful, Aborted, Failed @@ -328,178 +319,127 @@ class LogReader: self.full_log.append(result) continue - def _match_date(self, date): - return re.findall(r'\d{4}-\d{2}-\d{2}', date) - - def _match_time(self, time): - return re.findall(r'\d{2}:\d{2}:\d{2}', time) - - def _match_info(self, line): - parts = line.strip().split(' ') - return len(parts) > 3 and \ - parts[2] in INFO_TYPES and \ - self._match_date(parts[0]) and \ - self._match_time(parts[1]) - - def _match_task(self, line): - parts = line.strip().split(' ') - return len(parts) > 2 and \ - parts[2] in EXEC_VERBS and \ - self._match_date(parts[0]) and \ - self._match_time(parts[1]) - - def _match_start(self, line): - parts = line.strip().split(' ') - return len(parts) > 2 and \ - parts[2] == START and \ - self._match_date(parts[0]) and \ - self._match_time(parts[1]) and \ - SPREAD_FILE in parts[3] - - def _match_operation(self, line): - parts = line.strip().split(' ') - return len(parts) > 2 and \ - parts[2] in OPERATIONS and \ - self._match_date(parts[0]) and \ - self._match_time(parts[1]) - - def _match_result(self, line): - parts = line.strip().split(' ') - return len(parts) > 2 and \ - parts[2] in RESULTS and \ - self._match_date(parts[0]) and \ - self._match_time(parts[1]) - - def _get_detail(self, results=False, other_limit=None): + def _match_info(self, line: str) -> bool: + return helper.get_operation(line) in helper.ExecutionInfo.list() + + def _match_phase(self, line: str) -> bool: + return helper.get_operation(line) in helper.ExecutionPhase.list() + + def _match_action(self, line: str) -> bool: + return ( + helper.get_operation(line) + in helper.GeneralAction.list() + helper.GeneralActionStatus.list() + ) + + def _match_result(self, line: str) -> bool: + return helper.get_operation(line) in helper.Result.list() + + def _get_detail(self, rules, results=False, other_limit=None): """ This function is used to get the piece of log which is after the info lines (error, debug, warning). The detail could also include a limit of lines to tail the log and show the last lines. It returns a Detail object included all the lines. """ - - # If the first line matches with a regular line, this means the detail - # has no output and has to be discarded - line = self.lines[self.iter] - if self._match_task(line) or self._match_info(line) or \ - self._match_operation(line) or self._match_result(line): - return None - - detail=[] - initial_iter = self.iter + detail = [] while self.iter < len(self.lines): + previous_line = self.lines[self.iter - 1] line = self._next_line() - if self._match_task(line) or self._match_info(line) or \ - self._match_operation(line) or self._match_result(line): - # When the details is for results, then any match is ok to break - if results: - break - # When the details is no for results, then we need to check also - # the the last time was just a '.' - # The details for info (Error, Debug and Warning) always finish with - # ---- - # . - # - # As the iter is already pointing to the next line since 'line = self._next_line()' - # to access the previous line of the current one it is needed to do 'self.iter-2' - elif self.lines[self.iter-2].strip() == '.': + if helper.is_detail_finished(line): + # This is needed because it could happen that in the details there is a spread log + # because sometimes we run nested spread + # The is not valid when the details are for failed tests in results section + if results or previous_line.strip() == ".": break - detail.append(line) + detail.append(line) - # When the details is for results, if the detail line does not start - # with " - ", then it is time to break - if results and not line.startswith(" - "): - break - else: - detail.append(line) - - # We leave the iter in the last time in case the log has finished + # We leave the iter in the last line in case the log has finished if not self.iter == len(self.lines): self.iter = self.iter - 1 if not other_limit: other_limit = self.lines_limit - return Detail(other_limit, detail) + return Detail(other_limit, detail, rules) def _get_info(self, line): """ Get the Info object for the error, debug and warning lines including the details for this """ - parts = line.strip().split(' ') - if len(parts) < 3: - return None - date = parts[0] - time = parts[1] - info_type = parts[2] + date = helper.get_date(line) + time = helper.get_time(line) + info_type = helper.get_operation(line) + info_extra = helper.get_operation_info(line) verb = None task = None - if info_type == WARN_TYPE: - info_type = info_type.split(':')[0] + if info_type == helper.ExecutionInfo.WARNING.value: + # Removing the : from WARNING: + info_type = info_type.split(":")[0] verb = None task = None - extra = ' '.join(parts[3:]) - elif info_type == ERROR_TYPE: - verb = parts[3] - task = parts[4] + extra = info_extra + elif info_type == helper.ExecutionInfo.ERROR.value: + verb = info_extra.split(" ")[0] + task = info_extra.split(" ")[1] extra = None - elif info_type == DEBUG_TYPE: + elif info_type == helper.ExecutionInfo.DEBUG.value: verb = None - task = parts[5] + task = info_extra.split(" ")[2] extra = None else: - print('log-parser: detail type not recognized: {}'.format(info_type)) + print("log-parser: detail type not recognized: {}".format(info_type)) + return + + # Pass the rules according to the info type + rules = self.debug_rules + if info_type == helper.ExecutionInfo.ERROR.value: + rules = self.error_rules + + detail = None + if helper.is_detail(line): + detail = self._get_detail(rules) - detail = self._get_detail(results=False) return Info(info_type, verb, task, extra, date, time, detail, line) def _get_result(self, line): - """ Get the Result object including the details for the result """ - parts = line.strip().split(' ') - if len(parts) < 3: - return None - date = parts[0] - time = parts[1] - result_type = parts[2] - level = parts[3].split(':')[0] - number = parts[-1] + """Get the Result object including the details for the result""" + date = helper.get_date(line) + time = helper.get_time(line) + result_type = helper.get_operation(line) + result_extra = helper.get_operation_info(line) + level = result_extra.split(" ")[0].split(":")[0] + number = result_extra.split(" ")[-1] stage = None detail = None - if result_type == FAILED_TYPE: - if level in FAILED_LEVELS: - stage = parts[4].split(':')[0] - detail = self._get_detail(results=True, other_limit=-1) + if result_type == helper.Result.FAILED.value: + if level in helper.ExecutionLevel.list(): + stage = result_extra.split(" ")[1].split(":")[0] + detail = self._get_detail([], results=True, other_limit=-1) - return Result(result_type, level, stage, number.strip(), date, time, detail, - line) + return Result(result_type, level, stage, number, date, time, detail, line) - def _get_action(self, line): + def _get_phase(self, line): """ - Get the Action object for lines preparing, executing and restoring + Get the phase object for lines preparing, executing and restoring """ - parts = line.strip().split(' ') - if len(parts) < 3: - return None - date = parts[0] - time = parts[1] - verb = parts[2] - task = parts[3] - return Action(verb, task.split('...')[0], date, time, line) - - def _get_operation(self, line): - """ Get the Operation object for lines rebooting, allocating, etc """ - parts = line.strip().split(' ') - if len(parts) < 3: - return None - date = parts[0] - time = parts[1] - verb = parts[2] + date = helper.get_date(line) + time = helper.get_time(line) + verb = helper.get_operation(line) + task = helper.get_operation_info(line).split(" ")[0] + return Phase(verb, task.split("...")[0], date, time, line) + + def _get_action(self, line): + """Get the general actions object for lines rebooting, allocating, etc""" + + date = helper.get_date(line) + time = helper.get_time(line) + verb = helper.get_operation(line) task = None - extra = ' '.join(parts[3:]) - return Operation(verb, task, extra, date, time, line) + extra = helper.get_operation_info(line) + return Action(verb, task, extra, date, time, line) def _make_parser(): @@ -523,25 +463,9 @@ for the error/debug/warning output. "--format", type=str, default="json", - choices=['json'], + choices=["json"], help="format for the output", ) - parser.add_argument( - "-pd", - "--print-details", - type=str, - default=NONE, - choices=[ALL, ERROR, ERROR_DEBUG, OPERATION, ACTION, INFO, NONE], - help="Filter which info to print", - ) - parser.add_argument( - "-pr", - "--print-results", - type=str, - default=NONE, - choices=[ALL, FAILED, ABORTED, SUCCESSFUL, NONE], - help="Filter which results to print", - ) parser.add_argument( "-o", "--output", @@ -550,12 +474,21 @@ for the error/debug/warning output. help="output file to save the result", ) parser.add_argument( - "--store-setup", - action="store_true", - help="will save all the text before the spread run is started", + "-er", + "--error-rule", + action="append", + default=[], + help="A KEY=PATTERN used to extract and store specific data from errors", ) parser.add_argument( - "logpath", metavar="PATH", help="path to the log to be analyzed" + "-dr", + "--debug-rule", + action="append", + default=[], + help="A KEY=PATTERN used to extract and store specific data from debug output", + ) + parser.add_argument( + "log_path", metavar="PATH", help="path to the log to be analyzed" ) return parser @@ -565,11 +498,17 @@ def main(): parser = _make_parser() args = parser.parse_args() - if len(args.logpath) == 0: + if len(args.log_path) == 0: parser.print_usage() parser.exit(0) - reader = LogReader(args.logpath, args.format, args.cut, args.store_setup) + reader = LogReader( + args.log_path, + args.format, + args.cut, + args.error_rule, + args.debug_rule, + ) if not reader.check_log_exists(): print("log-parser: log not found") sys.exit(1) @@ -579,7 +518,7 @@ def main(): if args.output: reader.export_log(args.output) - reader.print_log(args.print_details, args.print_results) + reader.print_log() if __name__ == "__main__": diff --git a/utils/log_helper.py b/utils/log_helper.py new file mode 100644 index 00000000000..18de5030386 --- /dev/null +++ b/utils/log_helper.py @@ -0,0 +1,193 @@ +""" +This library provides a set of functions that can be used to +process the spread output. +""" + +import re + +from enum import Enum + + +class ListedEnum(Enum): + @classmethod + def list(cls) -> list[str]: + return list(map(lambda c: c.value, cls)) + +class ExecutionPhase(ListedEnum): + PREPARING = "Preparing" + EXECUTING = "Executing" + RESTORING = "Restoring" + + +class ExecutionInfo(ListedEnum): + DEBUG = "Debug" + ERROR = "Error" + WARNING = "WARNING:" + + +class ExecutionLevel(ListedEnum): + TASK = "task" + SUITE = "suite" + PROJECT = "project" + + +class GeneralAction(ListedEnum): + REBOOTING = "Rebooting" + DISCARDING = "Discarding" + ALLOCATING = "Allocating" + WAITING = "Waiting" + CONNECTING = "Connecting" + SENDING = "Sending" + + +class GeneralActionStatus(ListedEnum): + ALLOCATED = "Allocated" + CONNECTED = "Connected" + + +class Result(ListedEnum): + FAILED = "Failed" + SUCCESSFUL = "Successful" + ABORTED = "Aborted" + + +OPERATIONS = ( + ExecutionPhase.list() + + GeneralAction.list() + + GeneralActionStatus.list() + + ExecutionInfo.list() + + Result.list() +) + + +# Start line +START_LINE = ".*Project content is packed for delivery.*" + + +def _match_date(date: str) -> bool: + return re.match(r"\d{4}-\d{2}-\d{2}", date) is not None + + +def _match_time(time: str) -> bool: + return re.match(r"\d{2}:\d{2}:\d{2}", time) is not None + + +def is_initial_line(line: str) -> bool: + if not line: + return False + + pattern = re.compile(START_LINE) + parts = line.strip().split(" ") + return ( + len(parts) > 2 + and _match_date(parts[0]) + and _match_time(parts[1]) + and re.match(pattern, line) is not None + ) + + +# Debug line starts with the operation +def is_operation(line: str, operation: Enum) -> bool: + if not line: + return False + + parts = line.strip().split(" ") + return ( + len(parts) > 2 + and _match_date(parts[0]) + and _match_time(parts[1]) + and parts[2] == operation.value + ) + + +# Check if the line contains any operation +def is_any_operation(line: str) -> bool: + if not line: + return False + + parts = line.strip().split(" ") + return ( + len(parts) > 2 + and _match_date(parts[0]) + and _match_time(parts[1]) + and parts[2] in OPERATIONS + ) + + +# Return the date in the line +def get_date(line: str) -> str: + if not line: + raise RuntimeError("Empty line provided") + + parts = line.strip().split(" ") + if len(parts) <= 2 or not _match_date(parts[0]): + raise ValueError("Incorrect format for line provided: {}".format(line)) + + return parts[0] + + +# Return the time in the line +def get_time(line: str) -> str: + if not line: + raise RuntimeError("Empty line provided") + + parts = line.strip().split(" ") + if len(parts) <= 2 or not _match_date(parts[0]) or not _match_time(parts[1]): + raise ValueError("Incorrect format for line provided: {}".format(line)) + + return parts[1] + + +# Return the operation in the line +def get_operation(line: str) -> str: + if not line: + raise RuntimeError("Empty line provided") + + parts = line.strip().split(" ") + if len(parts) <= 2 or not _match_date(parts[0]) or not _match_time(parts[1]): + raise ValueError("Incorrect format for line provided: {}".format(line)) + + return parts[2] + + +# Return the information that comes after the operation +def get_operation_info(line: str) -> str: + if not line: + raise RuntimeError("Empty line provided") + + parts = line.strip().split(" ") + if len(parts) <= 3 or not _match_date(parts[0]) or not _match_time(parts[1]): + raise ValueError("Incorrect format for line provided: {}".format(line)) + + return " ".join(parts[3:]) + + +# Details are displayed after Error/Debug/Failed/Warning operations +def is_detail_start(line: str) -> bool: + return ( + is_operation(line, ExecutionInfo.DEBUG) + or is_operation(line, ExecutionInfo.ERROR) + or is_operation(line, ExecutionInfo.WARNING) + or is_operation(line, Result.FAILED) + ) + + +# Error/Debug/Failed output sometimes finish with either EOF error or a log file +# and no detail displayed +def is_detail(line: str) -> bool: + return ( + is_operation(line, ExecutionInfo.DEBUG) + or is_operation(line, ExecutionInfo.ERROR) + or is_operation(line, ExecutionInfo.WARNING) + ) and line.strip()[-1:] == ":" + + +# Error/Debug/Failed output finishes when a new other line starts +def is_detail_finished(line: str) -> bool: + parts = line.strip().split(" ") + return ( + len(parts) > 3 + and _match_date(parts[0]) + and _match_time(parts[1]) + and parts[2] in OPERATIONS + ) diff --git a/utils/spread-filter b/utils/spread-filter new file mode 100755 index 00000000000..0e49ac40468 --- /dev/null +++ b/utils/spread-filter @@ -0,0 +1,220 @@ +#!/usr/bin/env python3 + +import argparse +import os +import re +import sys +import yaml + + +class ExecutionRule: + def __init__(self, from_list: list[str], to: list[str]): + self.regex_list = [] + self.to = to + for regex in from_list: + self.regex_list.append(re.compile(regex)) + + def match(self, path: str) -> list[str]: + for regex in self.regex_list: + if regex.match(path): + return self.to + + return [] + + +class ExecutionRules: + def __init__(self, rules: list[ExecutionRule]): + self.rules = [] + self.rules = rules + + def calc_executions(self, change: str) -> list[str]: + for rule in self.rules: + match = rule.match(change) + if match != []: + return match + + return [] + + +class ExecutionManager: + + TASK = "task.yaml" + SELF = "$SELF" + NONE = "$NONE" + + def __init__(self, rules_file: str, prefix: str, verbose: bool): + self.verbose = verbose + self.prefix = prefix + with open(rules_file) as f: + rules_map = yaml.safe_load(f) + self.rules = ExecutionRules(self.from_rules_map(rules_map)) + + @classmethod + def from_rules_map( + cls, rules_map: dict[str, dict[str, dict[str, list[str]]]] + ) -> list[ExecutionRule]: + return [ + ExecutionRule(r.get("from", []), r.get("to", [])) + for r in rules_map["rules"].values() + ] + + def _is_test_dir(self, change_dir: str) -> bool: + return os.path.isfile(os.path.join(change_dir, self.TASK)) + + def _is_task_file(self, change_path: str) -> bool: + return os.path.isfile(change_path) and change_path.endswith("task.yaml") + + def _get_test_exec_dir(self, change_dir: str) -> str: + test_dir = change_dir + if change_dir.endswith("/") and self._is_test_dir(change_dir): + test_dir = change_dir[:-1] + return test_dir + + def _get_execution_param(self, exec_paths: list[str]) -> list[str]: + all_params = [] + for exec_path in exec_paths: + all_params.append(self.prefix + ":" + exec_path) + return all_params + + def _calc_self(self, change_path: str) -> str: + if self.verbose: + print("calculating self for {}".format(change_path)) + + # If the change is a directory which has changed + if os.path.isdir(change_path): + if self._is_test_dir(change_path): + return self._get_test_exec_dir(change_path) + else: + test_dir = self._get_parent_with_task(change_path) + return self._get_test_exec_dir(test_dir) + # If the change is a file which has changed + elif os.path.isfile(change_path): + # If the change is a task.yaml + if self._is_task_file(change_path): + return self._get_test_exec_dir(os.path.dirname(change_path)) + + # If the change is a file in the same dir than a task.yaml + change_dir = os.path.dirname(change_path) + if self._is_test_dir(change_dir): + return self._get_test_exec_dir(change_dir) + # If the change is a file which is not in the same dir than a task.yaml + else: + test_dir = self._get_parent_with_task(change_path) + return self._get_test_exec_dir(test_dir) + # If the change is deleted file/dir + else: + # If a task.yaml has been deleted + if self._is_task_file(change_path): + return "" + else: + test_dir = self._get_parent_with_task(change_path) + return test_dir + + def _get_parent_with_task(self, change_path: str) -> str: + if self.verbose: + print("calculating parent with task {}".format(change_path)) + parent_path = os.path.dirname(change_path) + while parent_path != "": + if os.path.isfile(os.path.join(parent_path, self.TASK)): + return parent_path + parent_path = os.path.dirname(parent_path) + return "" + + def _clean_executions(self, executions: list[str]) -> list[str]: + if self.verbose: + print("cleaning executions for {}".format(executions)) + + final_executions = [] + # Get the execution paths ordered starting from the longest one + sorted_executions = sorted(executions, key=len, reverse=True) + for i in range(len(sorted_executions)): + discard_execution = False + long_execution = sorted_executions[i] + if self.verbose: + print(" checking repeated executions for {}".format(long_execution)) + + for j in range(i + 1, len(sorted_executions)): + short_execution = sorted_executions[j] + if self.verbose: + print( + " comparing repeated executions for {}".format( + short_execution + ) + ) + + # If the shorter executions is a test, we continue + if not short_execution.endswith("/"): + if long_execution == short_execution: + discard_execution = True + break + # If the shorter execution is a either suite or group of suites + else: + # If the long executions starts with short execution means + # the long execution is included in the short one and it can + # be discarded + if long_execution.startswith(short_execution): + discard_execution = True + break + + # Take decision after all shorter executions have been compared + if not discard_execution: + final_executions.append(long_execution) + + return final_executions + + # Retrieves the list of tests to execute + def get_executions(self, changes: list[str]) -> list[str]: + all_executions = [] + for change in changes: + executions = self.rules.calc_executions(change) + # When the tests to run as tagged as SELF means the current test + # has to be executed + for execution in executions: + if execution == self.SELF: + self_execution = self._calc_self(change) + if self_execution != "": + all_executions.append(self_execution) + # When the tests to run are tagged as NONE means that no tests + # have to be executed + elif execution == self.NONE: + continue + # Otherwise, what is defined in to (literal) is executed. + else: + all_executions.append(self._get_test_exec_dir(execution)) + + cleaned_executions = self._clean_executions(all_executions) + return self._get_execution_param(cleaned_executions) + + +def _make_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser(description="spread filter helper") + parser.add_argument("-r", "--rules-file", required=True, help="Rules file") + parser.add_argument( + "-p", + "--prefix", + required=True, + help="Backend and system (BACKEND:SYSTEM) used as prefix in the output", + ) + parser.add_argument( + "-c", "--change", action="append", default=[], help="File that changed" + ) + parser.add_argument("-v", "--verbose", action="store_true", help="Be more verbose") + + return parser + + +if __name__ == "__main__": + parser = _make_parser() + args = parser.parse_args() + + if not args.change: + print("spread-filter: no file changes set") + sys.exit(1) + + if not os.path.isfile(args.rules_file): + print("spread-filter: rules file '{}' does not exist".format(args.rules_file)) + sys.exit(1) + + execution_manager = ExecutionManager(args.rules_file, args.prefix, args.verbose) + execution_list = execution_manager.get_executions(args.change) + print(" ".join(map(str, execution_list))) diff --git a/utils/spread-shellcheck b/utils/spread-shellcheck index 8bef747d1c7..4769a7dc5da 100755 --- a/utils/spread-shellcheck +++ b/utils/spread-shellcheck @@ -20,6 +20,7 @@ import hashlib import itertools import logging import os +import re import subprocess import yaml @@ -119,21 +120,34 @@ def checksection(data, env: Dict[str, str]): for key, value in env.items(): value = str(value) - # Unpack the special "$(HOST: ...) syntax and tell shellcheck not to - # worry about the use of echo to print variable value. - if value.startswith("$(HOST:") and value.endswith(")"): - script_data.append("# shellcheck disable=SC2116") - value = "$({})".format(value[len("$(HOST:"):-1]) - # XXX: poor man's shell key=value assignment with values in double - # quotes so that one value can refer to another value. - if '"' in value: - value = value.replace('"', '\"') + disabled_warnings = set() + export_disabled_warnings = set() + def replacement(match): + if match.group(0) == '"': + # SC2089 and SC2090 are about quotes vs arrays + # We cannot have arrays in environment variables of spread + # So we do have to use quotes + disabled_warnings.add('SC2089') + export_disabled_warnings.add('SC2090') + return r'\"' + else: + assert(match.group('command') is not None) + # "Useless" echo. This is what we get. + # We cannot just evaluate to please shellcheck. + disabled_warnings.add('SC2116') + return '$({})'.format(match.group('command')) + value = re.sub(r'[$][(]HOST:(?P.*)[)]|"', replacement, value) # converts # FOO: "$(HOST: echo $foo)" -> FOO="$(echo $foo)" - # FOO: "$(HOST: echo \"$foo\")" -> FOO="$(echo \"$foo\")" + # FOO: "$(HOST: echo \"$foo\")" -> FOO="$(echo "$foo")" # FOO: "foo" -> FOO="foo" + # FOO: "\"foo\"" -> FOO="\"foo\"" + if disabled_warnings: + script_data.append("# shellcheck disable={}".format(','.join(disabled_warnings))) script_data.append("{}=\"{}\"".format(key, value)) - script_data.append("export {}".format(key)) + if export_disabled_warnings: + script_data.append("# shellcheck disable={}".format(','.join(export_disabled_warnings))) + script_data.append("export {}".format(key, value)) script_data.append(data) proc = subprocess.Popen("shellcheck -s {} -x -".format(SHELLCHECK_SHELL), stdout=subprocess.PIPE, diff --git a/utils/spreadJ b/utils/spreadJ new file mode 100755 index 00000000000..26f6b4ae663 --- /dev/null +++ b/utils/spreadJ @@ -0,0 +1,119 @@ +#!/bin/bash + +show_help() { + echo "usage: spreadJ rerun [--suite SUITE] " + echo " spreadJ show [--suite SUITE] " + echo " spreadJ stats [--suite SUITE] " + echo " spreadJ list [--suite SUITE] " + echo "" + echo "Available options:" + echo " -h --help show this help message." + echo "" + echo "TARGET:" + echo " all,failed,passed,aborted" + echo "" + echo "Tool used to help with functions that are not already implemented in spread" +} + +_filter_suite() { + local suite="$1" + if [ -z "$suite" ]; then + echo ".testsuites[]" + else + echo ".testsuites[] | select(.name == \"$suite\")" + fi +} + +rerun() { + local suite="" + if [ "$1" == "--suite" ]; then + suite="$2" + shift 2 + fi + local res_path="$1" + if [ ! -e "$res_path" ]; then + echo "spreadJ: results path not found: $res_path" + exit 1 + fi + + local query + query="$(_filter_suite $suite).tests[] | select((.result == \"failed\") or (.result == \"aborted\")).name" + jq -r "$query" "$res_path" +} + +stats() { + local suite="" + if [ "$1" == "--suite" ]; then + suite="$2" + shift 2 + fi + local res_path="$1" + + if [ ! -e "$res_path" ]; then + echo "spreadJ: results path not found: $res_path" + exit 1 + fi + + local query + if [ -z "$suite" ]; then + query="del(.testsuites)" + else + query="$(_filter_suite $suite) | del(.tests) | del(.name)" + fi + jq -r "$query" "$res_path" +} + +list() { + local suite="" + if [ "$1" == "--suite" ]; then + suite="$2" + shift 2 + fi + local target="$1" + local res_path="$2" + + if [ ! -e "$res_path" ]; then + echo "spreadJ: results path not found: $res_path" + exit 1 + fi + + if [ -z "$target" ]; then + echo "spreadJ: result target cannot be empty" + exit 1 + fi + + local query + if [ "$target" == "all" ]; then + query="$(_filter_suite $suite).tests[]).name" + else + query="$(_filter_suite $suite).tests[] | select((.result == \"$target\")).name" + fi + jq -r "$query" "$res_path" +} + +main() { + if [ $# -eq 0 ]; then + show_help + exit 0 + fi + + local subcommand="$1" + local action= + if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + show_help + exit 0 + else + action=$(echo "$subcommand" | tr '-' '_') + shift + fi + + if [ -z "$(declare -f "$action")" ]; then + echo "spreadJ: no such command: $subcommand" >&2 + show_help + exit 1 + fi + + "$action" "$@" +} + +main "$@" From d1f0f31c0a94bc3a570b0450d9990598cd96c0f0 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 12 Sep 2024 16:04:05 -0300 Subject: [PATCH 03/33] download snapd snap-confine and ubuntu-core-launcher --- tests/lib/prepare-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index 10d69c339d5..d62298d3f66 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -586,7 +586,7 @@ prepare_project() { chown test:test -R "$SPREAD_PATH" if [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; then - ( cd "${GOHOME}" && tests.pkgs download snapd ) + ( cd "${GOHOME}" && tests.pkgs download snapd snap-confine ubuntu-core-launcher) elif [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then case "$SPREAD_SYSTEM" in ubuntu-*|debian-*) From 6d5d45806c4be08df9de184f3f7dc0df57cecfe9 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Mon, 16 Sep 2024 17:16:32 -0300 Subject: [PATCH 04/33] skip tests that trust on deb pkg testkeys --- tests/main/classic-custom-device-reg/task.yaml | 9 ++++++--- tests/main/classic-firstboot/task.yaml | 11 ++++++++--- tests/main/classic-prepare-image-no-core/task.yaml | 11 +++++++---- tests/main/classic-prepare-image/task.yaml | 9 ++++++--- tests/main/classic-snapd-firstboot/task.yaml | 9 ++++++--- tests/main/upgrade-from-release/task.yaml | 2 +- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/tests/main/classic-custom-device-reg/task.yaml b/tests/main/classic-custom-device-reg/task.yaml index f263cc6c3c2..353463e18bb 100644 --- a/tests/main/classic-custom-device-reg/task.yaml +++ b/tests/main/classic-custom-device-reg/task.yaml @@ -15,7 +15,8 @@ environment: SEED_DIR: /var/lib/snapd/seed prepare: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -52,7 +53,8 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -62,7 +64,8 @@ restore: | systemctl start snapd.socket snapd.service execute: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index 1a1d6373d44..549694e1f42 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -13,8 +13,11 @@ systems: [-ubuntu-core-*] environment: SEED_DIR: /var/lib/snapd/seed +kill-timeout: 10m + prepare: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -51,7 +54,8 @@ prepare: | cp ./test-snapd-service_1.0_all.snap "$SEED_DIR/snaps/test-snapd-service.snap" restore: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -60,7 +64,8 @@ restore: | systemctl start snapd.socket snapd.service execute: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index 8c73e03841b..7be455a4f81 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -20,7 +20,8 @@ environment: SEED_DIR: /var/lib/snapd/seed prepare: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -30,7 +31,7 @@ prepare: | snap pack "$TESTSLIB/snaps/basic18" snap pack classic-gadget-18 - echo Expose the needed assertions through the fakestore + echo Expose the needed assertions through pkg fakestore cp "$TESTSLIB"/assertions/developer1.account "$STORE_DIR/asserts" cp "$TESTSLIB"/assertions/developer1.account-key "$STORE_DIR/asserts" # have snap use the fakestore for assertions (but nothing else) @@ -49,7 +50,8 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -61,7 +63,8 @@ restore: | rm -rf "$ROOT" execute: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd deb are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image/task.yaml b/tests/main/classic-prepare-image/task.yaml index 52e3130e065..96b9acc1ca3 100644 --- a/tests/main/classic-prepare-image/task.yaml +++ b/tests/main/classic-prepare-image/task.yaml @@ -19,7 +19,8 @@ environment: SEED_DIR: /var/lib/snapd/seed prepare: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -48,7 +49,8 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -60,7 +62,8 @@ restore: | rm -rf "$ROOT" execute: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-snapd-firstboot/task.yaml b/tests/main/classic-snapd-firstboot/task.yaml index b3631828bc8..ae220154033 100644 --- a/tests/main/classic-snapd-firstboot/task.yaml +++ b/tests/main/classic-snapd-firstboot/task.yaml @@ -12,7 +12,8 @@ environment: SEED_DIR: /var/lib/snapd/seed prepare: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -51,7 +52,8 @@ prepare: | cp ./basic18_1.0_all.snap "$SEED_DIR/snaps/basic18.snap" restore: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi @@ -60,7 +62,8 @@ restore: | systemctl start snapd.socket snapd.service execute: | - if [ "$TRUST_TEST_KEYS" = "false" ]; then + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/upgrade-from-release/task.yaml b/tests/main/upgrade-from-release/task.yaml index 76323588ea5..dcaf61ee2bd 100644 --- a/tests/main/upgrade-from-release/task.yaml +++ b/tests/main/upgrade-from-release/task.yaml @@ -67,7 +67,7 @@ execute: | if [ "${VERSION_ID}" = "14.04" ]; then dpkg -i "$GOHOME"/snapd*.deb else - apt install -y "$GOHOME"/snapd_1337*.deb + apt install -y "$GOHOME"/snapd_*.deb fi echo "snapd listens to requests" From ab0b03ff93e3c3bdc01fc1c4fef20f1dd89e9095 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 17 Sep 2024 16:16:33 -0300 Subject: [PATCH 05/33] fix shellcheck --- tests/main/classic-custom-device-reg/task.yaml | 6 +++--- tests/main/classic-firstboot/task.yaml | 6 +++--- tests/main/classic-prepare-image-no-core/task.yaml | 6 +++--- tests/main/classic-prepare-image/task.yaml | 6 +++--- tests/main/classic-snapd-firstboot/task.yaml | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/main/classic-custom-device-reg/task.yaml b/tests/main/classic-custom-device-reg/task.yaml index 353463e18bb..247f0c4849d 100644 --- a/tests/main/classic-custom-device-reg/task.yaml +++ b/tests/main/classic-custom-device-reg/task.yaml @@ -16,7 +16,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -54,7 +54,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -65,7 +65,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index 549694e1f42..17c7d34f470 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -17,7 +17,7 @@ kill-timeout: 10m prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -55,7 +55,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -65,7 +65,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index 7be455a4f81..deae467b94f 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -21,7 +21,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -51,7 +51,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -64,7 +64,7 @@ restore: | execute: | # In this scenario, the keys from the snapd deb are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image/task.yaml b/tests/main/classic-prepare-image/task.yaml index 96b9acc1ca3..cec9fccab1e 100644 --- a/tests/main/classic-prepare-image/task.yaml +++ b/tests/main/classic-prepare-image/task.yaml @@ -20,7 +20,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -50,7 +50,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -63,7 +63,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-snapd-firstboot/task.yaml b/tests/main/classic-snapd-firstboot/task.yaml index ae220154033..8a6cd66dfa5 100644 --- a/tests/main/classic-snapd-firstboot/task.yaml +++ b/tests/main/classic-snapd-firstboot/task.yaml @@ -13,7 +13,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -53,7 +53,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi @@ -63,7 +63,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || ( [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]); then + if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then echo "This test needs test keys to be trusted" exit fi From 3c7643124f4beed9800a7e4ec693dc6fec15b55b Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 17 Sep 2024 16:31:18 -0300 Subject: [PATCH 06/33] revert kill timeout --- tests/main/classic-firstboot/task.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index 17c7d34f470..d81f47c7b9a 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -13,8 +13,6 @@ systems: [-ubuntu-core-*] environment: SEED_DIR: /var/lib/snapd/seed -kill-timeout: 10m - prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then From 7d7873710ed98feb4ce82b260b44e3ab4dc16df5 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Wed, 18 Sep 2024 17:08:16 -0300 Subject: [PATCH 07/33] fix tests using snapd.tool and store-state test --- tests/lib/tools/snapd.tool | 10 ++++++++-- tests/main/store-state/task.yaml | 17 ++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/lib/tools/snapd.tool b/tests/lib/tools/snapd.tool index 980a514125b..d780f748195 100755 --- a/tests/lib/tools/snapd.tool +++ b/tests/lib/tools/snapd.tool @@ -47,8 +47,14 @@ main() { esac done - LIBEXEC_DIR="$(os.paths libexec-dir)" - exec "$LIBEXEC_DIR/snapd/$tool" "$@" + # Use the tool from the snapd snap when re-exec is enabled + # Otherwise use the tool from the distro installation + if snap debug execution snap | grep -q "is-reexecd: true"; then + exec /snap/snapd/current/usr/lib/snapd/"$tool" "$@" + else + LIBEXEC_DIR="$(os.paths libexec-dir)" + exec "$LIBEXEC_DIR/snapd/$tool" "$@" + fi } main "$@" \ No newline at end of file diff --git a/tests/main/store-state/task.yaml b/tests/main/store-state/task.yaml index 554dd247d20..8f521b4578e 100644 --- a/tests/main/store-state/task.yaml +++ b/tests/main/store-state/task.yaml @@ -28,13 +28,16 @@ execute: | "$TESTSTOOLS"/store-state -h | MATCH "usage: store-state setup-fake-store " "$TESTSTOOLS"/store-state --help | MATCH "usage: store-state setup-fake-store " - # Setup staging store - "$TESTSTOOLS"/store-state setup-staging-store - snap info core | MATCH "store-url:.*https://staging-api.snapcraft.io" - - # Teardown staging store - "$TESTSTOOLS"/store-state teardown-staging-store - snap info core | MATCH "store-url:.*https://snapcraft.io" + # Staging store cannot be used with snapd deb from the repository + if not [[ "$SNAPD_DEB_FROM_REPO" = true && -n "$(command -v apt)" ]]; then + # Setup staging store + "$TESTSTOOLS"/store-state setup-staging-store + snap info core | MATCH "store-url:.*https://staging-api.snapcraft.io" + + # Teardown staging store + "$TESTSTOOLS"/store-state teardown-staging-store + snap info core | MATCH "store-url:.*https://snapcraft.io" + fi # Setup fakestore STORE_DIR="$(pwd)/fake-store-blobdir" From 87cbe024e62bf4a0276a7b8283df97d31401a0a2 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 19 Sep 2024 09:47:40 -0300 Subject: [PATCH 08/33] new tests.info tool this tool is used to check for re-exec and to know the source of the snapd package --- tests/bin/tests.info | 1 + tests/lib/prepare-restore.sh | 2 +- tests/lib/tools/snapd.tool | 2 +- tests/lib/tools/tests.info | 51 +++++++++++++++++++ .../main/classic-custom-device-reg/task.yaml | 6 +-- tests/main/classic-firstboot/task.yaml | 6 +-- .../classic-prepare-image-no-core/task.yaml | 6 +-- tests/main/classic-prepare-image/task.yaml | 6 +-- tests/main/classic-snapd-firstboot/task.yaml | 6 +-- tests/main/store-state/task.yaml | 2 +- 10 files changed, 70 insertions(+), 18 deletions(-) create mode 120000 tests/bin/tests.info create mode 100755 tests/lib/tools/tests.info diff --git a/tests/bin/tests.info b/tests/bin/tests.info new file mode 120000 index 00000000000..247c842a58c --- /dev/null +++ b/tests/bin/tests.info @@ -0,0 +1 @@ +../lib/tools/tests.info \ No newline at end of file diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index d62298d3f66..e9271679d36 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -585,7 +585,7 @@ prepare_project() { # go mod runs as root and will leave strange permissions chown test:test -R "$SPREAD_PATH" - if [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; then + if tests.info is-snapd-pkg-repo; then ( cd "${GOHOME}" && tests.pkgs download snapd snap-confine ubuntu-core-launcher) elif [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then case "$SPREAD_SYSTEM" in diff --git a/tests/lib/tools/snapd.tool b/tests/lib/tools/snapd.tool index d780f748195..66eb151e2ef 100755 --- a/tests/lib/tools/snapd.tool +++ b/tests/lib/tools/snapd.tool @@ -49,7 +49,7 @@ main() { # Use the tool from the snapd snap when re-exec is enabled # Otherwise use the tool from the distro installation - if snap debug execution snap | grep -q "is-reexecd: true"; then + if tests.info is-reexec-enabled; then exec /snap/snapd/current/usr/lib/snapd/"$tool" "$@" else LIBEXEC_DIR="$(os.paths libexec-dir)" diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info new file mode 100755 index 00000000000..7230e178564 --- /dev/null +++ b/tests/lib/tools/tests.info @@ -0,0 +1,51 @@ +#!/bin/bash -e + +show_help() { + echo "usage: tests.info " + echo + echo "Supported commands:" + echo " is-snapd-pkg-repo: indicates when the snap packages is from the repository" + echo " is-reexec-enabled: indicates when snapd package is re-executing to snapd snap" +} + + +is_snapd_pkg_repo() { + [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ] +} + +is_reexec_enabled() { + snap debug execution snap | grep -q "is-reexecd: true" +} + +main() { + if [ $# -eq 0 ]; then + show_help + exit 0 + fi + + local subcommand="$1" + local action= + while [ $# -gt 0 ]; do + case "$subcommand" in + -h|--help) + show_help + exit 0 + ;; + *) + action=$(echo "$subcommand" | tr '-' '_') + shift + break + ;; + esac + done + + if [ -z "$(declare -f "$action")" ]; then + echo "tests.env: no such command: $subcommand" + show_help + exit 1 + fi + + "$action" "$@" +} + +main "$@" diff --git a/tests/main/classic-custom-device-reg/task.yaml b/tests/main/classic-custom-device-reg/task.yaml index 247f0c4849d..c60ae6945e5 100644 --- a/tests/main/classic-custom-device-reg/task.yaml +++ b/tests/main/classic-custom-device-reg/task.yaml @@ -16,7 +16,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -54,7 +54,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -65,7 +65,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index d81f47c7b9a..ce9f94d1ed7 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -15,7 +15,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -53,7 +53,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -63,7 +63,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index deae467b94f..440b211ea60 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -21,7 +21,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -51,7 +51,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -64,7 +64,7 @@ restore: | execute: | # In this scenario, the keys from the snapd deb are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-prepare-image/task.yaml b/tests/main/classic-prepare-image/task.yaml index cec9fccab1e..82b64a58efe 100644 --- a/tests/main/classic-prepare-image/task.yaml +++ b/tests/main/classic-prepare-image/task.yaml @@ -20,7 +20,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -50,7 +50,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -63,7 +63,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/classic-snapd-firstboot/task.yaml b/tests/main/classic-snapd-firstboot/task.yaml index 8a6cd66dfa5..353e3f66fa9 100644 --- a/tests/main/classic-snapd-firstboot/task.yaml +++ b/tests/main/classic-snapd-firstboot/task.yaml @@ -13,7 +13,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -53,7 +53,7 @@ prepare: | restore: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi @@ -63,7 +63,7 @@ restore: | execute: | # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || { [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ]; }; then + if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" exit fi diff --git a/tests/main/store-state/task.yaml b/tests/main/store-state/task.yaml index 8f521b4578e..419eba943c7 100644 --- a/tests/main/store-state/task.yaml +++ b/tests/main/store-state/task.yaml @@ -29,7 +29,7 @@ execute: | "$TESTSTOOLS"/store-state --help | MATCH "usage: store-state setup-fake-store " # Staging store cannot be used with snapd deb from the repository - if not [[ "$SNAPD_DEB_FROM_REPO" = true && -n "$(command -v apt)" ]]; then + if not tests.info is-snapd-pkg-repo; then # Setup staging store "$TESTSTOOLS"/store-state setup-staging-store snap info core | MATCH "store-url:.*https://staging-api.snapcraft.io" From 1338735ad7a10ea8663d2c9d982c0da223cce068 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 19 Sep 2024 13:53:04 -0300 Subject: [PATCH 09/33] skip tests which are testing with re-exec:0 and snap is comming from the repo --- tests/main/command-chain/task.yaml | 10 ++++++++++ tests/main/debug-execution/task.yaml | 5 +++++ tests/main/install-sideload-epochs/task.yaml | 9 +++++++++ tests/main/install-sideload/task.yaml | 10 ++++++++++ tests/main/snap-run-hook/task.yaml | 9 +++++++++ tests/main/writable-areas/task.yaml | 9 +++++++++ 6 files changed, 52 insertions(+) diff --git a/tests/main/command-chain/task.yaml b/tests/main/command-chain/task.yaml index 7ad5bea5e66..5dfdcd88c21 100644 --- a/tests/main/command-chain/task.yaml +++ b/tests/main/command-chain/task.yaml @@ -16,6 +16,11 @@ environment: ENVDUMP: /var/snap/command-chain/current/env prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "Build command chain snap" snap pack command-chain snap install --dangerous command-chain_1.0_all.snap @@ -28,6 +33,11 @@ prepare: | fi execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "Test that command-chain runs for hooks" [ "$(cat "$BREADCRUMB")" = "chain1 chain2 configure" ] MATCH '^CHAIN_1_RAN=1$' < "$ENVDUMP" diff --git a/tests/main/debug-execution/task.yaml b/tests/main/debug-execution/task.yaml index 064da5df086..0420e9d08eb 100644 --- a/tests/main/debug-execution/task.yaml +++ b/tests/main/debug-execution/task.yaml @@ -8,6 +8,11 @@ debug: | grep -n '' snap-*.out || true execute: | + # TODO: remove this check once snapd 2.65 is released + if tests.info is-snapd-pkg-repo; then + exit 0 + fi + snap debug execution snap > snap-default.out SNAP_REEXEC=0 snap debug execution snap > snap-no-reexec.out SNAP_REEXEC=1 snap debug execution snap > snap-yes-reexec.out diff --git a/tests/main/install-sideload-epochs/task.yaml b/tests/main/install-sideload-epochs/task.yaml index c70c2dda5c7..8de6dbe2a1f 100644 --- a/tests/main/install-sideload-epochs/task.yaml +++ b/tests/main/install-sideload-epochs/task.yaml @@ -12,10 +12,19 @@ environment: SNAP_REEXEC/reexec1: 1 prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi snap pack test-snapd-epoch-1 snap pack test-snapd-epoch-2 execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + rx="cannot refresh \"[^ \"]*\" to local snap with epoch [^ ]*, because it can't read the current epoch" snap try test-snapd-epoch-1 not snap try test-snapd-epoch-2 2> try.err diff --git a/tests/main/install-sideload/task.yaml b/tests/main/install-sideload/task.yaml index 06a0cbdf969..286c3e679ec 100644 --- a/tests/main/install-sideload/task.yaml +++ b/tests/main/install-sideload/task.yaml @@ -14,6 +14,11 @@ environment: SNAP_REEXEC/reexec1: 1 prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + for snap in basic test-snapd-tools basic-desktop test-snapd-devmode snap-hooks-bad-install; do snap pack "$TESTSLIB"/snaps/$snap done @@ -26,6 +31,11 @@ prepare: | fi execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "Sideloaded snap shows status" expected='^basic 1.0 installed$' snap install --dangerous ./basic_1.0_all.snap | MATCH "$expected" diff --git a/tests/main/snap-run-hook/task.yaml b/tests/main/snap-run-hook/task.yaml index d73c13e7ab2..f7c2a606166 100644 --- a/tests/main/snap-run-hook/task.yaml +++ b/tests/main/snap-run-hook/task.yaml @@ -12,6 +12,10 @@ environment: ENVDUMP: /var/snap/basic-hooks/current/hooks-env prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi "$TESTSTOOLS"/snaps-state install-local basic-hooks SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" if [ "$SNAP_REEXEC" = "1" ] && [ "$SNAP_MOUNT_DIR" != "/snap" ] && [ ! -L /snap ]; then @@ -22,6 +26,11 @@ prepare: | fi execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + # Note that `snap run` doesn't exit non-zero if the hook is missing, so we # check the output instead. diff --git a/tests/main/writable-areas/task.yaml b/tests/main/writable-areas/task.yaml index 4c0638bd90b..45b35a05656 100644 --- a/tests/main/writable-areas/task.yaml +++ b/tests/main/writable-areas/task.yaml @@ -13,6 +13,10 @@ environment: SNAP_REEXEC/reexec1: 1 prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi snap pack data-writer SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" if [ "$SNAP_REEXEC" = "1" ] && [ "$SNAP_MOUNT_DIR" != "/snap" ] && [ ! -L /snap ]; then @@ -23,6 +27,11 @@ prepare: | fi execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + snap install --dangerous data-writer_1.0_all.snap echo "Apps can write to writable areas" From b7d5efb128876a5a92d63603f5153f6482885c0c Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 19 Sep 2024 15:15:45 -0300 Subject: [PATCH 10/33] update the systems where snapd comes from the repo --- tests/lib/tools/tests.info | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info index 7230e178564..5f5735b38dc 100755 --- a/tests/lib/tools/tests.info +++ b/tests/lib/tools/tests.info @@ -10,7 +10,10 @@ show_help() { is_snapd_pkg_repo() { - [ "$SNAPD_DEB_FROM_REPO" = true ] && [ -n "$(command -v apt)" ] + [ "$SNAPD_DEB_FROM_REPO" = true ] && \ + [ -n "$(command -v apt)" ] && \ + os.query is-classic && \ + not os.query is-trusty } is_reexec_enabled() { From d9aa6db89f10d58c1416e98dde09489589ff594b Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 20 Sep 2024 08:16:50 -0300 Subject: [PATCH 11/33] skip another test when re-exec:0 --- tests/main/install-errors/task.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/main/install-errors/task.yaml b/tests/main/install-errors/task.yaml index b219856980b..1c9f29d8324 100644 --- a/tests/main/install-errors/task.yaml +++ b/tests/main/install-errors/task.yaml @@ -18,6 +18,11 @@ prepare: | "$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME" execute: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit 0 + fi + echo "Install unexisting snap prints error" if snap install unexisting.canonical; then echo "Installing unexisting snap should fail" From b0f4d8daff730868b7a60aebf75aac53c24b92c7 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 20 Sep 2024 10:31:16 -0300 Subject: [PATCH 12/33] Squashed 'tests/lib/external/snapd-testing-tools/' changes from 33c1d672c6..912131f2a6 912131f2a6 fix another shellcheck d27cc72346 update tests.pkgs to fix shellchecks git-subtree-dir: tests/lib/external/snapd-testing-tools git-subtree-split: 912131f2a6a7d3c807c890d94fe56367aca67039 --- tests/tests.pkgs/task.yaml | 19 ++++++++++++++----- tools/tests.pkgs.apt.sh | 3 ++- tools/tests.pkgs.dnf-yum.sh | 4 ++-- tools/tests.pkgs.pacman.sh | 3 ++- tools/tests.pkgs.zypper.sh | 3 ++- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/tests.pkgs/task.yaml b/tests/tests.pkgs/task.yaml index e3d5f96453d..05e6b9f98ee 100644 --- a/tests/tests.pkgs/task.yaml +++ b/tests/tests.pkgs/task.yaml @@ -47,13 +47,22 @@ execute: | not tests.pkgs is-installed test-snapd-pkg-1 not tests.pkgs is-installed test-snapd-pkg-2 - # Download curl package, trusty does not support apt download + # Download 2 packages, trusty does not support apt download + PKG1="grep" + PKG2="curl" + MAXDEPTH=1 + if os.query is-opensuse; then + MAXDEPTH=4 + fi + if os.query is-arch-linux || os.query is-fedora || os.query is-opensuse; then + PKG2="vi" + fi + if not os.query is-trusty; then - tests.pkgs download curl + tests.pkgs download "$PKG1" "$PKG2" if os.query is-opensuse; then - find . -maxdepth 4 -name 'curl.*' - else - find . -maxdepth 1 -name 'curl.*' + find . -maxdepth "$MAXDEPTH" -name "$PKG1*" + find . -maxdepth "$MAXDEPTH" -name "$PKG2*" fi fi diff --git a/tools/tests.pkgs.apt.sh b/tools/tests.pkgs.apt.sh index b0814dd5ab3..51e66b1efd8 100644 --- a/tools/tests.pkgs.apt.sh +++ b/tools/tests.pkgs.apt.sh @@ -81,5 +81,6 @@ cmd_remove() { } cmd_download() { - apt download $@ >/dev/null 2>&1 + # shellcheck disable=SC2068 + apt download -q $@ >/dev/null } diff --git a/tools/tests.pkgs.dnf-yum.sh b/tools/tests.pkgs.dnf-yum.sh index cbf1c9e2f7a..4b82f77c62b 100644 --- a/tools/tests.pkgs.dnf-yum.sh +++ b/tools/tests.pkgs.dnf-yum.sh @@ -77,8 +77,8 @@ cmd_remove() { cmd_download() { # shellcheck disable=SC2068 if [ "$(command -v dnf)" != "" ]; then - dnf download $@ >/dev/null 2>&1 + dnf download -q $@ else - yum reinstall --downloadonly $@ >/dev/null 2>&1 + yum reinstall --downloadonly -q -y --downloaddir "${PWD:-.}" $@ fi } diff --git a/tools/tests.pkgs.pacman.sh b/tools/tests.pkgs.pacman.sh index 5de68ecc73f..37c49fa2aa0 100644 --- a/tools/tests.pkgs.pacman.sh +++ b/tools/tests.pkgs.pacman.sh @@ -71,5 +71,6 @@ cmd_remove() { } cmd_download() { - pacman -Sw --noconfirm --cachedir "${PWD:-.}" $@ >/dev/null 2>&1 + # shellcheck disable=SC2068 + pacman -Sw --noconfirm --cachedir "${PWD:-.}" -q $@ >/dev/null } diff --git a/tools/tests.pkgs.zypper.sh b/tools/tests.pkgs.zypper.sh index 688c66ae52d..218102b6e60 100644 --- a/tools/tests.pkgs.zypper.sh +++ b/tools/tests.pkgs.zypper.sh @@ -66,5 +66,6 @@ cmd_remove() { } cmd_download() { - zypper --pkg-cache-dir "${PWD:-.}" download $@ >/dev/null 2>&1 + # shellcheck disable=SC2068 + zypper --pkg-cache-dir "${PWD:-.}" -q download $@ } From 6cb8cb6188144dd875dfca9f628c6abb5a2e1fec Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Mon, 23 Sep 2024 10:59:00 -0300 Subject: [PATCH 13/33] Adjust failing test to new re-exec scenario --- tests/main/interfaces-personal-files/task.yaml | 3 +++ tests/main/postrm-purge/task.yaml | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/main/interfaces-personal-files/task.yaml b/tests/main/interfaces-personal-files/task.yaml index c48839e742c..c5aa1e86c7b 100644 --- a/tests/main/interfaces-personal-files/task.yaml +++ b/tests/main/interfaces-personal-files/task.yaml @@ -86,6 +86,9 @@ execute: | echo "Find snap-confine" SNAP_CONFINE=$(os.paths libexec-dir)/snapd/snap-confine + if tests.info is-snapd-pkg-repo; then + SNAP_CONFINE="/snap/snapd/current$SNAP_CONFINE" + fi # on Ubuntu Core we need to use the correct path to ensure it is # appropriately confined by apparmor as it may be from the snapd # snap diff --git a/tests/main/postrm-purge/task.yaml b/tests/main/postrm-purge/task.yaml index 4cbd01cbe2f..e7e015df686 100644 --- a/tests/main/postrm-purge/task.yaml +++ b/tests/main/postrm-purge/task.yaml @@ -1,10 +1,17 @@ summary: Check that package remove and purge removes everything related to snaps + details: | Ensure that the purge we do when removing the snapd package really removes all snap related files from the host system. + systems: [-ubuntu-core-*] prepare: | + if tests.info is-snapd-pkg-repo; then + echo "This test is skipped when the snapd pkg isn't built from local" + exit + fi + # TODO: unify this with tests/main/snap-mgmt/task.yaml # note: no need to unset these since this spread test purges snapd totally @@ -57,6 +64,11 @@ prepare: | fi restore: | + if tests.info is-snapd-pkg-repo; then + echo "This test is skipped when the snapd pkg isn't built from local" + exit + fi + #shellcheck source=tests/lib/pkgdb.sh . "$TESTSLIB/pkgdb.sh" if [ -e pkg-removed ]; then @@ -68,6 +80,11 @@ debug: | systemctl --no-legend --full | grep -E 'snap\..*\.(service|timer|socket|slice)' || true execute: | + if tests.info is-snapd-pkg-repo; then + echo "This test is skipped when the snapd pkg isn't built from local" + exit + fi + systemctl --no-legend --full | MATCH 'snap\..*\.(service|timer|socket|slice)' #shellcheck source=tests/lib/pkgdb.sh From 9ddfe3086b247bf49cf7c65fd45508ac4074ce13 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Mon, 23 Sep 2024 12:11:47 -0300 Subject: [PATCH 14/33] fix other 2 tests using correct paths --- tests/main/security-device-cgroups-helper/task.yaml | 3 +++ tests/main/snap-confine-tmp-mount/task.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/main/security-device-cgroups-helper/task.yaml b/tests/main/security-device-cgroups-helper/task.yaml index ad6321a5a7f..d2fce5c8c0b 100644 --- a/tests/main/security-device-cgroups-helper/task.yaml +++ b/tests/main/security-device-cgroups-helper/task.yaml @@ -25,6 +25,9 @@ execute: | #shellcheck source=tests/lib/systems.sh . "$TESTSLIB/systems.sh" libexecdir=$(os.paths libexec-dir) + if tests.info is-snapd-pkg-repo; then + libexecdir="/snap/snapd/current$libexecdir" + fi echo "Given a snap is installed" "$TESTSTOOLS"/snaps-state install-local test-strict-cgroup-helper diff --git a/tests/main/snap-confine-tmp-mount/task.yaml b/tests/main/snap-confine-tmp-mount/task.yaml index 6753730a203..bc5fbd12dbf 100644 --- a/tests/main/snap-confine-tmp-mount/task.yaml +++ b/tests/main/snap-confine-tmp-mount/task.yaml @@ -25,6 +25,9 @@ debug: | execute: | SNAP_CONFINE=$(os.paths libexec-dir)/snapd/snap-confine + if tests.info is-snapd-pkg-repo; then + SNAP_CONFINE="/snap/snapd/current$SNAP_CONFINE" + fi # on Ubuntu Core we need to use the correct path to ensure it is # appropriately confined by apparmor as it may be from the snapd From 06f3a157d82cfa92350c7d9a0634690d05874764 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Mon, 23 Sep 2024 12:12:08 -0300 Subject: [PATCH 15/33] Squashed 'tests/lib/external/snapd-testing-tools/' changes from 912131f2a6..bae7faf8cb bae7faf8cb Update the quoting used to download packages git-subtree-dir: tests/lib/external/snapd-testing-tools git-subtree-split: bae7faf8cb3f04296bac9552ac0d1aa89d4e9139 --- tools/tests.pkgs | 3 ++- tools/tests.pkgs.apt.sh | 3 +-- tools/tests.pkgs.dnf-yum.sh | 5 ++--- tools/tests.pkgs.pacman.sh | 5 ++--- tools/tests.pkgs.zypper.sh | 6 ++---- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tools/tests.pkgs b/tools/tests.pkgs index 89c51a7a3a3..086fcfacc97 100755 --- a/tools/tests.pkgs +++ b/tools/tests.pkgs @@ -161,7 +161,8 @@ main() { cmd_remove $(remap_many "$@") ;; download) - cmd_download "$(remap_many "$@")" + # shellcheck disable=SC2046 + cmd_download $(remap_many "$@") ;; *) echo "tests.pkgs: unknown action $action" >&2 diff --git a/tools/tests.pkgs.apt.sh b/tools/tests.pkgs.apt.sh index 51e66b1efd8..391874b4ba5 100644 --- a/tools/tests.pkgs.apt.sh +++ b/tools/tests.pkgs.apt.sh @@ -81,6 +81,5 @@ cmd_remove() { } cmd_download() { - # shellcheck disable=SC2068 - apt download -q $@ >/dev/null + apt download -q "$@" >/dev/null } diff --git a/tools/tests.pkgs.dnf-yum.sh b/tools/tests.pkgs.dnf-yum.sh index 4b82f77c62b..8f6b1c9cb4d 100644 --- a/tools/tests.pkgs.dnf-yum.sh +++ b/tools/tests.pkgs.dnf-yum.sh @@ -75,10 +75,9 @@ cmd_remove() { } cmd_download() { - # shellcheck disable=SC2068 if [ "$(command -v dnf)" != "" ]; then - dnf download -q $@ + dnf download -q "$@" else - yum reinstall --downloadonly -q -y --downloaddir "${PWD:-.}" $@ + yum reinstall --downloadonly -q -y --downloaddir "${PWD:-.}" "$@" fi } diff --git a/tools/tests.pkgs.pacman.sh b/tools/tests.pkgs.pacman.sh index 37c49fa2aa0..d0341fff24c 100644 --- a/tools/tests.pkgs.pacman.sh +++ b/tools/tests.pkgs.pacman.sh @@ -66,11 +66,10 @@ cmd_list_installed() { } cmd_remove() { - # shellcheck disable=SC2068 - pacman -Rnsc --noconfirm $@ + pacman -Rnsc --noconfirm "$@" } cmd_download() { # shellcheck disable=SC2068 - pacman -Sw --noconfirm --cachedir "${PWD:-.}" -q $@ >/dev/null + pacman -Sw --noconfirm --cachedir "${PWD:-.}" -q "$@" >/dev/null } diff --git a/tools/tests.pkgs.zypper.sh b/tools/tests.pkgs.zypper.sh index 218102b6e60..61296783418 100644 --- a/tools/tests.pkgs.zypper.sh +++ b/tools/tests.pkgs.zypper.sh @@ -61,11 +61,9 @@ cmd_list_installed() { } cmd_remove() { - # shellcheck disable=SC2068 - zypper remove -y $@ + zypper remove -y "$@" } cmd_download() { - # shellcheck disable=SC2068 - zypper --pkg-cache-dir "${PWD:-.}" -q download $@ + zypper --pkg-cache-dir "${PWD:-.}" -q download "$@" } From 744c89a6ba2a60e596c1a389649cc18d21b41138 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Mon, 23 Sep 2024 17:07:59 -0300 Subject: [PATCH 16/33] some tests fixes Changes considering the changes done in the re-exec workflow --- tests/lib/tools/tests.info | 5 +++-- tests/main/install-errors/task.yaml | 5 +++++ tests/main/preseed-lxd/task.yaml | 12 ++++++++++-- tests/main/snap-run-devmode-classic/task.yaml | 4 ++-- tests/main/snap-seccomp/task.yaml | 6 +++++- tests/regression/lp-1871652/task.yaml | 3 ++- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info index 5f5735b38dc..d8782aa4ae9 100755 --- a/tests/lib/tools/tests.info +++ b/tests/lib/tools/tests.info @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/bin/bash + +set -e show_help() { echo "usage: tests.info " @@ -8,7 +10,6 @@ show_help() { echo " is-reexec-enabled: indicates when snapd package is re-executing to snapd snap" } - is_snapd_pkg_repo() { [ "$SNAPD_DEB_FROM_REPO" = true ] && \ [ -n "$(command -v apt)" ] && \ diff --git a/tests/main/install-errors/task.yaml b/tests/main/install-errors/task.yaml index 1c9f29d8324..02e3d139c35 100644 --- a/tests/main/install-errors/task.yaml +++ b/tests/main/install-errors/task.yaml @@ -14,6 +14,11 @@ environment: SNAP_REEXEC/withreexec: 1 prepare: | + # No needed to test the snap pkg when it is coming from the repository + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit 0 + fi + echo "Given a snap with a failing command is installed" "$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME" diff --git a/tests/main/preseed-lxd/task.yaml b/tests/main/preseed-lxd/task.yaml index edc17fe7135..1426e4621bd 100644 --- a/tests/main/preseed-lxd/task.yaml +++ b/tests/main/preseed-lxd/task.yaml @@ -51,7 +51,11 @@ prepare: | # for images that are already preseeded, we need to undo the preseeding there echo "Running preseed --reset for already preseeded cloud images" - SNAPD_DEBUG=1 /usr/lib/snapd/snap-preseed --reset "$IMAGE_MOUNTPOINT" + SNAP_PRESEED=/usr/lib/snapd/snap-preseed + if tests.info is-snapd-pkg-repo; then + SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + fi + SNAPD_DEBUG=1 "$SNAP_PRESEED" --reset "$IMAGE_MOUNTPOINT" restore: | if [ -f remove-lxd ]; then @@ -103,7 +107,11 @@ execute: | echo "Make latest snap-preseed command available in the lxd container" lxc exec my-ubuntu -- mkdir -p "$GOHOME" - lxc file push /usr/lib/snapd/snap-preseed "my-ubuntu/$GOHOME/" + SNAP_PRESEED=/usr/lib/snapd/snap-preseed + if tests.info is-snapd-pkg-repo; then + SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + fi + lxc file push "$SNAP_PRESEED" "my-ubuntu/$GOHOME/" lxc file push cloudimg.img "my-ubuntu/$GOHOME/" lxc file push preseed-prepare.sh "my-ubuntu/$GOHOME/" diff --git a/tests/main/snap-run-devmode-classic/task.yaml b/tests/main/snap-run-devmode-classic/task.yaml index 47cc5fdedf9..b569f565d4f 100644 --- a/tests/main/snap-run-devmode-classic/task.yaml +++ b/tests/main/snap-run-devmode-classic/task.yaml @@ -68,7 +68,7 @@ prepare: | coredir=edge-core-snap snapddir=snapd-from-branch - dpkg-deb -x "${SPREAD_PATH}"/../snapd_*.deb "${snapddir}" + dpkg-deb -x "$GOHOME"/snapd_*.deb "${snapddir}" pushd "${PROJECT_PATH}" SNAPD_SNAP_VERSION=$(./mkversion.sh --output-only) @@ -186,7 +186,7 @@ execute: | fi # undo the purging - apt install -y "$PROJECT_PATH/../"snapd_1337.*_amd64.deb + apt install -y "$GOHOME"/snapd_*.deb else echo "unknown variant $SNAP_TO_USE_FIRST" exit 1 diff --git a/tests/main/snap-seccomp/task.yaml b/tests/main/snap-seccomp/task.yaml index e0e07e8d1b2..c1896651822 100644 --- a/tests/main/snap-seccomp/task.yaml +++ b/tests/main/snap-seccomp/task.yaml @@ -15,13 +15,17 @@ priority: 100 environment: PROFILE: /var/lib/snapd/seccomp/bpf/snap.test-snapd-sh.sh - SNAP_SECCOMP: /usr/lib/snapd/snap-seccomp execute: | echo "Install test-snapd-sh and verify it works" snap install test-snapd-sh test-snapd-sh.sh -c 'echo hello' | MATCH hello + SNAP_SECCOMP=/usr/lib/snapd/snap-seccomp + if tests.info is-snapd-pkg-repo; then + SNAP_SECCOMP="/snap/snapd/current$SNAP_SECCOMP" + fi + # from the old test_complain echo "Test that the @complain keyword works" rm -f "${PROFILE}.bin2" diff --git a/tests/regression/lp-1871652/task.yaml b/tests/regression/lp-1871652/task.yaml index 7c0f0d8c96e..c211e96add2 100644 --- a/tests/regression/lp-1871652/task.yaml +++ b/tests/regression/lp-1871652/task.yaml @@ -43,9 +43,10 @@ prepare: | # system. Given that snapd on the system has just been built from source it # will have the custom 1337 version string. # NOTE: For SRU validation snapd is not built from source, so version does not match 1337 + # NOTE: When snapd is downloaded from the repo version does not match 1337 # NOTE: This step is only necessary while snapd in the store is older than the fix lxc file push /usr/bin/snap bionic/usr/bin/snap - if [ ! "$SRU_VALIDATION" = 1 ]; then + if [ ! "$SRU_VALIDATION" = 1 ] && ! tests.info is-snapd-pkg-repo ; then lxc exec bionic -- snap version | MATCH 1337 fi From 2e32c65177591e348837991a589c47a8018fca5a Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 24 Sep 2024 09:59:05 -0300 Subject: [PATCH 17/33] New set of test fixes Also we are inclugin some minor changes to address review comments --- tests/lib/prepare-restore.sh | 2 +- .../classic-prepare-image-no-core/task.yaml | 2 +- tests/main/snapd-homedirs-vendored/task.yaml | 23 +++++++++++++++++-- tests/main/snapd-snap/task.yaml | 2 +- tests/main/user-session-env/task.yaml | 6 ++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index 7301e4278b0..b6d2a447bed 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -588,7 +588,7 @@ prepare_project() { chown test:test -R "$SPREAD_PATH" if tests.info is-snapd-pkg-repo; then - ( cd "${GOHOME}" && tests.pkgs download snapd snap-confine ubuntu-core-launcher) + ( cd "${GOHOME}" && tests.pkgs download snapd snap-confine) elif [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then case "$SPREAD_SYSTEM" in ubuntu-*|debian-*) diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index 440b211ea60..5915ef2975b 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -31,7 +31,7 @@ prepare: | snap pack "$TESTSLIB/snaps/basic18" snap pack classic-gadget-18 - echo Expose the needed assertions through pkg fakestore + echo Expose the needed assertions through the fakestore cp "$TESTSLIB"/assertions/developer1.account "$STORE_DIR/asserts" cp "$TESTSLIB"/assertions/developer1.account-key "$STORE_DIR/asserts" # have snap use the fakestore for assertions (but nothing else) diff --git a/tests/main/snapd-homedirs-vendored/task.yaml b/tests/main/snapd-homedirs-vendored/task.yaml index 918aca507c8..cd6852ac8dc 100644 --- a/tests/main/snapd-homedirs-vendored/task.yaml +++ b/tests/main/snapd-homedirs-vendored/task.yaml @@ -7,12 +7,17 @@ details: | # On ubuntu 18 and below snapd-internal is not available # ubuntu-24*: the snapd deb is version 2.60.4 which is post-vendored apparmor. -systems: [ubuntu-18*, ubuntu-20*, ubuntu-22*, ubuntu-23*] +systems: [ubuntu-18*, ubuntu-20*, ubuntu-22*] environment: USERNAME: home-sweet-home prepare: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs to be executed when snapd deb is built from local" + exit + fi + # Create a new user in a non-standard location mkdir -p /remote/users useradd -b /remote/users -m -U "$USERNAME" @@ -28,6 +33,11 @@ prepare: | rm -rf "${unpackdir}" restore: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs to be executed when snapd deb is built from local" + exit + fi + userdel -f --remove "$USERNAME" rm -rf /remote/users @@ -38,6 +48,11 @@ restore: | distro_install_build_snapd debug: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs to be executed when snapd deb is built from local" + exit + fi + # output custom snap-confine snippets ls -l /var/lib/snapd/apparmor/snap-confine/ for f in /var/lib/snapd/apparmor/snap-confine/*; do @@ -46,6 +61,11 @@ debug: | done execute: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs to be executed when snapd deb is built from local" + exit + fi + echo "Downgrading the snapd deb to pre-vendored apparmor times" TARGET_VER="$(apt list -a snapd | grep -- -updates | cut -f2 -d' ')" # Ubuntu release on development doesn't have updates @@ -58,7 +78,6 @@ execute: | echo "But installing the vendored apparmor snapd with our changes" snap install --dangerous snapd_modified.snap - # Verify supported features snap debug sandbox-features --required apparmor:parser:snapd-internal snap debug sandbox-features --required apparmor:parser:include-if-exists diff --git a/tests/main/snapd-snap/task.yaml b/tests/main/snapd-snap/task.yaml index af285889cd4..3ad13034732 100644 --- a/tests/main/snapd-snap/task.yaml +++ b/tests/main/snapd-snap/task.yaml @@ -381,7 +381,7 @@ execute: | # not have credentials for esm.ubuntu.com if ! os.query is-xenial; then apt install -y --allow-downgrades "snapd/$(lsb_release -sc)" - tests.cleanup defer apt install -y "$PROJECT_PATH/../"snapd_1337.*_"$(dpkg-architecture -qDEB_HOST_ARCH)".deb + tests.cleanup defer apt install -y "$GOHOME"/snapd_*.deb # check snapd.apparmor is still working after downgrade if ! os.query is-xenial; then diff --git a/tests/main/user-session-env/task.yaml b/tests/main/user-session-env/task.yaml index 550c2f51631..9c32f4690ea 100644 --- a/tests/main/user-session-env/task.yaml +++ b/tests/main/user-session-env/task.yaml @@ -54,13 +54,17 @@ execute: | su -c 'sh -c "exec env"' -l "$TEST_FISH_USER" > "${TEST_FISH_USER}-child-env" SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" + LOCAL_PATH= + if tests.info is-snapd-pkg-repo; then + LOCAL_PATH=/snap/snapd/current + fi for user in test "$TEST_ZSH_USER" "$TEST_FISH_USER" ; do echo "checking $user" if [ -e "${user}-session-env" ]; then # Even though there's user session support, systemd may be too old and # not support user-environment-generators (specifically systemd versions # earlier than 233). - if [ -d /usr/lib/systemd/user-environment-generators ]; then + if [ -d "$LOCAL_PATH"/usr/lib/systemd/user-environment-generators ]; then MATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-session-env" MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-session-env" fi From 514dbb8a09f4fc65600ae931e3521b3edca4b44f Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 24 Sep 2024 10:54:25 -0300 Subject: [PATCH 18/33] update tests info command to check re-execution --- tests/lib/tools/snapd.tool | 2 +- tests/lib/tools/tests.info | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/lib/tools/snapd.tool b/tests/lib/tools/snapd.tool index 66eb151e2ef..9590d4320fa 100755 --- a/tests/lib/tools/snapd.tool +++ b/tests/lib/tools/snapd.tool @@ -49,7 +49,7 @@ main() { # Use the tool from the snapd snap when re-exec is enabled # Otherwise use the tool from the distro installation - if tests.info is-reexec-enabled; then + if tests.info is-reexec-done; then exec /snap/snapd/current/usr/lib/snapd/"$tool" "$@" else LIBEXEC_DIR="$(os.paths libexec-dir)" diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info index d8782aa4ae9..80a561adc50 100755 --- a/tests/lib/tools/tests.info +++ b/tests/lib/tools/tests.info @@ -1,13 +1,14 @@ #!/bin/bash -set -e +set -eu show_help() { - echo "usage: tests.info " - echo - echo "Supported commands:" - echo " is-snapd-pkg-repo: indicates when the snap packages is from the repository" - echo " is-reexec-enabled: indicates when snapd package is re-executing to snapd snap" + echo "usage: tests.info " + echo + echo "Supported commands:" + echo " is-snapd-pkg-repo: indicates when the snap packages is from the repository" + echo " is-reexec-req: indicates re-execution has been explicitly enabled through the env" + echo " is-reexec-done: indicates re-execution to the snapd snap is being effectively performed" } is_snapd_pkg_repo() { @@ -17,7 +18,11 @@ is_snapd_pkg_repo() { not os.query is-trusty } -is_reexec_enabled() { +is_reexec_req() { + snap debug execution snap | grep -q "is-reexec-enabled: true" +} + +is_reexec_done() { snap debug execution snap | grep -q "is-reexecd: true" } From ec96de41a7d416a2ee547f860ca96075c2c174fc Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 24 Sep 2024 13:28:50 -0300 Subject: [PATCH 19/33] fix uc16 which preparing --- tests/lib/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 10605402580..d93f4711c82 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -1192,7 +1192,7 @@ setup_reflash_magic() { # FIXME: install would be better but we don't have dpkg on # the image # unpack our freshly build snapd into the new snapd snap - dpkg-deb -x "$SPREAD_PATH"/../snapd_*.deb "$UNPACK_DIR" + dpkg-deb -x "$GOHOME"/snapd_*.deb "$UNPACK_DIR" # Debian packages don't carry permissions correctly and we use # post-inst hooks to fix that on classic systems. Here, as a special # case, fix the void directory we just unpacked. From e048240cb8bf999a656acb2a5877b8fdc9ac3d4b Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 24 Sep 2024 17:32:41 -0300 Subject: [PATCH 20/33] check SPREAD_SYSTEM is not core in tests.info This is needed because the check in prepare-restore is done before we have an ubuntu-core image --- tests/lib/tools/tests.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info index 80a561adc50..844ff71f246 100755 --- a/tests/lib/tools/tests.info +++ b/tests/lib/tools/tests.info @@ -14,7 +14,7 @@ show_help() { is_snapd_pkg_repo() { [ "$SNAPD_DEB_FROM_REPO" = true ] && \ [ -n "$(command -v apt)" ] && \ - os.query is-classic && \ + [[ "$SPREAD_SYSTEM" != ubuntu-core-* ]] && \ not os.query is-trusty } From cb9b585531f2c39ddbba79bff8a6159a9f0c7bb2 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Wed, 25 Sep 2024 14:49:58 -0300 Subject: [PATCH 21/33] use .skip in tests to determine if a phase has to be skipped Use snap-mount-dir to determine where snaps are mounted --- tests/lib/prepare-restore.sh | 3 +++ tests/lib/tools/snapd.tool | 3 ++- tests/main/classic-custom-device-reg/task.yaml | 14 ++++---------- tests/main/classic-firstboot/task.yaml | 13 +++---------- .../main/classic-prepare-image-no-core/task.yaml | 14 ++++---------- tests/main/classic-prepare-image/task.yaml | 14 ++++---------- tests/main/classic-snapd-firstboot/task.yaml | 13 +++---------- tests/main/command-chain/task.yaml | 6 ++---- tests/main/install-errors/task.yaml | 6 ++---- tests/main/install-sideload-epochs/task.yaml | 6 ++---- tests/main/install-sideload/task.yaml | 6 ++---- tests/main/interfaces-personal-files/task.yaml | 3 ++- tests/main/postrm-purge/task.yaml | 13 +++++-------- tests/main/preseed-lxd/task.yaml | 6 ++++-- tests/main/preseed/task.yaml | 15 ++++++++++++--- tests/main/snap-run-hook/task.yaml | 6 ++---- tests/main/snap-seccomp/task.yaml | 5 +++-- tests/main/snapd-homedirs-vendored/task.yaml | 16 ++++------------ .../snapd-snap-transition-auto-install/task.yaml | 10 ++++++++++ tests/main/snapd-snap/task.yaml | 3 ++- tests/main/user-session-env/task.yaml | 3 ++- tests/main/writable-areas/task.yaml | 6 ++---- 22 files changed, 79 insertions(+), 105 deletions(-) diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index b6d2a447bed..38c88d42723 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -587,6 +587,9 @@ prepare_project() { # go mod runs as root and will leave strange permissions chown test:test -R "$SPREAD_PATH" + # We are testing snapd snap on top of snapd from the archive + # of the tested distribution. Download snapd and snap-confine + # as they exist in the archive for further use. if tests.info is-snapd-pkg-repo; then ( cd "${GOHOME}" && tests.pkgs download snapd snap-confine) elif [ "$BUILD_SNAPD_FROM_CURRENT" = true ]; then diff --git a/tests/lib/tools/snapd.tool b/tests/lib/tools/snapd.tool index 9590d4320fa..0df7f73ef7c 100755 --- a/tests/lib/tools/snapd.tool +++ b/tests/lib/tools/snapd.tool @@ -50,7 +50,8 @@ main() { # Use the tool from the snapd snap when re-exec is enabled # Otherwise use the tool from the distro installation if tests.info is-reexec-done; then - exec /snap/snapd/current/usr/lib/snapd/"$tool" "$@" + MOUNT_DIR="$(os.paths snap-mount-dir)" + exec "$MOUNT_DIR"/snapd/current/usr/lib/snapd/"$tool" "$@" else LIBEXEC_DIR="$(os.paths libexec-dir)" exec "$LIBEXEC_DIR/snapd/$tool" "$@" diff --git a/tests/main/classic-custom-device-reg/task.yaml b/tests/main/classic-custom-device-reg/task.yaml index c60ae6945e5..7fe90317f49 100644 --- a/tests/main/classic-custom-device-reg/task.yaml +++ b/tests/main/classic-custom-device-reg/task.yaml @@ -18,6 +18,7 @@ prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" + touch .skip exit fi @@ -53,22 +54,15 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 + systemctl stop snapd.service snapd.socket fakedevicesvc rm -rf "$SEED_DIR" systemctl start snapd.socket snapd.service execute: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index ce9f94d1ed7..b5c2340e472 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -17,6 +17,7 @@ prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" + touch .skip exit fi @@ -52,21 +53,13 @@ prepare: | cp ./test-snapd-service_1.0_all.snap "$SEED_DIR/snaps/test-snapd-service.snap" restore: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 rm -rf "$SEED_DIR" systemctl start snapd.socket snapd.service execute: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 echo "Start the daemon with an empty state, this will make it import " echo "assertions from the $SEED_DIR/assertions subdirectory and " diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index 5915ef2975b..be92b7d97c8 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -23,6 +23,7 @@ prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" + touch .skip exit fi @@ -50,11 +51,8 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 + systemctl stop snapd.service snapd.socket fakedevicesvc rm -rf "$SEED_DIR" @@ -63,11 +61,7 @@ restore: | rm -rf "$ROOT" execute: | - # In this scenario, the keys from the snapd deb are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-prepare-image/task.yaml b/tests/main/classic-prepare-image/task.yaml index 82b64a58efe..76162c7730c 100644 --- a/tests/main/classic-prepare-image/task.yaml +++ b/tests/main/classic-prepare-image/task.yaml @@ -22,6 +22,7 @@ prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" + touch .skip exit fi @@ -49,11 +50,8 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 + systemctl stop snapd.service snapd.socket fakedevicesvc rm -rf "$SEED_DIR" @@ -62,11 +60,7 @@ restore: | rm -rf "$ROOT" execute: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-snapd-firstboot/task.yaml b/tests/main/classic-snapd-firstboot/task.yaml index 353e3f66fa9..58710e775e0 100644 --- a/tests/main/classic-snapd-firstboot/task.yaml +++ b/tests/main/classic-snapd-firstboot/task.yaml @@ -15,6 +15,7 @@ prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then echo "This test needs test keys to be trusted" + touch .skip exit fi @@ -52,21 +53,13 @@ prepare: | cp ./basic18_1.0_all.snap "$SEED_DIR/snaps/basic18.snap" restore: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 rm -rf "$SEED_DIR" systemctl start snapd.socket snapd.service execute: | - # In this scenario, the keys from the snapd pkg are used - if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - exit - fi + test -f .skip && exit 0 echo "Start the daemon with an empty state, this will make it import " echo "assertions from the $SEED_DIR/assertions subdirectory and " diff --git a/tests/main/command-chain/task.yaml b/tests/main/command-chain/task.yaml index 5dfdcd88c21..2e9e83e44ff 100644 --- a/tests/main/command-chain/task.yaml +++ b/tests/main/command-chain/task.yaml @@ -18,6 +18,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit fi @@ -33,10 +34,7 @@ prepare: | fi execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 echo "Test that command-chain runs for hooks" [ "$(cat "$BREADCRUMB")" = "chain1 chain2 configure" ] diff --git a/tests/main/install-errors/task.yaml b/tests/main/install-errors/task.yaml index 02e3d139c35..c140714d591 100644 --- a/tests/main/install-errors/task.yaml +++ b/tests/main/install-errors/task.yaml @@ -16,6 +16,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit 0 fi @@ -23,10 +24,7 @@ prepare: | "$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME" execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit 0 - fi + test -f .skip && exit 0 echo "Install unexisting snap prints error" if snap install unexisting.canonical; then diff --git a/tests/main/install-sideload-epochs/task.yaml b/tests/main/install-sideload-epochs/task.yaml index 8de6dbe2a1f..9ab63e7c181 100644 --- a/tests/main/install-sideload-epochs/task.yaml +++ b/tests/main/install-sideload-epochs/task.yaml @@ -14,16 +14,14 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit fi snap pack test-snapd-epoch-1 snap pack test-snapd-epoch-2 execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 rx="cannot refresh \"[^ \"]*\" to local snap with epoch [^ ]*, because it can't read the current epoch" snap try test-snapd-epoch-1 diff --git a/tests/main/install-sideload/task.yaml b/tests/main/install-sideload/task.yaml index 61f8b0d2c18..5bc6a2e7685 100644 --- a/tests/main/install-sideload/task.yaml +++ b/tests/main/install-sideload/task.yaml @@ -16,6 +16,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit fi @@ -31,10 +32,7 @@ prepare: | fi execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 echo "Sideloaded snap shows status" expected='^basic 1.0 installed$' diff --git a/tests/main/interfaces-personal-files/task.yaml b/tests/main/interfaces-personal-files/task.yaml index c5aa1e86c7b..d72de053787 100644 --- a/tests/main/interfaces-personal-files/task.yaml +++ b/tests/main/interfaces-personal-files/task.yaml @@ -87,7 +87,8 @@ execute: | echo "Find snap-confine" SNAP_CONFINE=$(os.paths libexec-dir)/snapd/snap-confine if tests.info is-snapd-pkg-repo; then - SNAP_CONFINE="/snap/snapd/current$SNAP_CONFINE" + MOUNT_DIR="$(os.paths snap-mount-dir)" + SNAP_CONFINE="$MOUNT_DIR/snapd/current$SNAP_CONFINE" fi # on Ubuntu Core we need to use the correct path to ensure it is # appropriately confined by apparmor as it may be from the snapd diff --git a/tests/main/postrm-purge/task.yaml b/tests/main/postrm-purge/task.yaml index e7e015df686..a7b190fb592 100644 --- a/tests/main/postrm-purge/task.yaml +++ b/tests/main/postrm-purge/task.yaml @@ -9,6 +9,7 @@ systems: [-ubuntu-core-*] prepare: | if tests.info is-snapd-pkg-repo; then echo "This test is skipped when the snapd pkg isn't built from local" + touch .skip exit fi @@ -64,10 +65,7 @@ prepare: | fi restore: | - if tests.info is-snapd-pkg-repo; then - echo "This test is skipped when the snapd pkg isn't built from local" - exit - fi + test -f .skip && exit 0 #shellcheck source=tests/lib/pkgdb.sh . "$TESTSLIB/pkgdb.sh" @@ -77,13 +75,12 @@ restore: | fi debug: | + test -f .skip && exit 0 + systemctl --no-legend --full | grep -E 'snap\..*\.(service|timer|socket|slice)' || true execute: | - if tests.info is-snapd-pkg-repo; then - echo "This test is skipped when the snapd pkg isn't built from local" - exit - fi + test -f .skip && exit 0 systemctl --no-legend --full | MATCH 'snap\..*\.(service|timer|socket|slice)' diff --git a/tests/main/preseed-lxd/task.yaml b/tests/main/preseed-lxd/task.yaml index 1426e4621bd..699ab671049 100644 --- a/tests/main/preseed-lxd/task.yaml +++ b/tests/main/preseed-lxd/task.yaml @@ -53,7 +53,8 @@ prepare: | echo "Running preseed --reset for already preseeded cloud images" SNAP_PRESEED=/usr/lib/snapd/snap-preseed if tests.info is-snapd-pkg-repo; then - SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + MOUNT_DIR="$(os.paths snap-mount-dir)" + SNAP_PRESEED="$MOUNT_DIR/snapd/current$SNAP_PRESEED" fi SNAPD_DEBUG=1 "$SNAP_PRESEED" --reset "$IMAGE_MOUNTPOINT" @@ -109,7 +110,8 @@ execute: | lxc exec my-ubuntu -- mkdir -p "$GOHOME" SNAP_PRESEED=/usr/lib/snapd/snap-preseed if tests.info is-snapd-pkg-repo; then - SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + MOUNT_DIR="$(os.paths snap-mount-dir)" + SNAP_PRESEED="$MOUNT_DIR/snapd/current$SNAP_PRESEED" fi lxc file push "$SNAP_PRESEED" "my-ubuntu/$GOHOME/" lxc file push cloudimg.img "my-ubuntu/$GOHOME/" diff --git a/tests/main/preseed/task.yaml b/tests/main/preseed/task.yaml index dff40f499c7..11a38e71f43 100644 --- a/tests/main/preseed/task.yaml +++ b/tests/main/preseed/task.yaml @@ -35,7 +35,11 @@ prepare: | # for images that are already preseeded, we need to undo the preseeding there echo "Running preseed --reset for already preseeded cloud images" - SNAPD_DEBUG=1 /usr/lib/snapd/snap-preseed --reset "$IMAGE_MOUNTPOINT" + SNAP_PRESEED=/usr/lib/snapd/snap-preseed + if tests.info is-snapd-pkg-repo; then + SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + fi + SNAPD_DEBUG=1 "$SNAP_PRESEED" --reset "$IMAGE_MOUNTPOINT" restore: | #shellcheck source=tests/lib/preseed.sh @@ -48,11 +52,16 @@ execute: | LXD_BASE_SNAP=core22 fi + SNAP_PRESEED=/usr/lib/snapd/snap-preseed + if tests.info is-snapd-pkg-repo; then + SNAP_PRESEED="/snap/snapd/current$SNAP_PRESEED" + fi + echo "Checking missing chroot path arg error" - /usr/lib/snapd/snap-preseed 2>&1 | MATCH "error: need chroot path as argument" + "$SNAP_PRESEED" 2>&1 | MATCH "error: need chroot path as argument" echo "Running pre-seeding" - SNAPD_DEBUG=1 /usr/lib/snapd/snap-preseed "$IMAGE_MOUNTPOINT" + SNAPD_DEBUG=1 "$SNAP_PRESEED" "$IMAGE_MOUNTPOINT" # precondition, core snap mounted by snap-preseed got unmounted mount | NOMATCH "snap-preseed" diff --git a/tests/main/snap-run-hook/task.yaml b/tests/main/snap-run-hook/task.yaml index f7c2a606166..7958f01c0d5 100644 --- a/tests/main/snap-run-hook/task.yaml +++ b/tests/main/snap-run-hook/task.yaml @@ -14,6 +14,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit fi "$TESTSTOOLS"/snaps-state install-local basic-hooks @@ -26,10 +27,7 @@ prepare: | fi execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 # Note that `snap run` doesn't exit non-zero if the hook is missing, so we # check the output instead. diff --git a/tests/main/snap-seccomp/task.yaml b/tests/main/snap-seccomp/task.yaml index c1896651822..9d8136ffbc5 100644 --- a/tests/main/snap-seccomp/task.yaml +++ b/tests/main/snap-seccomp/task.yaml @@ -15,15 +15,16 @@ priority: 100 environment: PROFILE: /var/lib/snapd/seccomp/bpf/snap.test-snapd-sh.sh + SNAP_SECCOMP: /usr/lib/snapd/snap-seccomp execute: | echo "Install test-snapd-sh and verify it works" snap install test-snapd-sh test-snapd-sh.sh -c 'echo hello' | MATCH hello - SNAP_SECCOMP=/usr/lib/snapd/snap-seccomp if tests.info is-snapd-pkg-repo; then - SNAP_SECCOMP="/snap/snapd/current$SNAP_SECCOMP" + MOUNT_DIR="$(os.paths snap-mount-dir)" + SNAP_SECCOMP="$MOUNT_DIR/snapd/current$SNAP_SECCOMP" fi # from the old test_complain diff --git a/tests/main/snapd-homedirs-vendored/task.yaml b/tests/main/snapd-homedirs-vendored/task.yaml index cd6852ac8dc..ebc52bfbaeb 100644 --- a/tests/main/snapd-homedirs-vendored/task.yaml +++ b/tests/main/snapd-homedirs-vendored/task.yaml @@ -15,6 +15,7 @@ environment: prepare: | if tests.info is-snapd-pkg-repo; then echo "This test needs to be executed when snapd deb is built from local" + touch .skip exit fi @@ -33,10 +34,7 @@ prepare: | rm -rf "${unpackdir}" restore: | - if tests.info is-snapd-pkg-repo; then - echo "This test needs to be executed when snapd deb is built from local" - exit - fi + test -f .skip && exit 0 userdel -f --remove "$USERNAME" rm -rf /remote/users @@ -48,10 +46,7 @@ restore: | distro_install_build_snapd debug: | - if tests.info is-snapd-pkg-repo; then - echo "This test needs to be executed when snapd deb is built from local" - exit - fi + test -f .skip && exit 0 # output custom snap-confine snippets ls -l /var/lib/snapd/apparmor/snap-confine/ @@ -61,10 +56,7 @@ debug: | done execute: | - if tests.info is-snapd-pkg-repo; then - echo "This test needs to be executed when snapd deb is built from local" - exit - fi + test -f .skip && exit 0 echo "Downgrading the snapd deb to pre-vendored apparmor times" TARGET_VER="$(apt list -a snapd | grep -- -updates | cut -f2 -d' ')" diff --git a/tests/main/snapd-snap-transition-auto-install/task.yaml b/tests/main/snapd-snap-transition-auto-install/task.yaml index 26fbb6bb49e..b6d0c9743c7 100644 --- a/tests/main/snapd-snap-transition-auto-install/task.yaml +++ b/tests/main/snapd-snap-transition-auto-install/task.yaml @@ -15,6 +15,11 @@ environment: SNAPD_SRC/core: "core" prepare: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs snapd deb built from local" + exit + fi + # Expect system preparation stage installed built snapd and core snaps. # Check this and remove all snaps to remove snapd. snap list core @@ -45,6 +50,11 @@ prepare: | not snap list snapd execute: | + if tests.info is-snapd-pkg-repo; then + echo "This test needs snapd deb built from local" + exit + fi + # check re-exec disabled, exec from snapd deb or re-exec from core snap snap_mount_dir="$(os.paths snap-mount-dir)" expect="" diff --git a/tests/main/snapd-snap/task.yaml b/tests/main/snapd-snap/task.yaml index 3ad13034732..d41b617a280 100644 --- a/tests/main/snapd-snap/task.yaml +++ b/tests/main/snapd-snap/task.yaml @@ -372,7 +372,8 @@ execute: | fi # reboot to ensure snapd.apparmor still works then too - if [ "$SPREAD_REBOOT" = "0" ]; then + + if [ "$SPREAD_REBOOT" = "0" ] && ! tests.info is-snapd-pkg-repo; then # downgrade the snapd deb from the distro package to test that we can # still handle the generated apparmor profiles etc from the snapd snap echo "Downgrading snapd to distro packaged version..." diff --git a/tests/main/user-session-env/task.yaml b/tests/main/user-session-env/task.yaml index 9c32f4690ea..7d1cc328f4d 100644 --- a/tests/main/user-session-env/task.yaml +++ b/tests/main/user-session-env/task.yaml @@ -56,7 +56,8 @@ execute: | SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" LOCAL_PATH= if tests.info is-snapd-pkg-repo; then - LOCAL_PATH=/snap/snapd/current + MOUNT_DIR="$(os.paths snap-mount-dir)" + LOCAL_PATH="$MOUNT_DIR/snapd/current" fi for user in test "$TEST_ZSH_USER" "$TEST_FISH_USER" ; do echo "checking $user" diff --git a/tests/main/writable-areas/task.yaml b/tests/main/writable-areas/task.yaml index 45b35a05656..433cda9eb69 100644 --- a/tests/main/writable-areas/task.yaml +++ b/tests/main/writable-areas/task.yaml @@ -15,6 +15,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip exit fi snap pack data-writer @@ -27,10 +28,7 @@ prepare: | fi execute: | - # No needed to test the snap pkg when it is coming from the repository - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 snap install --dangerous data-writer_1.0_all.snap From 463424e86490490188a9c90a6c1321358c066c88 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 26 Sep 2024 10:00:51 -0300 Subject: [PATCH 22/33] skip updating core snap when the snap pkg is not built from local --- tests/lib/prepare.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index d93f4711c82..5def54feb37 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -450,10 +450,13 @@ prepare_classic() { snap list | grep core - systemctl stop snapd.{service,socket} - # repack and also make a side copy of the core snap - update_core_snap_for_classic_reexec "$TESTSTMP/core_snap" - systemctl start snapd.{service,socket} + # No need to update the core snap when the snap pkg is not being built from local changes + if not tests.info is-snapd-pkg-repo; then + systemctl stop snapd.{service,socket} + # repack and also make a side copy of the core snap + update_core_snap_for_classic_reexec "$TESTSTMP/core_snap" + systemctl start snapd.{service,socket} + fi prepare_reexec_override prepare_memory_limit_override From 5758688c4d079b10332187139af411b55fae7a03 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Thu, 26 Sep 2024 17:52:35 -0300 Subject: [PATCH 23/33] save installed core snap when snap deb is used from the repo --- tests/lib/prepare.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 5def54feb37..bb1a519a256 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -154,6 +154,22 @@ setup_experimental_features() { fi } +save_installed_core_snap() { + local target_dir="${1-}" + + SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" + LIBEXEC_DIR="$(os.paths libexec-dir)" + core="$(readlink -f "$SNAP_MOUNT_DIR/core/current" || readlink -f "$SNAP_MOUNT_DIR/ubuntu-core/current")" + snap="$(mount | grep " $core" | head -n 1 | awk '{print $1}')" + + # make a copy for later use + if [ -n "$target_dir" ]; then + mkdir -p "$target_dir" + cp -av "$snap" "$target_dir/" + fi +} + + # update_core_snap_for_classic_reexec modifies the core snap for snapd re-exec # by injecting binaries from the installed snapd deb built from our modified code. # $1: directory where updated core snap should be copied (optional) @@ -451,7 +467,9 @@ prepare_classic() { snap list | grep core # No need to update the core snap when the snap pkg is not being built from local changes - if not tests.info is-snapd-pkg-repo; then + if tests.info is-snapd-pkg-repo; then + save_installed_core_snap "$TESTSTMP/core_snap" + else systemctl stop snapd.{service,socket} # repack and also make a side copy of the core snap update_core_snap_for_classic_reexec "$TESTSTMP/core_snap" From cd751ac4d85451e92b20705c94f49d75a1f720dc Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 09:58:57 -0300 Subject: [PATCH 24/33] copy also .orig core snap --- tests/lib/prepare.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index bb1a519a256..5d24671fbbd 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -165,7 +165,8 @@ save_installed_core_snap() { # make a copy for later use if [ -n "$target_dir" ]; then mkdir -p "$target_dir" - cp -av "$snap" "$target_dir/" + cp -av "$snap" "${target_dir}/${snap}" + cp "$snap" "${target_dir}/${snap}.orig" fi } From 8e5bfcb5ddd4318f0f1b70d17475298256c20b6c Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 10:57:53 -0300 Subject: [PATCH 25/33] change how we copy the core snap --- tests/lib/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 5d24671fbbd..ff911b890a9 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -165,7 +165,7 @@ save_installed_core_snap() { # make a copy for later use if [ -n "$target_dir" ]; then mkdir -p "$target_dir" - cp -av "$snap" "${target_dir}/${snap}" + cp "$snap" "${target_dir}/${snap}" cp "$snap" "${target_dir}/${snap}.orig" fi } From d7f37b9ab7359c1b3384d50f38c1940ce57c96fe Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 13:29:57 -0300 Subject: [PATCH 26/33] change the snapname used for core snap --- tests/lib/prepare.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index ff911b890a9..430e1c07b1a 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -161,12 +161,14 @@ save_installed_core_snap() { LIBEXEC_DIR="$(os.paths libexec-dir)" core="$(readlink -f "$SNAP_MOUNT_DIR/core/current" || readlink -f "$SNAP_MOUNT_DIR/ubuntu-core/current")" snap="$(mount | grep " $core" | head -n 1 | awk '{print $1}')" + snap_name="$(basename "$snap")" # make a copy for later use if [ -n "$target_dir" ]; then mkdir -p "$target_dir" - cp "$snap" "${target_dir}/${snap}" - cp "$snap" "${target_dir}/${snap}.orig" + + cp -av "$snap" "${target_dir}/${snap_name}" + cp "$snap" "${target_dir}/${snap_name}.orig" fi } From 1624ebf8ae00a474ee1c874bd5acf343f51aeb7e Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 16:03:15 -0300 Subject: [PATCH 27/33] skip saving the core snap --- tests/lib/prepare.sh | 23 +---------------------- tests/main/snapd-snap/task.yaml | 2 +- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 430e1c07b1a..b901fe95d08 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -154,25 +154,6 @@ setup_experimental_features() { fi } -save_installed_core_snap() { - local target_dir="${1-}" - - SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" - LIBEXEC_DIR="$(os.paths libexec-dir)" - core="$(readlink -f "$SNAP_MOUNT_DIR/core/current" || readlink -f "$SNAP_MOUNT_DIR/ubuntu-core/current")" - snap="$(mount | grep " $core" | head -n 1 | awk '{print $1}')" - snap_name="$(basename "$snap")" - - # make a copy for later use - if [ -n "$target_dir" ]; then - mkdir -p "$target_dir" - - cp -av "$snap" "${target_dir}/${snap_name}" - cp "$snap" "${target_dir}/${snap_name}.orig" - fi -} - - # update_core_snap_for_classic_reexec modifies the core snap for snapd re-exec # by injecting binaries from the installed snapd deb built from our modified code. # $1: directory where updated core snap should be copied (optional) @@ -470,9 +451,7 @@ prepare_classic() { snap list | grep core # No need to update the core snap when the snap pkg is not being built from local changes - if tests.info is-snapd-pkg-repo; then - save_installed_core_snap "$TESTSTMP/core_snap" - else + if ! tests.info is-snapd-pkg-repo; then systemctl stop snapd.{service,socket} # repack and also make a side copy of the core snap update_core_snap_for_classic_reexec "$TESTSTMP/core_snap" diff --git a/tests/main/snapd-snap/task.yaml b/tests/main/snapd-snap/task.yaml index d41b617a280..d652fd068e9 100644 --- a/tests/main/snapd-snap/task.yaml +++ b/tests/main/snapd-snap/task.yaml @@ -114,7 +114,7 @@ prepare: | # When the SRU validation tests are executed, the core snap is not repacked # and the var MODIFY_CORE_SNAP_FOR_REEXEC is 0 - if [ "$MODIFY_CORE_SNAP_FOR_REEXEC" = 1 ]; then + if [ "$MODIFY_CORE_SNAP_FOR_REEXEC" = 1 ] && ! tests.info is-snapd-pkg-repo; then CORE_SNAP_REV=$(snap list core | grep -v Name | awk '{print $3}') CORE_SNAP="/var/lib/snapd/snaps/core_${CORE_SNAP_REV}.snap" ORIG_CORE_SNAP=${CORE_SNAP}.orig From 5e1e52020eb7a93529f59cb61e066f77830d2d39 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 17:28:26 -0300 Subject: [PATCH 28/33] Fix error using snapcraft for testing in arm --- tests/lib/prepare.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index b901fe95d08..6857bff9f5f 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -550,6 +550,7 @@ build_snapd_snap() { ;; esac [ -d "${TARGET}" ] || mkdir -p "${TARGET}" + touch "${PROJECT_PATH}"/test-build chmod -R go+r "${PROJECT_PATH}/tests" # TODO: run_snapcraft does not currently guarantee or check the required version for building snapd run_snapcraft --use-lxd --verbosity quiet --output="snapd_from_snapcraft.snap" From 37487c1152d9a8c701b5996887643bbdfbe7fb69 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 17:30:20 -0300 Subject: [PATCH 29/33] make sure fips tests dont run with reexec=0 and snapd.deb from the repo --- tests/main/fips/task.yaml | 15 +++++++++++++++ tests/main/known/task.yaml | 5 +++++ tests/main/searching/task.yaml | 5 +++++ tests/main/snap-run/task.yaml | 10 ++++++++++ tests/main/try/task.yaml | 10 ++++++++++ tests/smoke/find-info/task.yaml | 5 +++++ tests/smoke/install/task.yaml | 10 ++++++++++ tests/smoke/remove/task.yaml | 5 +++++ tests/smoke/sandbox/task.yaml | 8 ++++++++ tests/smoke/versioning/task.yaml | 6 ++++++ 10 files changed, 79 insertions(+) diff --git a/tests/main/fips/task.yaml b/tests/main/fips/task.yaml index 3b0bf025066..2b9e511204e 100644 --- a/tests/main/fips/task.yaml +++ b/tests/main/fips/task.yaml @@ -7,10 +7,25 @@ systems: - ubuntu-fips-* debug: | + test -f .skip && exit 0 + cat snapd-map-fips.out || true cat snapd-map-non-fips.out || true execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + + # In this scenario, the keys from the snapd pkg are used + if [ "$TRUST_TEST_KEYS" = "false" ]; then + echo "This test needs test keys to be trusted" + touch .skip + exit + fi + pmap -p "$(pidof snapd)" > snapd-map.out case "$SPREAD_SYSTEM" in ubuntu-fips-*) diff --git a/tests/main/known/task.yaml b/tests/main/known/task.yaml index 4a1927f1cd5..9771d1ccdc6 100644 --- a/tests/main/known/task.yaml +++ b/tests/main/known/task.yaml @@ -7,6 +7,11 @@ details: | properties in general. execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "Listing all account assertions" snap known account|MATCH "^type: account$" snap known account|MATCH "^account-id: canonical$" diff --git a/tests/main/searching/task.yaml b/tests/main/searching/task.yaml index 1806af82477..e817ac780fa 100644 --- a/tests/main/searching/task.yaml +++ b/tests/main/searching/task.yaml @@ -15,6 +15,11 @@ backends: [-autopkgtest] systems: [-ubuntu-*-ppc64el, -ubuntu-*-s390x] execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "List all featured snaps" expected='(?s).*Name +Version +Publisher +Notes +Summary *\n(.*?\n)?.*' snap find > featured.txt diff --git a/tests/main/snap-run/task.yaml b/tests/main/snap-run/task.yaml index 3f3ff0e4ef1..7d206154ce5 100644 --- a/tests/main/snap-run/task.yaml +++ b/tests/main/snap-run/task.yaml @@ -14,13 +14,23 @@ environment: STRACE_STATIC_CHANNEL: candidate prepare: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + "$TESTSTOOLS"/snaps-state install-local basic-run "$TESTSTOOLS"/snaps-state install-local test-snapd-sh debug: | + test -f .skip && exit 0 + cat stderr || true execute: | + test -f .skip && exit 0 + echo "Running a trivial command causes no DENIED messages" test-snapd-sh.sh -c 'echo hello' dmesg | not grep DENIED diff --git a/tests/main/try/task.yaml b/tests/main/try/task.yaml index 5a982020a94..121e9164e50 100644 --- a/tests/main/try/task.yaml +++ b/tests/main/try/task.yaml @@ -15,15 +15,25 @@ environment: SERVICE_NAME: "test-service" prepare: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + # shellcheck source=tests/lib/network.sh . "$TESTSLIB"/network.sh make_network_service "$SERVICE_NAME" "$PORT" restore: | + test -f .skip && exit 0 + systemctl stop "$SERVICE_NAME" rm -f "$READABLE_FILE" execute: | + test -f .skip && exit 0 + echo "Given a buildable snap in a known directory" echo "When try is executed on that directory" snap try "$TESTSLIB"/snaps/test-snapd-tools diff --git a/tests/smoke/find-info/task.yaml b/tests/smoke/find-info/task.yaml index dafa1d04493..8929055925d 100644 --- a/tests/smoke/find-info/task.yaml +++ b/tests/smoke/find-info/task.yaml @@ -6,6 +6,11 @@ details: | display detailed information about it by using the "snap info" command. execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + echo "Ensure 'snap find' works" snap find test-snapd-tools | MATCH ^test-snapd-tools diff --git a/tests/smoke/install/task.yaml b/tests/smoke/install/task.yaml index 3e1549b0953..13c3e855c30 100644 --- a/tests/smoke/install/task.yaml +++ b/tests/smoke/install/task.yaml @@ -10,18 +10,28 @@ details: | snaps: core, core18, core20 and core22. restore: | + test -f .skip && exit 0 + rm -f /home/test/stderr.log rm -f /home/test/stdout.log # required! in autopkgtest no suite restore is run at all snap remove --purge test-snapd-sh debug: | + test -f .skip && exit 0 + if test -e stderr.log; then echo "content of stderr.log" cat stderr.log fi execute: | + # When s# When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + #shellcheck source=tests/lib/systems.sh . "$TESTSLIB"/systems.sh diff --git a/tests/smoke/remove/task.yaml b/tests/smoke/remove/task.yaml index a7fa6299b6c..a611925ed0e 100644 --- a/tests/smoke/remove/task.yaml +++ b/tests/smoke/remove/task.yaml @@ -7,6 +7,11 @@ details: | removal no leftovers remain in the mounting area. execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + exit + fi + "$TESTSTOOLS"/snaps-state install-local test-snapd-sh SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" diff --git a/tests/smoke/sandbox/task.yaml b/tests/smoke/sandbox/task.yaml index f11164e80db..5d005624954 100644 --- a/tests/smoke/sandbox/task.yaml +++ b/tests/smoke/sandbox/task.yaml @@ -9,12 +9,20 @@ details: | the CPU supports one. restore: | + test -f .skip && exit 0 + rm -f /home/test/foo # required! in autopkgtest no suite restore is run at all snap remove --purge test-snapd-sandbox snap remove --purge test-snapd-hello-multi-arch execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + if [ "$(snap debug confinement)" != "strict" ]; then if os.query is-ubuntu; then echo "all ubuntu systems must have strict confinement" diff --git a/tests/smoke/versioning/task.yaml b/tests/smoke/versioning/task.yaml index f4b5a870354..903a2be24e0 100644 --- a/tests/smoke/versioning/task.yaml +++ b/tests/smoke/versioning/task.yaml @@ -9,6 +9,12 @@ details: | modified the code in unintended ways. execute: | + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + exit + fi + # TODO: fix dirty version number on riscv echo "Ensure the version number is not 'dirty'" if not uname -m | MATCH riscv64; then From c0ccc680ef345173e25c9d9ba5b682181fefdbd6 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 17:37:06 -0300 Subject: [PATCH 30/33] simplify how fips tests are skipped --- spread.yaml | 4 ++++ tests/main/fips/task.yaml | 6 +----- tests/main/known/task.yaml | 5 +---- tests/main/searching/task.yaml | 5 +---- tests/main/snap-run/task.yaml | 6 +----- tests/main/try/task.yaml | 6 +----- tests/smoke/find-info/task.yaml | 5 +---- tests/smoke/install/task.yaml | 6 +----- tests/smoke/remove/task.yaml | 5 +---- tests/smoke/sandbox/task.yaml | 6 +----- 10 files changed, 13 insertions(+), 41 deletions(-) diff --git a/spread.yaml b/spread.yaml index 2f159a21b1f..1f1bdaaab79 100644 --- a/spread.yaml +++ b/spread.yaml @@ -1432,6 +1432,10 @@ suites: "$TESTSLIB"/prepare-restore.sh --prepare-suite prepare-each: | "$TESTSLIB"/prepare-restore.sh --prepare-suite-each + # When snapd.deb is from the repo, we just need to test when re-exec is enabled + if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then + touch .skip + fi restore-each: | "$TESTSLIB"/prepare-restore.sh --restore-suite-each restore: | diff --git a/tests/main/fips/task.yaml b/tests/main/fips/task.yaml index 2b9e511204e..9ec331ffc44 100644 --- a/tests/main/fips/task.yaml +++ b/tests/main/fips/task.yaml @@ -13,11 +13,7 @@ debug: | cat snapd-map-non-fips.out || true execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + test -f .skip && exit 0 # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ]; then diff --git a/tests/main/known/task.yaml b/tests/main/known/task.yaml index 9771d1ccdc6..8d501b2574d 100644 --- a/tests/main/known/task.yaml +++ b/tests/main/known/task.yaml @@ -7,10 +7,7 @@ details: | properties in general. execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 echo "Listing all account assertions" snap known account|MATCH "^type: account$" diff --git a/tests/main/searching/task.yaml b/tests/main/searching/task.yaml index e817ac780fa..55bd6f959ad 100644 --- a/tests/main/searching/task.yaml +++ b/tests/main/searching/task.yaml @@ -15,10 +15,7 @@ backends: [-autopkgtest] systems: [-ubuntu-*-ppc64el, -ubuntu-*-s390x] execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 echo "List all featured snaps" expected='(?s).*Name +Version +Publisher +Notes +Summary *\n(.*?\n)?.*' diff --git a/tests/main/snap-run/task.yaml b/tests/main/snap-run/task.yaml index 7d206154ce5..970e8d5addc 100644 --- a/tests/main/snap-run/task.yaml +++ b/tests/main/snap-run/task.yaml @@ -14,11 +14,7 @@ environment: STRACE_STATIC_CHANNEL: candidate prepare: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + test -f .skip && exit 0 "$TESTSTOOLS"/snaps-state install-local basic-run "$TESTSTOOLS"/snaps-state install-local test-snapd-sh diff --git a/tests/main/try/task.yaml b/tests/main/try/task.yaml index 121e9164e50..44b878a9bee 100644 --- a/tests/main/try/task.yaml +++ b/tests/main/try/task.yaml @@ -15,11 +15,7 @@ environment: SERVICE_NAME: "test-service" prepare: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + test -f .skip && exit 0 # shellcheck source=tests/lib/network.sh . "$TESTSLIB"/network.sh diff --git a/tests/smoke/find-info/task.yaml b/tests/smoke/find-info/task.yaml index 8929055925d..9fdcef02e7c 100644 --- a/tests/smoke/find-info/task.yaml +++ b/tests/smoke/find-info/task.yaml @@ -6,10 +6,7 @@ details: | display detailed information about it by using the "snap info" command. execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 echo "Ensure 'snap find' works" snap find test-snapd-tools | MATCH ^test-snapd-tools diff --git a/tests/smoke/install/task.yaml b/tests/smoke/install/task.yaml index 13c3e855c30..055b12e3ae4 100644 --- a/tests/smoke/install/task.yaml +++ b/tests/smoke/install/task.yaml @@ -26,11 +26,7 @@ debug: | fi execute: | - # When s# When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + test -f .skip && exit 0 #shellcheck source=tests/lib/systems.sh . "$TESTSLIB"/systems.sh diff --git a/tests/smoke/remove/task.yaml b/tests/smoke/remove/task.yaml index a611925ed0e..c911389903f 100644 --- a/tests/smoke/remove/task.yaml +++ b/tests/smoke/remove/task.yaml @@ -7,10 +7,7 @@ details: | removal no leftovers remain in the mounting area. execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - exit - fi + test -f .skip && exit 0 "$TESTSTOOLS"/snaps-state install-local test-snapd-sh diff --git a/tests/smoke/sandbox/task.yaml b/tests/smoke/sandbox/task.yaml index 5d005624954..e326256e142 100644 --- a/tests/smoke/sandbox/task.yaml +++ b/tests/smoke/sandbox/task.yaml @@ -17,11 +17,7 @@ restore: | snap remove --purge test-snapd-hello-multi-arch execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + test -f .skip && exit 0 if [ "$(snap debug confinement)" != "strict" ]; then if os.query is-ubuntu; then From b14c80d750cbf645e948601a0f72f0dd38ece103 Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 17:55:09 -0300 Subject: [PATCH 31/33] fix indentation on test --- tests/smoke/find-info/task.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/smoke/find-info/task.yaml b/tests/smoke/find-info/task.yaml index 9fdcef02e7c..6514fc353ef 100644 --- a/tests/smoke/find-info/task.yaml +++ b/tests/smoke/find-info/task.yaml @@ -6,11 +6,10 @@ details: | display detailed information about it by using the "snap info" command. execute: | - test -f .skip && exit 0 + test -f .skip && exit 0 echo "Ensure 'snap find' works" snap find test-snapd-tools | MATCH ^test-snapd-tools echo "Ensure we can see useful info for it" snap info test-snapd-tools | MATCH '^name:\ +test-snapd-tools' - From cde70a7241195414e1ee5adff9b185e0c36b456d Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Fri, 27 Sep 2024 20:52:35 -0300 Subject: [PATCH 32/33] Make sure we save core snap in TESTSTMP/core_snap --- tests/lib/prepare.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 6857bff9f5f..2189a50bd37 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -154,6 +154,25 @@ setup_experimental_features() { fi } +save_installed_core_snap() { + local target_dir="${1-}" + + SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" + LIBEXEC_DIR="$(os.paths libexec-dir)" + core="$(readlink -f "$SNAP_MOUNT_DIR/core/current" || readlink -f "$SNAP_MOUNT_DIR/ubuntu-core/current")" + snap="$(mount | grep " $core" | head -n 1 | awk '{print $1}')" + snap_name="$(basename "$snap")" + + # make a copy for later use + if [ -n "$target_dir" ]; then + mkdir -p "$target_dir" + + cp -av "$snap" "${target_dir}/${snap_name}" + cp "$snap" "${target_dir}/${snap_name}.orig" + fi +} + + # update_core_snap_for_classic_reexec modifies the core snap for snapd re-exec # by injecting binaries from the installed snapd deb built from our modified code. # $1: directory where updated core snap should be copied (optional) @@ -451,7 +470,9 @@ prepare_classic() { snap list | grep core # No need to update the core snap when the snap pkg is not being built from local changes - if ! tests.info is-snapd-pkg-repo; then + if tests.info is-snapd-pkg-repo; then + save_installed_core_snap "$TESTSTMP/core_snap" + else systemctl stop snapd.{service,socket} # repack and also make a side copy of the core snap update_core_snap_for_classic_reexec "$TESTSTMP/core_snap" From b50e533c797e7c6b1df338da4840e2259832117a Mon Sep 17 00:00:00 2001 From: Sergio Cazzolato Date: Tue, 1 Oct 2024 16:00:44 -0300 Subject: [PATCH 33/33] use tests.exec tool to skip tests --- spread.yaml | 2 +- tests/bin/tests.exec | 1 + tests/lib/prepare.sh | 6 +- tests/lib/tools/snapd.tool | 2 +- tests/lib/tools/tests.exec | 58 +++++++++++++++++++ tests/lib/tools/tests.info | 12 ++-- .../main/classic-custom-device-reg/task.yaml | 8 +-- tests/main/classic-firstboot/task.yaml | 8 +-- .../classic-prepare-image-no-core/task.yaml | 8 +-- tests/main/classic-prepare-image/task.yaml | 8 +-- tests/main/classic-snapd-firstboot/task.yaml | 8 +-- tests/main/command-chain/task.yaml | 6 +- tests/main/fips/task.yaml | 8 +-- tests/main/install-errors/task.yaml | 6 +- tests/main/install-sideload-epochs/task.yaml | 6 +- tests/main/install-sideload/task.yaml | 6 +- tests/main/known/task.yaml | 2 +- tests/main/postrm-purge/task.yaml | 10 ++-- tests/main/searching/task.yaml | 2 +- tests/main/snap-run-hook/task.yaml | 6 +- tests/main/snap-run/task.yaml | 6 +- tests/main/snapd-homedirs-vendored/task.yaml | 10 ++-- tests/main/try/task.yaml | 6 +- tests/main/writable-areas/task.yaml | 5 +- tests/smoke/find-info/task.yaml | 2 +- tests/smoke/install/task.yaml | 6 +- tests/smoke/remove/task.yaml | 2 +- tests/smoke/sandbox/task.yaml | 4 +- tests/smoke/versioning/task.yaml | 6 +- 29 files changed, 125 insertions(+), 95 deletions(-) create mode 120000 tests/bin/tests.exec create mode 100755 tests/lib/tools/tests.exec diff --git a/spread.yaml b/spread.yaml index 1f1bdaaab79..b04ebe7b8af 100644 --- a/spread.yaml +++ b/spread.yaml @@ -1434,7 +1434,7 @@ suites: "$TESTSLIB"/prepare-restore.sh --prepare-suite-each # When snapd.deb is from the repo, we just need to test when re-exec is enabled if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip + tests.exec skip-test "When snapd.deb is from the repo, we just need to test when re-exec is enabled" && exit 0 fi restore-each: | "$TESTSLIB"/prepare-restore.sh --restore-suite-each diff --git a/tests/bin/tests.exec b/tests/bin/tests.exec new file mode 120000 index 00000000000..689b4eb7189 --- /dev/null +++ b/tests/bin/tests.exec @@ -0,0 +1 @@ +../lib/tools/tests.exec \ No newline at end of file diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 2189a50bd37..4a578381493 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -159,7 +159,7 @@ save_installed_core_snap() { SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" LIBEXEC_DIR="$(os.paths libexec-dir)" - core="$(readlink -f "$SNAP_MOUNT_DIR/core/current" || readlink -f "$SNAP_MOUNT_DIR/ubuntu-core/current")" + core="$(readlink -f "$SNAP_MOUNT_DIR/core/current")" snap="$(mount | grep " $core" | head -n 1 | awk '{print $1}')" snap_name="$(basename "$snap")" @@ -469,7 +469,9 @@ prepare_classic() { snap list | grep core - # No need to update the core snap when the snap pkg is not being built from local changes + # With reexec, and on classic, the snapd snap is preferred over the core snap for reexecution target, + # so to be as close as possible to the actual real life scenarios, we only update the snapd snap. + # The tests alreday ensure that snapd snap is installed. if tests.info is-snapd-pkg-repo; then save_installed_core_snap "$TESTSTMP/core_snap" else diff --git a/tests/lib/tools/snapd.tool b/tests/lib/tools/snapd.tool index 0df7f73ef7c..6af476b5e1e 100755 --- a/tests/lib/tools/snapd.tool +++ b/tests/lib/tools/snapd.tool @@ -49,7 +49,7 @@ main() { # Use the tool from the snapd snap when re-exec is enabled # Otherwise use the tool from the distro installation - if tests.info is-reexec-done; then + if tests.info is-reexec-in-use; then MOUNT_DIR="$(os.paths snap-mount-dir)" exec "$MOUNT_DIR"/snapd/current/usr/lib/snapd/"$tool" "$@" else diff --git a/tests/lib/tools/tests.exec b/tests/lib/tools/tests.exec new file mode 100755 index 00000000000..d33ae520bbc --- /dev/null +++ b/tests/lib/tools/tests.exec @@ -0,0 +1,58 @@ +#!/bin/bash + +set -eu + +show_help() { + echo "usage: tests.exec skip-test [MSG]" + echo "usage: tests.exec is-skipped" + echo + echo "Supported commands:" + echo " skip-test: indicates the test has to be skipped and saves the raeson" + echo " is-skipped: check if the test has to be skipped and prints the raeson" +} + +skip_test() { + local raeson="${1:-}" + echo "$raeson" > tests.exec +} + +is_skipped() { + if [ -f tests.exec ]; then + echo "skip raeson: $(cat tests.exec)" + return 0 + fi + return 1 +} + +main() { + if [ $# -eq 0 ]; then + show_help + exit 0 + fi + + local subcommand="$1" + local action= + while [ $# -gt 0 ]; do + case "$subcommand" in + -h|--help) + show_help + exit 0 + ;; + *) + action=$(echo "$subcommand" | tr '-' '_') + shift + break + ;; + esac + done + + if [ -z "$(declare -f "$action")" ]; then + echo "tests.exec: no such command: $subcommand" + show_help + exit 1 + fi + + "$action" "$@" +} + +main "$@" diff --git a/tests/lib/tools/tests.info b/tests/lib/tools/tests.info index 844ff71f246..aaba49c5be8 100755 --- a/tests/lib/tools/tests.info +++ b/tests/lib/tools/tests.info @@ -6,9 +6,9 @@ show_help() { echo "usage: tests.info " echo echo "Supported commands:" - echo " is-snapd-pkg-repo: indicates when the snap packages is from the repository" - echo " is-reexec-req: indicates re-execution has been explicitly enabled through the env" - echo " is-reexec-done: indicates re-execution to the snapd snap is being effectively performed" + echo " is-snapd-pkg-repo: indicates when the snapd package is from the repository" + echo " is-reexec-enabled: indicates re-execution has been explicitly enabled through the env" + echo " is-reexec-in-use: indicates re-execution to the snapd snap is being effectively performed" } is_snapd_pkg_repo() { @@ -18,11 +18,11 @@ is_snapd_pkg_repo() { not os.query is-trusty } -is_reexec_req() { +is_reexec_enabled() { snap debug execution snap | grep -q "is-reexec-enabled: true" } -is_reexec_done() { +is_reexec_in_use() { snap debug execution snap | grep -q "is-reexecd: true" } @@ -49,7 +49,7 @@ main() { done if [ -z "$(declare -f "$action")" ]; then - echo "tests.env: no such command: $subcommand" + echo "tests.info: no such command: $subcommand" show_help exit 1 fi diff --git a/tests/main/classic-custom-device-reg/task.yaml b/tests/main/classic-custom-device-reg/task.yaml index 7fe90317f49..5ebae04ea37 100644 --- a/tests/main/classic-custom-device-reg/task.yaml +++ b/tests/main/classic-custom-device-reg/task.yaml @@ -17,9 +17,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi snap pack "$TESTSLIB/snaps/classic-gadget" @@ -54,7 +52,7 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl stop snapd.service snapd.socket fakedevicesvc @@ -62,7 +60,7 @@ restore: | systemctl start snapd.socket snapd.service execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-firstboot/task.yaml b/tests/main/classic-firstboot/task.yaml index b5c2340e472..8b1e01d8ca7 100644 --- a/tests/main/classic-firstboot/task.yaml +++ b/tests/main/classic-firstboot/task.yaml @@ -16,9 +16,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi snap pack "$TESTSLIB/snaps/basic" @@ -53,13 +51,13 @@ prepare: | cp ./test-snapd-service_1.0_all.snap "$SEED_DIR/snaps/test-snapd-service.snap" restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 rm -rf "$SEED_DIR" systemctl start snapd.socket snapd.service execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Start the daemon with an empty state, this will make it import " echo "assertions from the $SEED_DIR/assertions subdirectory and " diff --git a/tests/main/classic-prepare-image-no-core/task.yaml b/tests/main/classic-prepare-image-no-core/task.yaml index be92b7d97c8..8da92f0fcd3 100644 --- a/tests/main/classic-prepare-image-no-core/task.yaml +++ b/tests/main/classic-prepare-image-no-core/task.yaml @@ -22,9 +22,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi "$TESTSTOOLS"/store-state setup-fake-store "$STORE_DIR" @@ -51,7 +49,7 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl stop snapd.service snapd.socket fakedevicesvc @@ -61,7 +59,7 @@ restore: | rm -rf "$ROOT" execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-prepare-image/task.yaml b/tests/main/classic-prepare-image/task.yaml index 76162c7730c..b15a06f03d5 100644 --- a/tests/main/classic-prepare-image/task.yaml +++ b/tests/main/classic-prepare-image/task.yaml @@ -21,9 +21,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi "$TESTSTOOLS"/store-state setup-fake-store "$STORE_DIR" @@ -50,7 +48,7 @@ prepare: | systemd-run --unit fakedevicesvc fakedevicesvc localhost:11029 restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl stop snapd.service snapd.socket fakedevicesvc @@ -60,7 +58,7 @@ restore: | rm -rf "$ROOT" execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 #shellcheck source=tests/lib/core-config.sh . "$TESTSLIB"/core-config.sh diff --git a/tests/main/classic-snapd-firstboot/task.yaml b/tests/main/classic-snapd-firstboot/task.yaml index 58710e775e0..af033909ddb 100644 --- a/tests/main/classic-snapd-firstboot/task.yaml +++ b/tests/main/classic-snapd-firstboot/task.yaml @@ -14,9 +14,7 @@ environment: prepare: | # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ] || tests.info is-snapd-pkg-repo; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi snap pack "$TESTSLIB/snaps/basic18" @@ -53,13 +51,13 @@ prepare: | cp ./basic18_1.0_all.snap "$SEED_DIR/snaps/basic18.snap" restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 rm -rf "$SEED_DIR" systemctl start snapd.socket snapd.service execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Start the daemon with an empty state, this will make it import " echo "assertions from the $SEED_DIR/assertions subdirectory and " diff --git a/tests/main/command-chain/task.yaml b/tests/main/command-chain/task.yaml index 2e9e83e44ff..98775849588 100644 --- a/tests/main/command-chain/task.yaml +++ b/tests/main/command-chain/task.yaml @@ -16,10 +16,8 @@ environment: ENVDUMP: /var/snap/command-chain/current/env prepare: | - # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi echo "Build command chain snap" @@ -34,7 +32,7 @@ prepare: | fi execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Test that command-chain runs for hooks" [ "$(cat "$BREADCRUMB")" = "chain1 chain2 configure" ] diff --git a/tests/main/fips/task.yaml b/tests/main/fips/task.yaml index 9ec331ffc44..e3e1734acb9 100644 --- a/tests/main/fips/task.yaml +++ b/tests/main/fips/task.yaml @@ -7,19 +7,17 @@ systems: - ubuntu-fips-* debug: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 cat snapd-map-fips.out || true cat snapd-map-non-fips.out || true execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 # In this scenario, the keys from the snapd pkg are used if [ "$TRUST_TEST_KEYS" = "false" ]; then - echo "This test needs test keys to be trusted" - touch .skip - exit + tests.exec skip-test "This test needs test keys to be trusted" && exit 0 fi pmap -p "$(pidof snapd)" > snapd-map.out diff --git a/tests/main/install-errors/task.yaml b/tests/main/install-errors/task.yaml index c140714d591..145e337e57f 100644 --- a/tests/main/install-errors/task.yaml +++ b/tests/main/install-errors/task.yaml @@ -14,17 +14,15 @@ environment: SNAP_REEXEC/withreexec: 1 prepare: | - # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit 0 + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi echo "Given a snap with a failing command is installed" "$TESTSTOOLS"/snaps-state install-local "$SNAP_NAME" execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Install unexisting snap prints error" if snap install unexisting.canonical; then diff --git a/tests/main/install-sideload-epochs/task.yaml b/tests/main/install-sideload-epochs/task.yaml index 9ab63e7c181..a4e52c7d5c3 100644 --- a/tests/main/install-sideload-epochs/task.yaml +++ b/tests/main/install-sideload-epochs/task.yaml @@ -12,16 +12,14 @@ environment: SNAP_REEXEC/reexec1: 1 prepare: | - # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi snap pack test-snapd-epoch-1 snap pack test-snapd-epoch-2 execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 rx="cannot refresh \"[^ \"]*\" to local snap with epoch [^ ]*, because it can't read the current epoch" snap try test-snapd-epoch-1 diff --git a/tests/main/install-sideload/task.yaml b/tests/main/install-sideload/task.yaml index 5bc6a2e7685..5b115b010e1 100644 --- a/tests/main/install-sideload/task.yaml +++ b/tests/main/install-sideload/task.yaml @@ -14,10 +14,8 @@ environment: SNAP_REEXEC/reexec1: 1 prepare: | - # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi for snap in basic test-snapd-tools basic-desktop test-snapd-devmode snap-hooks-bad-install; do @@ -32,7 +30,7 @@ prepare: | fi execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Sideloaded snap shows status" expected='^basic 1.0 installed$' diff --git a/tests/main/known/task.yaml b/tests/main/known/task.yaml index 8d501b2574d..8440173a77e 100644 --- a/tests/main/known/task.yaml +++ b/tests/main/known/task.yaml @@ -7,7 +7,7 @@ details: | properties in general. execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Listing all account assertions" snap known account|MATCH "^type: account$" diff --git a/tests/main/postrm-purge/task.yaml b/tests/main/postrm-purge/task.yaml index a7b190fb592..4e3fc0d926d 100644 --- a/tests/main/postrm-purge/task.yaml +++ b/tests/main/postrm-purge/task.yaml @@ -8,9 +8,7 @@ systems: [-ubuntu-core-*] prepare: | if tests.info is-snapd-pkg-repo; then - echo "This test is skipped when the snapd pkg isn't built from local" - touch .skip - exit + tests.exec skip-test "This test is skipped when the snapd pkg isn't built from local" && exit 0 fi # TODO: unify this with tests/main/snap-mgmt/task.yaml @@ -65,7 +63,7 @@ prepare: | fi restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 #shellcheck source=tests/lib/pkgdb.sh . "$TESTSLIB/pkgdb.sh" @@ -75,12 +73,12 @@ restore: | fi debug: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl --no-legend --full | grep -E 'snap\..*\.(service|timer|socket|slice)' || true execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl --no-legend --full | MATCH 'snap\..*\.(service|timer|socket|slice)' diff --git a/tests/main/searching/task.yaml b/tests/main/searching/task.yaml index 55bd6f959ad..2da2fd000a9 100644 --- a/tests/main/searching/task.yaml +++ b/tests/main/searching/task.yaml @@ -15,7 +15,7 @@ backends: [-autopkgtest] systems: [-ubuntu-*-ppc64el, -ubuntu-*-s390x] execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "List all featured snaps" expected='(?s).*Name +Version +Publisher +Notes +Summary *\n(.*?\n)?.*' diff --git a/tests/main/snap-run-hook/task.yaml b/tests/main/snap-run-hook/task.yaml index 7958f01c0d5..344be80b2c8 100644 --- a/tests/main/snap-run-hook/task.yaml +++ b/tests/main/snap-run-hook/task.yaml @@ -12,10 +12,8 @@ environment: ENVDUMP: /var/snap/basic-hooks/current/hooks-env prepare: | - # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi "$TESTSTOOLS"/snaps-state install-local basic-hooks SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" @@ -27,7 +25,7 @@ prepare: | fi execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 # Note that `snap run` doesn't exit non-zero if the hook is missing, so we # check the output instead. diff --git a/tests/main/snap-run/task.yaml b/tests/main/snap-run/task.yaml index 970e8d5addc..8c2a25c2880 100644 --- a/tests/main/snap-run/task.yaml +++ b/tests/main/snap-run/task.yaml @@ -14,18 +14,18 @@ environment: STRACE_STATIC_CHANNEL: candidate prepare: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 "$TESTSTOOLS"/snaps-state install-local basic-run "$TESTSTOOLS"/snaps-state install-local test-snapd-sh debug: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 cat stderr || true execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Running a trivial command causes no DENIED messages" test-snapd-sh.sh -c 'echo hello' diff --git a/tests/main/snapd-homedirs-vendored/task.yaml b/tests/main/snapd-homedirs-vendored/task.yaml index ebc52bfbaeb..4d971cdbd63 100644 --- a/tests/main/snapd-homedirs-vendored/task.yaml +++ b/tests/main/snapd-homedirs-vendored/task.yaml @@ -14,9 +14,7 @@ environment: prepare: | if tests.info is-snapd-pkg-repo; then - echo "This test needs to be executed when snapd deb is built from local" - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi # Create a new user in a non-standard location @@ -34,7 +32,7 @@ prepare: | rm -rf "${unpackdir}" restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 userdel -f --remove "$USERNAME" rm -rf /remote/users @@ -46,7 +44,7 @@ restore: | distro_install_build_snapd debug: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 # output custom snap-confine snippets ls -l /var/lib/snapd/apparmor/snap-confine/ @@ -56,7 +54,7 @@ debug: | done execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Downgrading the snapd deb to pre-vendored apparmor times" TARGET_VER="$(apt list -a snapd | grep -- -updates | cut -f2 -d' ')" diff --git a/tests/main/try/task.yaml b/tests/main/try/task.yaml index 44b878a9bee..725714d0dee 100644 --- a/tests/main/try/task.yaml +++ b/tests/main/try/task.yaml @@ -15,20 +15,20 @@ environment: SERVICE_NAME: "test-service" prepare: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 # shellcheck source=tests/lib/network.sh . "$TESTSLIB"/network.sh make_network_service "$SERVICE_NAME" "$PORT" restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 systemctl stop "$SERVICE_NAME" rm -f "$READABLE_FILE" execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Given a buildable snap in a known directory" echo "When try is executed on that directory" diff --git a/tests/main/writable-areas/task.yaml b/tests/main/writable-areas/task.yaml index 433cda9eb69..f8482dfb3a0 100644 --- a/tests/main/writable-areas/task.yaml +++ b/tests/main/writable-areas/task.yaml @@ -15,8 +15,7 @@ environment: prepare: | # No needed to test the snap pkg when it is coming from the repository if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit + tests.exec skip-test "No needed to test the snap pkg when it is coming from the repository" && exit 0 fi snap pack data-writer SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)" @@ -28,7 +27,7 @@ prepare: | fi execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 snap install --dangerous data-writer_1.0_all.snap diff --git a/tests/smoke/find-info/task.yaml b/tests/smoke/find-info/task.yaml index 6514fc353ef..98181a0f3db 100644 --- a/tests/smoke/find-info/task.yaml +++ b/tests/smoke/find-info/task.yaml @@ -6,7 +6,7 @@ details: | display detailed information about it by using the "snap info" command. execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 echo "Ensure 'snap find' works" snap find test-snapd-tools | MATCH ^test-snapd-tools diff --git a/tests/smoke/install/task.yaml b/tests/smoke/install/task.yaml index 055b12e3ae4..7603d3d22f3 100644 --- a/tests/smoke/install/task.yaml +++ b/tests/smoke/install/task.yaml @@ -10,7 +10,7 @@ details: | snaps: core, core18, core20 and core22. restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 rm -f /home/test/stderr.log rm -f /home/test/stdout.log @@ -18,7 +18,7 @@ restore: | snap remove --purge test-snapd-sh debug: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 if test -e stderr.log; then echo "content of stderr.log" @@ -26,7 +26,7 @@ debug: | fi execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 #shellcheck source=tests/lib/systems.sh . "$TESTSLIB"/systems.sh diff --git a/tests/smoke/remove/task.yaml b/tests/smoke/remove/task.yaml index c911389903f..946c9124c5b 100644 --- a/tests/smoke/remove/task.yaml +++ b/tests/smoke/remove/task.yaml @@ -7,7 +7,7 @@ details: | removal no leftovers remain in the mounting area. execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 "$TESTSTOOLS"/snaps-state install-local test-snapd-sh diff --git a/tests/smoke/sandbox/task.yaml b/tests/smoke/sandbox/task.yaml index e326256e142..442cc3bb97c 100644 --- a/tests/smoke/sandbox/task.yaml +++ b/tests/smoke/sandbox/task.yaml @@ -9,7 +9,7 @@ details: | the CPU supports one. restore: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 rm -f /home/test/foo # required! in autopkgtest no suite restore is run at all @@ -17,7 +17,7 @@ restore: | snap remove --purge test-snapd-hello-multi-arch execute: | - test -f .skip && exit 0 + tests.exec is-skipped && exit 0 if [ "$(snap debug confinement)" != "strict" ]; then if os.query is-ubuntu; then diff --git a/tests/smoke/versioning/task.yaml b/tests/smoke/versioning/task.yaml index 903a2be24e0..71d44649dd6 100644 --- a/tests/smoke/versioning/task.yaml +++ b/tests/smoke/versioning/task.yaml @@ -9,11 +9,7 @@ details: | modified the code in unintended ways. execute: | - # When snapd.deb is from the repo, we just need to test when re-exec is enabled - if [ "$SNAP_REEXEC" = "0" ] && tests.info is-snapd-pkg-repo; then - touch .skip - exit - fi + tests.exec is-skipped && exit 0 # TODO: fix dirty version number on riscv echo "Ensure the version number is not 'dirty'"