diff --git a/.github/workflows/spread-test.yaml b/.github/workflows/spread-test.yaml index af390b7f..e26a1b3d 100644 --- a/.github/workflows/spread-test.yaml +++ b/.github/workflows/spread-test.yaml @@ -16,6 +16,8 @@ jobs: - name: Build ubuntu-image snap uses: snapcore/action-build@3bdaa03e1ba6bf59a65f84a751d943d549a54e79 # v1.3.0 + with: + snapcraft-channel: 8.x/stable - name: Uploading ubuntu-image snap artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 @@ -37,6 +39,8 @@ jobs: - name: Build ubuntu-image snap uses: snapcore/action-build@3bdaa03e1ba6bf59a65f84a751d943d549a54e79 # v1.3.0 + with: + snapcraft-channel: 8.x/stable - name: Uploading ubuntu-image snap artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 @@ -47,7 +51,7 @@ jobs: spread: name: Build a ${{ matrix.series }} image on ${{ matrix.group }} (${{ matrix.systems }}) - runs-on: [self-hosted, ubuntu-image] + runs-on: [self-hosted, spread-enabled] needs: [snap-build-amd64, snap-build-arm64] strategy: fail-fast: false @@ -159,13 +163,13 @@ jobs: # Register a problem matcher to highlight spread failures echo "::add-matcher::.github/spread-problem-matcher.json" - BACKEND=google + BACKEND=openstack SERIES=${{ matrix.series }} if [[ "${{ matrix.systems }}" =~ -arm- ]]; then - BACKEND=google-arm + BACKEND=openstack-arm elif [[ "${{ matrix.group }}" =~ -crossbuild ]]; then - BACKEND=google-crossbuild + BACKEND=openstack-crossbuild fi RUN_TESTS="" @@ -201,9 +205,9 @@ jobs: echo "Running spread log parser" ./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --output spread-results.json - BACKEND=google + BACKEND=openstack if [[ "${{ matrix.systems }}" =~ -arm- ]]; then - BACKEND=google-arm + BACKEND=openstack-arm fi echo "Determining which tests were executed" diff --git a/internal/statemachine/classic_test.go b/internal/statemachine/classic_test.go index 893c5b8a..1bc6faae 100644 --- a/internal/statemachine/classic_test.go +++ b/internal/statemachine/classic_test.go @@ -2151,6 +2151,9 @@ func TestPrepareClassicImage(t *testing.T) { SnapName: "lxd", Channel: "latest/stable", }, + { + SnapName: "core26", + }, { SnapName: "core24", }, @@ -2171,7 +2174,7 @@ func TestPrepareClassicImage(t *testing.T) { // check that the lxd and hello snaps, as well as lxd's base, core20 // were prepared in the correct location - snaps := map[string]string{"lxd": "stable", "hello": "candidate", "core20": "stable", "core22": "stable", "core24": "stable"} + snaps := map[string]string{"lxd": "stable", "hello": "candidate", "core20": "stable", "core22": "stable", "core24": "stable", "core26": "stable"} for snapName, snapChannel := range snaps { // reach out to the snap store to find the revision // of the snap for the specified channel @@ -5182,6 +5185,9 @@ func TestPreseedResetChroot(t *testing.T) { { SnapName: "core24", }, + { + SnapName: "core26", + }, }, }, } diff --git a/spread.yaml b/spread.yaml index 1027c3ac..2be1ea29 100644 --- a/spread.yaml +++ b/spread.yaml @@ -15,50 +15,69 @@ environment: backends: - google: - key: '$(HOST: echo "$SPREAD_GOOGLE_KEY")' - location: snapd-spread/us-east1-b - plan: n2-standard-2 + openstack: + key: '$(HOST: echo "$OS_CREDENTIALS_AMD64_PS7")' + plan: shared.xsmall halt-timeout: 2h + wait-timeout: 10m + groups: [default] + proxy: ingress-haproxy.ps7.canonical.com + cidr-port-rel: [10.151.96.0/21:5000] + volume-auto-delete: true + environment: &openstack-env + SNAPD_USE_PROXY: 'true' + HTTP_PROXY: 'http://egress.ps7.internal:3128' + HTTPS_PROXY: 'http://egress.ps7.internal:3128' + http_proxy: 'http://egress.ps7.internal:3128' + https_proxy: 'http://egress.ps7.internal:3128' + no_proxy: '127.0.0.1,127.0.0.53,localhost' + NO_PROXY: '127.0.0.1,127.0.0.53,localhost' + NTP_SERVER: 'ntp.ps7.internal' systems: - ubuntu-20.04-64: - storage: 45G + image: snapd-spread/ubuntu-20.04-64 workers: 1 - ubuntu-22.04-64: - storage: 45G + image: snapd-spread/ubuntu-22.04-64 workers: 1 - ubuntu-24.04-64: - storage: 45G + image: snapd-spread/ubuntu-24.04-64 workers: 1 - google-crossbuild: - type: google - key: '$(HOST: echo "$SPREAD_GOOGLE_KEY")' - location: snapd-spread/us-east1-b - plan: n2-standard-4 + openstack-crossbuild: + type: openstack + key: '$(HOST: echo "$OS_CREDENTIALS_AMD64_PS7")' + plan: shared.medium halt-timeout: 2h + wait-timeout: 10m + proxy: ingress-haproxy.ps7.canonical.com + cidr-port-rel: [10.151.96.0/21:5000] + volume-auto-delete: true + environment: *openstack-env systems: - ubuntu-24.04-64: - storage: 45G + image: snapd-spread/ubuntu-24.04-64 workers: 1 - google-arm: - type: google - key: '$(HOST: echo "$SPREAD_GOOGLE_KEY")' - location: snapd-spread/us-central1-a - plan: t2a-standard-1 + openstack-arm: + type: openstack + key: '$(HOST: echo "$OS_CREDENTIALS_ARM64_PS7")' + plan: shared.xsmall.arm64 halt-timeout: 2h + wait-timeout: 10m + groups: [default] + proxy: ingress-haproxy.ps7.canonical.com + cidr-port-rel: [10.151.89.0/24:8000] + volume-auto-delete: true + environment: *openstack-env systems: - ubuntu-20.04-arm-64: - image: ubuntu-os-cloud/ubuntu-2004-lts-arm64 + image: snapd-spread/ubuntu-20.04-arm-64 workers: 1 - storage: 45G - ubuntu-22.04-arm-64: - image: ubuntu-os-cloud/ubuntu-2204-lts-arm64 + image: snapd-spread/ubuntu-22.04-arm-64 workers: 1 - storage: 45G - ubuntu-24.04-arm-64: - image: ubuntu-os-cloud/ubuntu-2404-lts-arm64 + image: snapd-spread/ubuntu-24.04-arm-64 workers: 1 - storage: 45G qemu: memory: 4G systems: @@ -75,6 +94,15 @@ backends: path: /home/ubuntu-image prepare: | + #shellcheck source=tests/lib/spread/tools.sh + . $SPREAD_PATH/tests/lib/spread/tools.sh + if [ -n "$HTTP_PROXY" ]; then + tools.setup_system_proxy + # The snapd daemon doesn't see the environment variables, so we must modify its config + # to use a proxy with it. Came from: + # https://github.com/canonical/snapd/blob/619cc925793591348db21bb45fa4af65288d2c42/tests/lib/prepare.sh#L90 + tools.setup_snapd_proxy + fi # Make sure there is a hostname file because it could be missing # We will need it to have debootstrap properly run if [ ! -f /etc/hostname ]; then @@ -107,12 +135,6 @@ prepare: | systemctl mask unattended-upgrades.service fi - # Make sure ssh service is restarted after it is killed by spread (pkill -o -HUP sshd) - # during the machine setup in google systems. For more details see lp:2011458 - if [ "$SPREAD_BACKEND" = "google" ] && [[ "$SPREAD_SYSTEM" == ubuntu-2* ]] && ! systemctl is-active ssh; then - systemctl restart ssh - fi - apt update apt install -y snapd libc6-dev git ubuntu-dev-tools if [[ ! "$SPREAD_BACKEND" == *-arm ]]; then @@ -146,18 +168,18 @@ suites: summary: Common integration tests for ubuntu-image tests/amd64/: summary: Integration tests for ubuntu-image on amd64 - backends: [google, qemu] + backends: [openstack, qemu] environment: IMG/ubuntu_server_pc_amd64: ubuntu-server-pc-amd64 tests/amd64-crossbuild/: summary: Integration tests for ubuntu-image on amd64 - backends: [google-crossbuild, qemu] + backends: [openstack-crossbuild, qemu] environment: IMG/ubuntu_server_riscv64: ubuntu-server-riscv64 IMG/ubuntu_server_pi_arm64: ubuntu-server-pi-arm64 tests/arm64/: summary: Integration tests for ubuntu-image on arm64 - backends: [google-arm] + backends: [openstack-arm] environment: IMG/ubuntu_server_pi_arm64: ubuntu-server-pi-arm64 IMG/ubuntu_server_pc_arm64: ubuntu-server-pc-arm64 diff --git a/tests/lib/spread/tools.sh b/tests/lib/spread/tools.sh new file mode 100644 index 00000000..d4be2b83 --- /dev/null +++ b/tests/lib/spread/tools.sh @@ -0,0 +1,35 @@ +tools.setup_snapd_proxy() { + if [ "${SNAPD_USE_PROXY:-}" != true ]; then + return + fi + + local SNAPD_CONFD="/etc/systemd/system/snapd.service.d" + mkdir -p "$SNAPD_CONFD" + + cat < ${SNAPD_CONFD}/proxy.conf +[Service] +Environment=HTTPS_PROXY="$HTTPS_PROXY" HTTP_PROXY="$HTTP_PROXY" https_proxy="$HTTPS_PROXY" http_proxy="$HTTP_PROXY" NO_PROXY="$NO_PROXY" no_proxy="$NO_PROXY" +EOF + + # Since the service config changed, restart + systemctl daemon-reload + systemctl restart snapd.service +} + +tools.setup_system_proxy() { + if [ "${SNAPD_USE_PROXY:-}" != true ]; then + return + fi + + local UBUNTU_IMAGE_WORKDIR="/var/tmp/ubuntu-image-work-dir" + mkdir -p "$UBUNTU_IMAGE_WORKDIR" + cp -f /etc/environment "$UBUNTU_IMAGE_WORKDIR"/environment.bak + { + echo "HTTPS_PROXY=$HTTPS_PROXY" + echo "HTTP_PROXY=$HTTP_PROXY" + echo "https_proxy=$HTTPS_PROXY" + echo "http_proxy=$HTTP_PROXY" + echo "NO_PROXY=$NO_PROXY" + echo "no_proxy=$NO_PROXY" + } >> /etc/environment +} \ No newline at end of file