From 7c7d5a25f900798ba1f35c346a20c9cedf40b73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Mon, 6 May 2024 20:15:04 +0200 Subject: [PATCH 1/3] build-lxd.yml: Add network profile to incus containers on the arm gh runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .../actions/create-test-instance/action.yml | 2 +- .github/workflows/build-lxd.yml | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/actions/create-test-instance/action.yml b/.github/actions/create-test-instance/action.yml index 8229415db..ff6cdb9c8 100644 --- a/.github/actions/create-test-instance/action.yml +++ b/.github/actions/create-test-instance/action.yml @@ -24,7 +24,7 @@ outputs: description: ID of the created test server runs: using: docker - image: docker://thecalcaholic/ncp-test-automation:bookworm + image: docker://thecalcaholic/ncp-test-automation:latest env: HCLOUD_TOKEN: ${{ inputs.hcloud_token }} diff --git a/.github/workflows/build-lxd.yml b/.github/workflows/build-lxd.yml index 776c52c2f..b624abd29 100644 --- a/.github/workflows/build-lxd.yml +++ b/.github/workflows/build-lxd.yml @@ -35,6 +35,7 @@ jobs: outputs: runner_label: ${{ steps.script.outputs.runner_label }} lxc_cmd: ${{ steps.script.outputs.lxc_cmd }} + lxd_extra_profile: ${{ steps.script.outputs.lxd_extra_profile }} steps: - name: script id: script @@ -43,6 +44,7 @@ jobs: then LXC_CMD="incus" RUNNER_LABEL="ubuntu-20.04-arm64" + echo "lxd_extra_profile=network" | tee -a "$GITHUB_OUTPUT" else LXC_CMD="incus" RUNNER_LABEL="ubuntu-20.04" @@ -62,6 +64,7 @@ jobs: ARTIFACT_NAME: "${{ github.run_id }}-lxd-${{ inputs.arch || 'x86' }}-image" LXD_ARCH: "${{ inputs.arch || 'x86' }}" LXC: "${{ needs.determine-runner.outputs.lxc_cmd }}" + LXD_EXTRA_PROFILE: "${{ needs.determine-runner.outputs.lxd_extra_profile }}" steps: - name: Checkout code uses: actions/checkout@v4 @@ -78,7 +81,7 @@ jobs: env: USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" run: | - BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh + LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh - name: Pack LXD image id: pack-lxd run: | @@ -107,6 +110,7 @@ jobs: # ARTIFACT_NAME: "${{ github.run_id }}-lxd-${{ inputs.arch || 'x86' }}-image-previous" # LXD_ARCH: "${{ inputs.arch || 'x86' }}" # LXC: "${{ needs.determine-runner.outputs.lxc_cmd }}" +# LXD_EXTRA_PROFILE: "${{ needs.determine-runner.outputs.lxd_extra_profile }}" # steps: # - name: Checkout code # uses: actions/checkout@v3 @@ -325,10 +329,11 @@ jobs: test-dist-upgrade: needs: - determine-runner - runs-on: [ubuntu-20.04] + runs-on: ${{ needs.determine-runner.outputs.runner_label }} env: VERSION: "${{ inputs.git_ref || github.ref }}" LXC: "${{ needs.determine-runner.outputs.lxc_cmd }}" + LXD_EXTRA_PROFILE: "${{ needs.determine-runner.outputs.lxd_extra_profile }}" PREVIOUS_IMAGE_URL: "https://github.com/nextcloud/nextcloudpi/releases/download/v1.53.2/NextcloudPi_LXD_x86_v1.53.2.tar.gz" USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" steps: @@ -365,7 +370,9 @@ jobs: set -x sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./ncp.tar.gz" --alias "ncp/update" - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" launch -q "ncp/update" ncp + LXC_ARGS=() + [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") + systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" launch "${LXC_ARGS[@]}" -q "ncp/update" ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sudo "$LXC" exec ncp -- rm -f /opt/ncdata/data/nextcloud.log sleep 30 @@ -436,7 +443,9 @@ jobs: - name: Relaunch container run: | set -x - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" start ncp + LXC_ARGS=() + [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") + systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" "${LXD_ARGS[@]}" start ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" @@ -479,7 +488,9 @@ jobs: - name: Relaunch container run: | set -x - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" start ncp + LXC_ARGS=() + [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") + systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" "${LXC_ARGS[@]}" start ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" @@ -563,8 +574,10 @@ jobs: . ./build/buildlib.sh sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./${ARTIFACT_FILE?}" --alias "ncp/test" || true - systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "ncp/test" ncp || \ - sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "ncp/test" ncp + LXC_ARGS=() + [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") + systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp || \ + sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" From 6a93bb14e3282b2237f13f229eb3175c5b99473f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Mon, 6 May 2024 23:21:40 +0200 Subject: [PATCH 2/3] build-lxd.yml: Change to custom geckodriver install script for arm support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-lxd.yml | 95 +++++++++++++++++++++++---------- install.sh | 2 +- 2 files changed, 68 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-lxd.yml b/.github/workflows/build-lxd.yml index b624abd29..87b80017b 100644 --- a/.github/workflows/build-lxd.yml +++ b/.github/workflows/build-lxd.yml @@ -81,7 +81,7 @@ jobs: env: USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" run: | - LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh + LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh - name: Pack LXD image id: pack-lxd run: | @@ -156,7 +156,7 @@ jobs: # env: # USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" # run: | -# BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh +# LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh # - name: Pack LXD image # id: pack-lxd # run: | @@ -205,9 +205,17 @@ jobs: # run: | # sudo apt-get install -y --no-install-recommends firefox # - name: Setup GeckoDriver -# uses: ChlodAlejandro/setup-geckodriver@latest -# with: -# token: ${{ secrets.GITHUB_TOKEN }} +# env: +# GH_TOKEN: ${{ github.token }} +# run: | +# arch=linux64 +# if [[ "$RUNNER_ARCH" == "ARM64" ]] +# then +# arch="linux-aarch64" +# fi +# gh release download -R mozilla/geckodriver -p 'geckodriver-*-'"$arch.tar.gz" +# tar xf "geckodriver-"*"-$arch.tar.gz" +# sudo mv geckodriver /usr/local/bin/ # - name: Setup Selenium # run: pip install selenium # - name: download LXD image from artifact store @@ -233,7 +241,8 @@ jobs: # sleep 30 # ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" # ip="${ip/% *}" -# echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts +# sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts +# echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts # - name: Activate and Test LXD Image # working-directory: ./tests # run: | @@ -297,13 +306,14 @@ jobs: # - name: Relaunch container # run: | # set -x -# systemd-run --user --scope -p "Delegate=yes" "$LXC" start -q "ncp/test" ncp || \ -# sudo systemd-run --scope -p "Delegate=yes" "$LXC" start -q "ncp/test" ncp +# systemd-run --user --scope -p "Delegate=yes" "$LXC" start -q ncp || \ +# sudo systemd-run --scope -p "Delegate=yes" "$LXC" start -q ncp # sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' # sleep 30 # ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" # ip="${ip/% *}" -# echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts +# sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts +# echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts # - name: Test LXD Image # working-directory: ./tests # run: | @@ -334,7 +344,8 @@ jobs: VERSION: "${{ inputs.git_ref || github.ref }}" LXC: "${{ needs.determine-runner.outputs.lxc_cmd }}" LXD_EXTRA_PROFILE: "${{ needs.determine-runner.outputs.lxd_extra_profile }}" - PREVIOUS_IMAGE_URL: "https://github.com/nextcloud/nextcloudpi/releases/download/v1.53.2/NextcloudPi_LXD_x86_v1.53.2.tar.gz" + PREVIOUS_IMAGE_URL_ARM64: "https://github.com/nextcloud/nextcloudpi/releases/download/v1.53.2/NextcloudPi_LXD_arm64_v1.53.2.tar.gz" + PREVIOUS_IMAGE_URL_AMD64: "https://github.com/nextcloud/nextcloudpi/releases/download/v1.53.2/NextcloudPi_LXD_x86_v1.53.2.tar.gz" USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" steps: - name: Setup incus @@ -357,28 +368,43 @@ jobs: run: | sudo apt-get install -y --no-install-recommends firefox - name: Setup GeckoDriver - uses: ChlodAlejandro/setup-geckodriver@latest - with: - token: ${{ secrets.GITHUB_TOKEN }} + env: + GH_TOKEN: ${{ github.token }} + run: | + arch=linux64 + if [[ "$RUNNER_ARCH" == "ARM64" ]] + then + arch="linux-aarch64" + fi + gh release download -R mozilla/geckodriver -p 'geckodriver-*-'"$arch.tar.gz" + tar xf "geckodriver-"*"-$arch.tar.gz" + sudo mv geckodriver /usr/local/bin/ - name: Setup Selenium run: pip install selenium - name: download LXD image run: | - wget -qO ./ncp.tar.gz "${PREVIOUS_IMAGE_URL?}" + image_url="${PREVIOUS_IMAGE_URL_AMD64?}" + if [[ "$RUNNER_ARCH" == "ARM64" ]] + then + image_url="${PREVIOUS_IMAGE_URL_ARM64?}" + fi + wget -qO ./ncp.tar.gz "${image_url?}" - name: Launch ncp container run: | set -x sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./ncp.tar.gz" --alias "ncp/update" - LXC_ARGS=() + LXC_ARGS=(-p default) [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" launch "${LXC_ARGS[@]}" -q "ncp/update" ncp + systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/update" ncp || \ + sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/update" ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sudo "$LXC" exec ncp -- rm -f /opt/ncdata/data/nextcloud.log sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" ip="${ip/% *}" - echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts + sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts + echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts - name: Activate and Test LXD Image working-directory: ./tests run: | @@ -445,12 +471,14 @@ jobs: set -x LXC_ARGS=() [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" "${LXD_ARGS[@]}" start ncp + systemd-run --user --scope -p "Delegate=yes" "$LXC" start ncp || \ + sudo systemd-run --scope -p "Delegate=yes" "$LXC" start ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" ip="${ip/% *}" - echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts + sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts + echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts - name: Test LXD Image working-directory: ./tests run: | @@ -490,12 +518,14 @@ jobs: set -x LXC_ARGS=() [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") - systemd-run --user --scope -p "Delegate=yes" sudo "$LXC" "${LXC_ARGS[@]}" start ncp + systemd-run --user --scope -p "Delegate=yes" "$LXC" start ncp || \ + sudo systemd-run --scope -p "Delegate=yes" "$LXC" start ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" ip="${ip/% *}" - echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts + sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts + echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts - name: Test LXD Image working-directory: ./tests run: | @@ -530,6 +560,7 @@ jobs: ARTIFACT_FILE: ${{ needs.build-current.outputs.artifact_file }} LXC: "${{ needs.determine-runner.outputs.lxc_cmd }}" USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" + LXD_EXTRA_PROFILE: "${{ needs.determine-runner.outputs.lxd_extra_profile }}" steps: - name: Checkout code uses: actions/checkout@v3 @@ -551,10 +582,17 @@ jobs: run: | sudo apt-get install -y --no-install-recommends firefox - name: Setup GeckoDriver - uses: ChlodAlejandro/setup-geckodriver@latest - continue-on-error: true - with: - token: ${{ secrets.GITHUB_TOKEN }} + env: + GH_TOKEN: ${{ github.token }} + run: | + arch=linux64 + if [[ "$RUNNER_ARCH" == "ARM64" ]] + then + arch="linux-aarch64" + fi + gh release download -R mozilla/geckodriver -p 'geckodriver-*-'"$arch.tar.gz" + tar xf "geckodriver-"*"-$arch.tar.gz" + sudo mv geckodriver /usr/local/bin/ - name: Setup Selenium run: pip install selenium - name: download LXD image from artifact store @@ -574,15 +612,16 @@ jobs: . ./build/buildlib.sh sudo "$LXC" delete -q -f ncp || true sudo "$LXC" image import -q "./${ARTIFACT_FILE?}" --alias "ncp/test" || true - LXC_ARGS=() + LXC_ARGS=(-p default) [[ -z "$LXD_EXTRA_PROFILE" ]] || LXC_ARGS+=(-p "$LXD_EXTRA_PROFILE") systemd-run --user --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp || \ - sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp + sudo systemd-run --scope -p "Delegate=yes" "$LXC" launch -q "${LXC_ARGS[@]}" "ncp/test" ncp sudo "$LXC" exec ncp -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' sleep 30 ip="$(sudo "$LXC" list -c n4 -f csv | grep '^ncp' | cut -d ',' -f2)" ip="${ip/% *}" - echo "${ip} nextcloudpi.local" | sudo tee /etc/hosts + sudo sed -i 's/^.*nextcloudpi.local.*$//g' /etc/hosts + echo "${ip} nextcloudpi.local" | sudo tee -a /etc/hosts - name: Test LXD Image working-directory: ./tests run: | diff --git a/install.sh b/install.sh index 4598920ed..ceafe6597 100644 --- a/install.sh +++ b/install.sh @@ -28,7 +28,7 @@ export PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}" type mysqld &>/dev/null && echo ">>> WARNING: existing mysqld configuration will be changed <<<" type mysqld &>/dev/null && mysql -e 'use nextcloud' &>/dev/null && { echo "The 'nextcloud' database already exists. Aborting"; exit 1; } -[[ "$DEBIAN_FRONTEND" == "noninteractive" ]] || { +[[ "$CI" == "true" ]] || { echo "WARNING: This installer will disable SSH login for the root user and reset its password. If you need to login with root, you should make sure, you have a root session open that you can use, to revert these changes afterwards (set PermitRootLogin to 'yes' in /etc/ssh/sshd_config and run passwd as root)." From 9b66766b1b4080ecfcf231392c12312e54da0216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Mon, 6 May 2024 23:47:43 +0200 Subject: [PATCH 3/3] system_tests.py: Correctly handle case where no valid lxc command can be determined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/build-lxd.yml | 6 ++++-- tests/system_tests.py | 17 +++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-lxd.yml b/.github/workflows/build-lxd.yml index 87b80017b..561344c48 100644 --- a/.github/workflows/build-lxd.yml +++ b/.github/workflows/build-lxd.yml @@ -81,7 +81,8 @@ jobs: env: USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" run: | - LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh + export CI + LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh - name: Pack LXD image id: pack-lxd run: | @@ -156,7 +157,8 @@ jobs: # env: # USE_INCUS: "${{ needs.determine-runner.outputs.lxc_cmd == 'incus' && 'yes' || 'no' }}" # run: | -# LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" CI="$CI" ./build/build-LXD.sh +# export CI +# LXD_EXTRA_PROFILE="$LXD_EXTRA_PROFILE" BRANCH="${VERSION##refs/heads/}" ./build/build-LXD.sh # - name: Pack LXD image # id: pack-lxd # run: | diff --git a/tests/system_tests.py b/tests/system_tests.py index a01e0f007..9664c0fdf 100755 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -301,14 +301,19 @@ def set_cohorte_id(cohorte_id: int) -> CompletedProcess: if lxc_test.returncode != 0: raise Exception(f"failed to execute {lxc_command} info") except: - lxc_test = run(['sudo'] + lxc_command + ['info'], stdout=PIPE, check='True') - lxc_command = ['sudo'] + lxc_command + try: + lxc_test = run(['sudo'] + lxc_command + ['info'], stdout=PIPE, check='True') + lxc_command = ['sudo'] + lxc_command + except: + lxc_command = None + lxc_running = False # detect if we are running this in a LXC instance - try: - lxc_running = run(lxc_command + ['info', 'ncp'], stdout=PIPE, check = True) - except: - lxc_running = False + if lxc_command is not None: + try: + lxc_running = run(lxc_command + ['info', 'ncp'], stdout=PIPE, check = True) + except: + lxc_running = False try: systemd_container_running = run(['machinectl', 'show', 'ncp'], stdout=PIPE, check = True)