From 71fd95ca276337817982ac97769fec32d91c7033 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 15 May 2024 15:43:02 +0100 Subject: [PATCH 01/17] tests: Search for compute service It's more common than the object storage service and allows us to run on a DevStack with default configuration. Signed-off-by: Stephen Finucane (cherry picked from commit c81a270a0cd598a263e471c11102647f5f8a0298) --- internal/acceptance/openstack/client_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/acceptance/openstack/client_test.go b/internal/acceptance/openstack/client_test.go index 69e9a09367..3b252a2853 100644 --- a/internal/acceptance/openstack/client_test.go +++ b/internal/acceptance/openstack/client_test.go @@ -36,14 +36,14 @@ func TestAuthenticatedClient(t *testing.T) { t.Logf("Client successfully acquired a token: %v", client.TokenID) - // Find the storage service in the service catalog. - storage, err := openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{ + // Find the compute service in the service catalog. + compute, err := openstack.NewComputeV2(client, gophercloud.EndpointOpts{ Region: os.Getenv("OS_REGION_NAME"), }) if err != nil { - t.Errorf("Unable to locate a storage service: %v", err) + t.Errorf("Unable to locate a compute service: %v", err) } else { - t.Logf("Located a storage service at endpoint: [%s]", storage.Endpoint) + t.Logf("Located a compute service at endpoint: [%s]", compute.Endpoint) } } From ca1ccc25355cc90c251c2c0d00be40b1b8df0d34 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 22 May 2024 11:54:15 +0100 Subject: [PATCH 02/17] make: Correct typos We mangled this, probably since we were renaming the 'imageservice' module to 'image' at the time. Signed-off-by: Stephen Finucane (cherry picked from commit c56703d8872779ff2b3866b240cb58ff3e218a67) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2a0618a6b6..51b4d20478 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ coverage: $(GO_TEST) -covermode count -coverprofile cover.out -coverpkg=./... ./... .PHONY: coverage -acceptance: acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-imageservice acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow +acceptance: acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-image acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow .PHONY: acceptance acceptance-baremetal: @@ -74,7 +74,7 @@ acceptance-identity: .PHONY: acceptance-identity acceptance-image: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/imageservice/... + $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/image/... .PHONY: acceptance-image acceptance-keymanager: From f46c96dd87d13db8abe044005636bfc20cd0eb4e Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 8 May 2024 18:12:37 +0100 Subject: [PATCH 03/17] make: Add 'acceptance-basic' target For use in CI. Signed-off-by: Stephen Finucane (cherry picked from commit cfeb6d5aff9e3126e5180d4a15b133461c409491) --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51b4d20478..cc30e43fd9 100644 --- a/Makefile +++ b/Makefile @@ -38,9 +38,13 @@ coverage: $(GO_TEST) -covermode count -coverprofile cover.out -coverpkg=./... ./... .PHONY: coverage -acceptance: acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-image acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow +acceptance: acceptance-basic acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-image acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow .PHONY: acceptance +acceptance-basic: + $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack +.PHONY: acceptance-basic + acceptance-baremetal: $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/... .PHONY: acceptance-baremetal From 8178ebffb17e8a3e3b98197edabf632661e53276 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 20 May 2024 17:49:33 +0100 Subject: [PATCH 04/17] make: Add timeout for acceptance tests Signed-off-by: Stephen Finucane (cherry picked from commit 7f4ed82c98a3436c7beb9b5216486c68920622b6) --- Makefile | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index cc30e43fd9..47c397a6b1 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ undefine GOFLAGS GOLANGCI_LINT_VERSION?=v1.62.2 GO_TEST?=go run gotest.tools/gotestsum@latest --format testname -- +TIMEOUT := "60m" ifeq ($(shell command -v podman 2> /dev/null),) RUNNER=docker @@ -42,77 +43,77 @@ acceptance: acceptance-basic acceptance-baremetal acceptance-blockstorage accept .PHONY: acceptance acceptance-basic: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack .PHONY: acceptance-basic acceptance-baremetal: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/baremetal/... .PHONY: acceptance-baremetal acceptance-blockstorage: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/blockstorage/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/blockstorage/... .PHONY: acceptance-blockstorage acceptance-compute: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/compute/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/compute/... .PHONY: acceptance-compute acceptance-container: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/container/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/container/... .PHONY: acceptance-container acceptance-containerinfra: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/containerinfra/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/containerinfra/... .PHONY: acceptance-containerinfra acceptance-db: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/db/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/db/... .PHONY: acceptance-db acceptance-dns: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/dns/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/dns/... .PHONY: acceptance-dns acceptance-identity: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/identity/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/identity/... .PHONY: acceptance-identity acceptance-image: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/image/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/image/... .PHONY: acceptance-image acceptance-keymanager: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/keymanager/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/keymanager/... .PHONY: acceptance-keymanager acceptance-loadbalancer: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/loadbalancer/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/loadbalancer/... .PHONY: acceptance-loadbalancer acceptance-messaging: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/messaging/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/messaging/... .PHONY: acceptance-messaging acceptance-networking: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/networking/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/networking/... .PHONY: acceptance-networking acceptance-objectstorage: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/objectstorage/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/objectstorage/... .PHONY: acceptance-objectstorage acceptance-orchestration: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/orchestration/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/orchestration/... .PHONY: acceptance-orchestration acceptance-placement: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/placement/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/placement/... .PHONY: acceptance-placement acceptance-sharedfilesystems: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/sharedfilesystems/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/sharedfilesystems/... .PHONY: acceptance-sharefilesystems acceptance-workflow: - $(GO_TEST) -tags "fixtures acceptance" ./internal/acceptance/openstack/workflow/... + $(GO_TEST) -timeout $(TIMEOUT) -tags "fixtures acceptance" ./internal/acceptance/openstack/workflow/... .PHONY: acceptance-workflow From e84fb1de91432667704fd1c4db3019c2f4276aef Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 17 Jul 2024 16:15:38 +0100 Subject: [PATCH 05/17] make: Create golangci-lint cache dir if necessary Signed-off-by: Stephen Finucane (cherry picked from commit 56b90f65323ee37de6fa9d84fff629ec4388d2c9) --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 47c397a6b1..86356b78ab 100644 --- a/Makefile +++ b/Makefile @@ -10,15 +10,18 @@ else RUNNER=podman endif -# if the golangci-lint steps fails with the following error message: +# if the golangci-lint steps fails with one of the following error messages: # # directory prefix . does not contain main module or its selected dependencies # +# failed to initialize build cache at /root/.cache/golangci-lint: mkdir /root/.cache/golangci-lint: permission denied +# # you probably have to fix the SELinux security context for root directory plus your cache # # chcon -Rt svirt_sandbox_file_t . # chcon -Rt svirt_sandbox_file_t ~/.cache/golangci-lint lint: + mkdir -p ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION) $(RUNNER) run -t --rm \ -v $(shell pwd):/app \ -v ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION):/root/.cache \ From 0106df855d280f8cce09ddc3ff74f61741337688 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 8 May 2024 18:10:36 +0100 Subject: [PATCH 06/17] CI: Switch to Makefile for running acceptance tests We can remove the 'acceptancetest' script in the process. Note that this isn't a 1:1 match: the fwaasv2 test job now runs the entire networking test suite and not just the fwaasv2-specific tests but seeing as this is using OVS rather than OVN that doesn't seem like such a bad thing. Signed-off-by: Stephen Finucane (cherry picked from commit 90cded10439a88581c9cd5afbbca206bc20c3230) --- .github/workflows/functional-baremetal.yaml | 5 ++-- .github/workflows/functional-basic.yaml | 5 ++-- .../workflows/functional-blockstorage.yaml | 5 ++-- .github/workflows/functional-compute.yaml | 5 ++-- .../workflows/functional-containerinfra.yaml | 5 ++-- .github/workflows/functional-dns.yaml | 5 ++-- .github/workflows/functional-fwaas_v2.yaml | 5 ++-- .github/workflows/functional-identity.yaml | 5 ++-- .github/workflows/functional-image.yaml | 5 ++-- .github/workflows/functional-keymanager.yaml | 5 ++-- .../workflows/functional-loadbalancer.yaml | 5 ++-- .github/workflows/functional-messaging.yaml | 5 ++-- .github/workflows/functional-networking.yaml | 5 ++-- .../workflows/functional-objectstorage.yaml | 5 ++-- .../workflows/functional-orchestration.yaml | 5 ++-- .github/workflows/functional-placement.yaml | 5 ++-- .../functional-sharedfilesystems.yaml | 5 ++-- .github/workflows/functional-workflow.yaml | 5 ++-- internal/acceptance/README.md | 8 +++++- script/acceptancetest | 26 ------------------- 20 files changed, 61 insertions(+), 63 deletions(-) delete mode 100755 script/acceptancetest diff --git a/.github/workflows/functional-baremetal.yaml b/.github/workflows/functional-baremetal.yaml index df5e4c88dc..384cc121a7 100644 --- a/.github/workflows/functional-baremetal.yaml +++ b/.github/workflows/functional-baremetal.yaml @@ -82,10 +82,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-baremetal env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/baremetal/..." OS_BRANCH: ${{ matrix.openstack_version }} USE_SYSTEM_SCOPE: true - name: Generate logs on failure diff --git a/.github/workflows/functional-basic.yaml b/.github/workflows/functional-basic.yaml index 6c3587c35d..aee751f2b9 100644 --- a/.github/workflows/functional-basic.yaml +++ b/.github/workflows/functional-basic.yaml @@ -41,10 +41,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-basic env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: './internal/acceptance/openstack' OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-blockstorage.yaml b/.github/workflows/functional-blockstorage.yaml index f94bef2658..742ce60a7a 100644 --- a/.github/workflows/functional-blockstorage.yaml +++ b/.github/workflows/functional-blockstorage.yaml @@ -40,10 +40,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-blockstorage env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/blockstorage/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-compute.yaml b/.github/workflows/functional-compute.yaml index b26c82b8da..515ec9d6b7 100644 --- a/.github/workflows/functional-compute.yaml +++ b/.github/workflows/functional-compute.yaml @@ -40,10 +40,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-compute env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/compute/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-containerinfra.yaml b/.github/workflows/functional-containerinfra.yaml index 59da6bf1d4..ecd728690e 100644 --- a/.github/workflows/functional-containerinfra.yaml +++ b/.github/workflows/functional-containerinfra.yaml @@ -61,10 +61,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-containerinfra env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/containerinfra/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-dns.yaml b/.github/workflows/functional-dns.yaml index cbf27b04f0..f9a468c5cc 100644 --- a/.github/workflows/functional-dns.yaml +++ b/.github/workflows/functional-dns.yaml @@ -49,10 +49,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-dns env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/dns/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-fwaas_v2.yaml b/.github/workflows/functional-fwaas_v2.yaml index 880fa8994c..890d198d28 100644 --- a/.github/workflows/functional-fwaas_v2.yaml +++ b/.github/workflows/functional-fwaas_v2.yaml @@ -45,10 +45,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-networking env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/networking/v2/extensions/fwaas_v2/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-identity.yaml b/.github/workflows/functional-identity.yaml index 9c58e24d5a..049a3fe343 100644 --- a/.github/workflows/functional-identity.yaml +++ b/.github/workflows/functional-identity.yaml @@ -38,10 +38,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-identity env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/identity/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-image.yaml b/.github/workflows/functional-image.yaml index 74164ae7e1..5e506a5fd2 100644 --- a/.github/workflows/functional-image.yaml +++ b/.github/workflows/functional-image.yaml @@ -38,10 +38,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-image env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/image/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-keymanager.yaml b/.github/workflows/functional-keymanager.yaml index bcdbe5c614..73f1584974 100644 --- a/.github/workflows/functional-keymanager.yaml +++ b/.github/workflows/functional-keymanager.yaml @@ -48,10 +48,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-keymanager env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/keymanager/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-loadbalancer.yaml b/.github/workflows/functional-loadbalancer.yaml index 142a30d123..eefa3f070b 100644 --- a/.github/workflows/functional-loadbalancer.yaml +++ b/.github/workflows/functional-loadbalancer.yaml @@ -49,10 +49,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-loadbalancer env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/loadbalancer/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-messaging.yaml b/.github/workflows/functional-messaging.yaml index f47e6f620c..d113187e8b 100644 --- a/.github/workflows/functional-messaging.yaml +++ b/.github/workflows/functional-messaging.yaml @@ -41,10 +41,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-messaging env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/messaging/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-networking.yaml b/.github/workflows/functional-networking.yaml index 7127596ff7..ee4647665d 100644 --- a/.github/workflows/functional-networking.yaml +++ b/.github/workflows/functional-networking.yaml @@ -55,10 +55,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-networking env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/networking/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-objectstorage.yaml b/.github/workflows/functional-objectstorage.yaml index 9b98a32d3f..4ffffcd865 100644 --- a/.github/workflows/functional-objectstorage.yaml +++ b/.github/workflows/functional-objectstorage.yaml @@ -44,10 +44,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-objectstorage env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/objectstorage/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-orchestration.yaml b/.github/workflows/functional-orchestration.yaml index 111a1c1a86..93c35070c3 100644 --- a/.github/workflows/functional-orchestration.yaml +++ b/.github/workflows/functional-orchestration.yaml @@ -40,10 +40,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-orchestration env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/orchestration/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-placement.yaml b/.github/workflows/functional-placement.yaml index 261bf74200..4df23efff2 100644 --- a/.github/workflows/functional-placement.yaml +++ b/.github/workflows/functional-placement.yaml @@ -38,10 +38,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-placement env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/placement/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-sharedfilesystems.yaml b/.github/workflows/functional-sharedfilesystems.yaml index 75704987d7..bc817a17b7 100644 --- a/.github/workflows/functional-sharedfilesystems.yaml +++ b/.github/workflows/functional-sharedfilesystems.yaml @@ -62,10 +62,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-sharedfilesystems env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/sharedfilesystems/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/.github/workflows/functional-workflow.yaml b/.github/workflows/functional-workflow.yaml index 376cc181e8..cf4c52fb72 100644 --- a/.github/workflows/functional-workflow.yaml +++ b/.github/workflows/functional-workflow.yaml @@ -43,10 +43,11 @@ jobs: with: go-version: '^1.22' - name: Run Gophercloud acceptance tests - run: ./script/acceptancetest + run: | + source ${{ github.workspace }}/script/stackenv + make acceptance-workflow env: DEVSTACK_PATH: ${{ github.workspace }}/devstack - PACKAGE: "./internal/acceptance/openstack/workflow/..." OS_BRANCH: ${{ matrix.openstack_version }} - name: Generate logs on failure run: ./script/collectlogs diff --git a/internal/acceptance/README.md b/internal/acceptance/README.md index cbbbac7f39..febf394f10 100644 --- a/internal/acceptance/README.md +++ b/internal/acceptance/README.md @@ -91,7 +91,13 @@ to set them manually. From the root directory, run: ``` -./script/acceptancetest +make acceptance +``` + +You can also run tests for a specific service: + +``` +make acceptance-compute ``` Alternatively, add the following to your `.bashrc`: diff --git a/script/acceptancetest b/script/acceptancetest deleted file mode 100755 index 7e223bae5e..0000000000 --- a/script/acceptancetest +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Run acceptance tests. - -# We intentionally don't set '-u' (error on unbound variables) or '-e' (exit on -# first failure) initially since DevStack is not designed to run with these -# flags and things crash and burn *spectacularly* 🔥🔥🔥 -set -xo pipefail - -# shellcheck disable=SC1091 -source "$(dirname "$0")/stackenv" - -# ...but we can do it after the fact -set -eu - -timeout="60m" - -LOG_DIR=${LOG_DIR:-} -if [[ -z "${LOG_DIR}" ]]; then - echo "LOG_DIR not set, will set a temp directory" - LOG_DIR=/tmp/devstack-logs -fi -mkdir -p "${LOG_DIR}" - -# shellcheck disable=SC2068 -go test -v -timeout $timeout -tags "fixtures acceptance" "${PACKAGE:-./internal/acceptance/openstack/...}" $@ |& tee -a "${LOG_DIR}/acceptance_tests.log" From 194878dc513613e1d457becfdc8fff9d37e2250c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 28 May 2024 16:08:22 +0100 Subject: [PATCH 07/17] CI: Switch to Makefile for running linters Signed-off-by: Stephen Finucane (cherry picked from commit 641d7c128f993a7d0a43f9b8c47b509f2e413f2e) --- .github/workflows/lint.yaml | 22 +++++++++------------- script/format | 7 ------- script/vet | 8 -------- 3 files changed, 9 insertions(+), 28 deletions(-) delete mode 100755 script/format delete mode 100755 script/vet diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 665b887187..ed7399819d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,27 +1,23 @@ -on: [push, pull_request] name: Linters +on: + - push + - pull_request permissions: contents: read - jobs: test: runs-on: ubuntu-latest - steps: + - name: Checkout Gophercloud + uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: '1' - - - uses: actions/checkout@v4 - - - name: Run go fmt + - name: Run linters run: | - ./script/format - - - name: Run go vet - run: | - ./script/vet - + make lint + # TODO: Use 'go mod tidy -diff' instead once go 1.23 is out + # https://github.com/golang/go/issues/27005 - name: Ensure go.mod is up-to-date run: | if [ $(go mod tidy && git diff | wc -l) -gt 0 ]; then git diff && exit 1; fi diff --git a/script/format b/script/format deleted file mode 100755 index 1bbf74ce39..0000000000 --- a/script/format +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -# -# Run 'go fmt' to warn about unformatted code - -set -euxo pipefail - -go fmt ./... diff --git a/script/vet b/script/vet deleted file mode 100755 index ecb74ef37d..0000000000 --- a/script/vet +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -# Run go vet. - -set -euxo pipefail - -export GOFLAGS="-tags=acceptance" -go vet ./... From e951c1a0100b2faebd2855efa9f00893955fb84a Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 28 May 2024 16:13:43 +0100 Subject: [PATCH 08/17] CI: Switch to Makefile for running unit tests Conflicts: .github/workflows/unit.yaml NOTE(stephenfin): Conflicts are due to trivial spacing. Signed-off-by: Stephen Finucane (cherry picked from commit c237277801bd53071228e74903c910eaee8d82d6) --- .github/workflows/unit.yaml | 19 +++++++------------ script/coverage | 24 ------------------------ script/unittest | 10 ---------- 3 files changed, 7 insertions(+), 46 deletions(-) delete mode 100755 script/coverage delete mode 100755 script/unittest diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index 0ae498baf7..abab3a5237 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -1,8 +1,9 @@ -on: [push, pull_request] name: Unit Testing +on: + - push + - pull_request permissions: contents: read - jobs: test: permissions: @@ -15,35 +16,29 @@ jobs: go-version: - "1.22.3" - "1" - steps: + - name: Checkout Gophercloud + uses: actions/checkout@v4 - name: Setup Go ${{ matrix.go-version }} uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - - uses: actions/checkout@v4 - - name: Setup environment run: | # Changing into a different directory to avoid polluting go.sum with "go get" cd "$(mktemp -d)" go mod init unit_tests - go install github.com/alexfalkowski/gocovmerge@v1.4.0 - - name: Run unit tests run: | - ./script/coverage - ./script/unittest - + make unit + make coverage - name: Check coverage uses: coverallsapp/github-action@v2 with: file: cover.out flag-name: Go-${{ matrix.go-version }} parallel: true - finish: permissions: checks: write # for coverallsapp/github-action to create a new check based on the results diff --git a/script/coverage b/script/coverage deleted file mode 100755 index ec5b2776b8..0000000000 --- a/script/coverage +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Run unit tests with coverage enabled. - -set -euxo pipefail - -n=1 -for testpkg in $(go list ./testing ./.../testing); do - covpkg="${testpkg/"/testing"/}" - go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$covpkg" "$testpkg" 2>/dev/null - n=$((n+1)) -done - -base_pkg=$(go list) -# Look for additional test files -for path in $(find . -path '*/testing' -prune -o -path '*/internal' -prune -o -name '*_test.go' -exec dirname {} \; | uniq); do - pkg="${base_pkg}${path:1}" - go test -covermode count -coverprofile "testing_"$n.coverprofile -coverpkg "$pkg" "$pkg" 2>/dev/null - n=$((n+1)) -done - -# shellcheck disable=SC2046 -gocovmerge $(ls -- *.coverprofile) > cover.out -rm ./*.coverprofile diff --git a/script/unittest b/script/unittest deleted file mode 100755 index 1f1b1864f4..0000000000 --- a/script/unittest +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -# Run the unit tests. - -set -euxo pipefail - -# Do extra rounds of testing to help identify reauth concurrency issues. -# All other packages are tested in the `coverage` tests. -# shellcheck disable=SC2068 -go test -v -race -count=5 ./testing $@ From e71d6720452e4ee35e784c92b9eb1791d0dcc029 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 28 May 2024 16:15:28 +0100 Subject: [PATCH 09/17] script: Remove unused script Users can use 'make unit' for this now. Signed-off-by: Stephen Finucane (cherry picked from commit 5d3669360365e02a26344e66147fdf43bc221b5a) --- script/test | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 script/test diff --git a/script/test b/script/test deleted file mode 100755 index e71e7514bb..0000000000 --- a/script/test +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -# Run all the tests. - -set -euxo pipefail - -# shellcheck disable=SC2068 -go test -v -tags 'acceptance fixtures' ./... $@ From 4b982e2bb2a29580fb37c510196f27abc15dc0f6 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 4 Dec 2024 17:26:58 +0000 Subject: [PATCH 10/17] Remove workarounds for untested Ubuntu versions We no longer test on Ubuntu 20.04. Signed-off-by: Stephen Finucane (cherry picked from commit 05723996dceb14849cef43b56f402fee96e57de7) --- .github/workflows/functional-baremetal.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/functional-baremetal.yaml b/.github/workflows/functional-baremetal.yaml index 384cc121a7..ad04f95913 100644 --- a/.github/workflows/functional-baremetal.yaml +++ b/.github/workflows/functional-baremetal.yaml @@ -28,14 +28,6 @@ jobs: steps: - name: Checkout Gophercloud uses: actions/checkout@v4 - - name: Workaround for grub-efi-amd64-signed - run: sudo rm /var/cache/debconf/config.dat - shell: bash - if: matrix.ubuntu_version == '20.04' - - name: Ensure update and upgrade - run: sudo apt update && sudo apt -y upgrade - shell: bash - if: matrix.ubuntu_version == '20.04' - name: Work around broken dnsmasq run: sudo apt-get purge -y dnsmasq-base - name: Deploy devstack From f36037cb3c532c09e2bb3b8b5e0b0f4407d60609 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 13 May 2025 17:32:29 +0100 Subject: [PATCH 11/17] Replace errant character in workflows It's annoying that GitHub doesn't surface this error. Signed-off-by: Stephen Finucane Fixes: c4a191eea6af0d7cf6b1ff71312a0b493ba066a6 (cherry picked from commit 7c10efbf7c3b35cbbc6f650f72f4e0ee6344784d) --- .github/workflows/functional-baremetal.yaml | 2 +- .github/workflows/functional-basic.yaml | 2 +- .github/workflows/functional-blockstorage.yaml | 2 +- .github/workflows/functional-compute.yaml | 2 +- .github/workflows/functional-containerinfra.yaml | 2 +- .github/workflows/functional-dns.yaml | 2 +- .github/workflows/functional-fwaas_v2.yaml | 2 +- .github/workflows/functional-identity.yaml | 2 +- .github/workflows/functional-image.yaml | 2 +- .github/workflows/functional-keymanager.yaml | 2 +- .github/workflows/functional-loadbalancer.yaml | 2 +- .github/workflows/functional-messaging.yaml | 2 +- .github/workflows/functional-networking.yaml | 2 +- .github/workflows/functional-objectstorage.yaml | 2 +- .github/workflows/functional-orchestration.yaml | 2 +- .github/workflows/functional-placement.yaml | 2 +- .github/workflows/functional-sharedfilesystems.yaml | 2 +- .github/workflows/functional-workflow.yaml | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/functional-baremetal.yaml b/.github/workflows/functional-baremetal.yaml index ad04f95913..19fb54fc02 100644 --- a/.github/workflows/functional-baremetal.yaml +++ b/.github/workflows/functional-baremetal.yaml @@ -31,7 +31,7 @@ jobs: - name: Work around broken dnsmasq run: sudo apt-get purge -y dnsmasq-base - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-basic.yaml b/.github/workflows/functional-basic.yaml index aee751f2b9..80808ac181 100644 --- a/.github/workflows/functional-basic.yaml +++ b/.github/workflows/functional-basic.yaml @@ -32,7 +32,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} enabled_services: 's-account,s-container,s-object,s-proxy,${{ matrix.additional_services }}' diff --git a/.github/workflows/functional-blockstorage.yaml b/.github/workflows/functional-blockstorage.yaml index 742ce60a7a..8ee647a364 100644 --- a/.github/workflows/functional-blockstorage.yaml +++ b/.github/workflows/functional-blockstorage.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-compute.yaml b/.github/workflows/functional-compute.yaml index 515ec9d6b7..e65d553344 100644 --- a/.github/workflows/functional-compute.yaml +++ b/.github/workflows/functional-compute.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-containerinfra.yaml b/.github/workflows/functional-containerinfra.yaml index ecd728690e..5a4bdbc31d 100644 --- a/.github/workflows/functional-containerinfra.yaml +++ b/.github/workflows/functional-containerinfra.yaml @@ -44,7 +44,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-dns.yaml b/.github/workflows/functional-dns.yaml index f9a468c5cc..e95c2173ce 100644 --- a/.github/workflows/functional-dns.yaml +++ b/.github/workflows/functional-dns.yaml @@ -36,7 +36,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-fwaas_v2.yaml b/.github/workflows/functional-fwaas_v2.yaml index 890d198d28..96dfff581a 100644 --- a/.github/workflows/functional-fwaas_v2.yaml +++ b/.github/workflows/functional-fwaas_v2.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-identity.yaml b/.github/workflows/functional-identity.yaml index 049a3fe343..6bdf6a2c0b 100644 --- a/.github/workflows/functional-identity.yaml +++ b/.github/workflows/functional-identity.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} enabled_services: "${{ matrix.additional_services }}" diff --git a/.github/workflows/functional-image.yaml b/.github/workflows/functional-image.yaml index 5e506a5fd2..d4f7e0e4f1 100644 --- a/.github/workflows/functional-image.yaml +++ b/.github/workflows/functional-image.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} enabled_services: "${{ matrix.additional_services }}" diff --git a/.github/workflows/functional-keymanager.yaml b/.github/workflows/functional-keymanager.yaml index 73f1584974..96a653d421 100644 --- a/.github/workflows/functional-keymanager.yaml +++ b/.github/workflows/functional-keymanager.yaml @@ -35,7 +35,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-loadbalancer.yaml b/.github/workflows/functional-loadbalancer.yaml index eefa3f070b..6145d10c25 100644 --- a/.github/workflows/functional-loadbalancer.yaml +++ b/.github/workflows/functional-loadbalancer.yaml @@ -35,7 +35,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-messaging.yaml b/.github/workflows/functional-messaging.yaml index d113187e8b..b007942410 100644 --- a/.github/workflows/functional-messaging.yaml +++ b/.github/workflows/functional-messaging.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-networking.yaml b/.github/workflows/functional-networking.yaml index ee4647665d..c4cd4a149c 100644 --- a/.github/workflows/functional-networking.yaml +++ b/.github/workflows/functional-networking.yaml @@ -37,7 +37,7 @@ jobs: "update_port:binding:profile": "rule:admin_only or rule:service_api" EOF - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-objectstorage.yaml b/.github/workflows/functional-objectstorage.yaml index 4ffffcd865..0e31102a7d 100644 --- a/.github/workflows/functional-objectstorage.yaml +++ b/.github/workflows/functional-objectstorage.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-orchestration.yaml b/.github/workflows/functional-orchestration.yaml index 93c35070c3..8ee464602d 100644 --- a/.github/workflows/functional-orchestration.yaml +++ b/.github/workflows/functional-orchestration.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-placement.yaml b/.github/workflows/functional-placement.yaml index 4df23efff2..6afb44a0c1 100644 --- a/.github/workflows/functional-placement.yaml +++ b/.github/workflows/functional-placement.yaml @@ -29,7 +29,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} enabled_services: "${{ matrix.additional_services }}" diff --git a/.github/workflows/functional-sharedfilesystems.yaml b/.github/workflows/functional-sharedfilesystems.yaml index bc817a17b7..cf737ac368 100644 --- a/.github/workflows/functional-sharedfilesystems.yaml +++ b/.github/workflows/functional-sharedfilesystems.yaml @@ -35,7 +35,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | diff --git a/.github/workflows/functional-workflow.yaml b/.github/workflows/functional-workflow.yaml index cf4c52fb72..62f2af2698 100644 --- a/.github/workflows/functional-workflow.yaml +++ b/.github/workflows/functional-workflow.yaml @@ -32,7 +32,7 @@ jobs: - name: Checkout Gophercloud uses: actions/checkout@v4 - name: Deploy devstack - uses: gophercloud@devstack-action@v0.17 + uses: gophercloud/devstack-action@v0.17 with: branch: ${{ matrix.openstack_version }} conf_overrides: | From b113a13593f9c6d710fddae260af35b55866752b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 13 May 2025 17:02:29 +0100 Subject: [PATCH 12/17] Run functional tests if workflow changes Signed-off-by: Stephen Finucane (cherry picked from commit 69b54462666840df025cdee8dfd76bfda4fddd81) --- .github/workflows/functional-baremetal.yaml | 1 + .github/workflows/functional-blockstorage.yaml | 1 + .github/workflows/functional-compute.yaml | 1 + .github/workflows/functional-containerinfra.yaml | 1 + .github/workflows/functional-dns.yaml | 4 ++-- .github/workflows/functional-fwaas_v2.yaml | 1 + .github/workflows/functional-identity.yaml | 1 + .github/workflows/functional-image.yaml | 1 + .github/workflows/functional-keymanager.yaml | 1 + .github/workflows/functional-loadbalancer.yaml | 1 + .github/workflows/functional-messaging.yaml | 1 + .github/workflows/functional-networking.yaml | 1 + .github/workflows/functional-objectstorage.yaml | 1 + .github/workflows/functional-orchestration.yaml | 1 + .github/workflows/functional-placement.yaml | 1 + .github/workflows/functional-sharedfilesystems.yaml | 1 + .github/workflows/functional-workflow.yaml | 1 + 17 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/functional-baremetal.yaml b/.github/workflows/functional-baremetal.yaml index 19fb54fc02..eb04f8c920 100644 --- a/.github/workflows/functional-baremetal.yaml +++ b/.github/workflows/functional-baremetal.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**baremetal**' + - '.github/workflows/functional-baremetal.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-blockstorage.yaml b/.github/workflows/functional-blockstorage.yaml index 8ee647a364..1a36b0da04 100644 --- a/.github/workflows/functional-blockstorage.yaml +++ b/.github/workflows/functional-blockstorage.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**blockstorage**' + - '.github/workflows/functional-blockstorage.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-compute.yaml b/.github/workflows/functional-compute.yaml index e65d553344..87f0ef7e67 100644 --- a/.github/workflows/functional-compute.yaml +++ b/.github/workflows/functional-compute.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**compute**' + - '.github/workflows/functional-compute.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-containerinfra.yaml b/.github/workflows/functional-containerinfra.yaml index 5a4bdbc31d..ad3c275b66 100644 --- a/.github/workflows/functional-containerinfra.yaml +++ b/.github/workflows/functional-containerinfra.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**containerinfra**' + - '.github/workflows/functional-containerinfra.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-dns.yaml b/.github/workflows/functional-dns.yaml index e95c2173ce..43e8123cc0 100644 --- a/.github/workflows/functional-dns.yaml +++ b/.github/workflows/functional-dns.yaml @@ -2,8 +2,8 @@ name: functional-dns on: pull_request: paths: - - '**openstack/dns**' - - '**functional-dns.yaml' + - '**dns**' + - '.github/workflows/functional-dns.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-fwaas_v2.yaml b/.github/workflows/functional-fwaas_v2.yaml index 96dfff581a..f715da56a9 100644 --- a/.github/workflows/functional-fwaas_v2.yaml +++ b/.github/workflows/functional-fwaas_v2.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**networking/v2/extensions/fwaas_v2**' + - '.github/workflows/functional-fwaas_v2.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-identity.yaml b/.github/workflows/functional-identity.yaml index 6bdf6a2c0b..d3cb23f02c 100644 --- a/.github/workflows/functional-identity.yaml +++ b/.github/workflows/functional-identity.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**identity**' + - '.github/workflows/functional-identity.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-image.yaml b/.github/workflows/functional-image.yaml index d4f7e0e4f1..26579dd4e7 100644 --- a/.github/workflows/functional-image.yaml +++ b/.github/workflows/functional-image.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**image**' + - '.github/workflows/functional-image.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-keymanager.yaml b/.github/workflows/functional-keymanager.yaml index 96a653d421..099939e5a3 100644 --- a/.github/workflows/functional-keymanager.yaml +++ b/.github/workflows/functional-keymanager.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**keymanager**' + - '.github/workflows/functional-keymanager.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-loadbalancer.yaml b/.github/workflows/functional-loadbalancer.yaml index 6145d10c25..6b720aecac 100644 --- a/.github/workflows/functional-loadbalancer.yaml +++ b/.github/workflows/functional-loadbalancer.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**loadbalancer**' + - '.github/workflows/functional-loadbalancer.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-messaging.yaml b/.github/workflows/functional-messaging.yaml index b007942410..0ddb5f1efd 100644 --- a/.github/workflows/functional-messaging.yaml +++ b/.github/workflows/functional-messaging.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**messaging**' + - '.github/workflows/functional-messaging.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-networking.yaml b/.github/workflows/functional-networking.yaml index c4cd4a149c..a0608a2b98 100644 --- a/.github/workflows/functional-networking.yaml +++ b/.github/workflows/functional-networking.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**networking**' + - '.github/workflows/functional-networking.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-objectstorage.yaml b/.github/workflows/functional-objectstorage.yaml index 0e31102a7d..b22f5ef454 100644 --- a/.github/workflows/functional-objectstorage.yaml +++ b/.github/workflows/functional-objectstorage.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**objectstorage**' + - '.github/workflows/functional-objectstorage.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-orchestration.yaml b/.github/workflows/functional-orchestration.yaml index 8ee464602d..a301e45688 100644 --- a/.github/workflows/functional-orchestration.yaml +++ b/.github/workflows/functional-orchestration.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**orchestration**' + - '.github/workflows/functional-orchestration.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-placement.yaml b/.github/workflows/functional-placement.yaml index 6afb44a0c1..c6356e95e2 100644 --- a/.github/workflows/functional-placement.yaml +++ b/.github/workflows/functional-placement.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**placement**' + - '.github/workflows/functional-placement.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-sharedfilesystems.yaml b/.github/workflows/functional-sharedfilesystems.yaml index cf737ac368..08aca0f0e8 100644 --- a/.github/workflows/functional-sharedfilesystems.yaml +++ b/.github/workflows/functional-sharedfilesystems.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**sharedfilesystems**' + - '.github/workflows/functional-sharedfilesystems.yaml' schedule: - cron: '0 0 */3 * *' jobs: diff --git a/.github/workflows/functional-workflow.yaml b/.github/workflows/functional-workflow.yaml index 62f2af2698..d4d389581b 100644 --- a/.github/workflows/functional-workflow.yaml +++ b/.github/workflows/functional-workflow.yaml @@ -3,6 +3,7 @@ on: pull_request: paths: - '**workflow**' + - '.github/workflows/functional-workflow.yaml' schedule: - cron: '0 0 */3 * *' jobs: From 243570027ee37c2dca463c6b71e631a986143171 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 7 May 2025 11:11:12 +0100 Subject: [PATCH 13/17] tests: Devolve acceptance test conditions Place service-specific conditions in service-specific locations. We also removed the now-unused RequireNovaNetwork helper. Conflicts: internal/acceptance/openstack/baremetal/httpbasic/portgroups_test.go NOTE(stephenfin): Conflicts are because the file doesn't exist on the v2 branch (yet) Signed-off-by: Stephen Finucane (cherry picked from commit 2a22f9d7af83e3a8d284a4815a527df16ae1d799) --- internal/acceptance/clients/conditions.go | 97 +++---------------- .../baremetal/httpbasic/allocations_test.go | 2 +- .../baremetal/httpbasic/conditions.go | 14 +++ .../baremetal/httpbasic/nodes_test.go | 8 +- .../baremetal/httpbasic/ports_test.go | 4 +- .../baremetal/noauth/allocations_test.go | 2 +- .../openstack/baremetal/noauth/conditions.go | 15 +++ .../openstack/baremetal/noauth/nodes_test.go | 6 +- .../openstack/baremetal/noauth/ports_test.go | 4 +- .../blockstorage/noauth/conditions.go | 14 +++ .../blockstorage/noauth/snapshots_test.go | 4 +- .../blockstorage/noauth/volumes_test.go | 4 +- .../openstack/compute/v2/conditions.go | 22 +++++ .../openstack/compute/v2/migrate_test.go | 2 +- .../openstack/compute/v2/servers_test.go | 2 +- .../openstack/identity/v2/conditions.go | 14 +++ .../openstack/identity/v2/extension_test.go | 4 +- .../openstack/identity/v2/role_test.go | 4 +- .../openstack/identity/v2/tenant_test.go | 4 +- .../openstack/identity/v2/token_test.go | 4 +- .../openstack/identity/v2/user_test.go | 4 +- .../openstack/networking/v2/conditions.go | 9 ++ .../extensions/layer3/portforwardings_test.go | 2 +- .../sharedfilesystems/v2/conditions.go | 14 +++ .../sharedfilesystems/v2/replicas_test.go | 12 +-- 25 files changed, 151 insertions(+), 120 deletions(-) create mode 100644 internal/acceptance/openstack/baremetal/httpbasic/conditions.go create mode 100644 internal/acceptance/openstack/baremetal/noauth/conditions.go create mode 100644 internal/acceptance/openstack/blockstorage/noauth/conditions.go create mode 100644 internal/acceptance/openstack/compute/v2/conditions.go create mode 100644 internal/acceptance/openstack/identity/v2/conditions.go create mode 100644 internal/acceptance/openstack/sharedfilesystems/v2/conditions.go diff --git a/internal/acceptance/clients/conditions.go b/internal/acceptance/clients/conditions.go index c48ac208a9..6077f4bdef 100644 --- a/internal/acceptance/clients/conditions.go +++ b/internal/acceptance/clients/conditions.go @@ -14,14 +14,6 @@ func RequiredSystemScope(t *testing.T) { } } -// RequireManilaReplicas will restrict a test to only be run with enabled -// manila replicas. -func RequireManilaReplicas(t *testing.T) { - if os.Getenv("OS_MANILA_REPLICAS") != "true" { - t.Skip("manila replicas must be enabled to run this test") - } -} - // RequireAdmin will restrict a test to only be run by admin users. func RequireAdmin(t *testing.T) { if os.Getenv("OS_USERNAME") != "admin" { @@ -36,38 +28,6 @@ func RequireNonAdmin(t *testing.T) { } } -// RequirePortForwarding will restrict a test to only be run in environments -// that support port forwarding -func RequirePortForwarding(t *testing.T) { - if os.Getenv("OS_PORTFORWARDING_ENVIRONMENT") == "" { - t.Skip("this test requires support for port forwarding") - } -} - -// RequireGuestAgent will restrict a test to only be run in -// environments that support the QEMU guest agent. -func RequireGuestAgent(t *testing.T) { - if os.Getenv("OS_GUEST_AGENT") == "" { - t.Skip("this test requires support for qemu guest agent and to set OS_GUEST_AGENT to 1") - } -} - -// RequireIdentityV2 will restrict a test to only be run in -// environments that support the Identity V2 API. -func RequireIdentityV2(t *testing.T) { - if os.Getenv("OS_IDENTITY_API_VERSION") != "2.0" { - t.Skip("this test requires support for the identity v2 API") - } -} - -// RequireLiveMigration will restrict a test to only be run in -// environments that support live migration. -func RequireLiveMigration(t *testing.T) { - if os.Getenv("OS_LIVE_MIGRATE") == "" { - t.Skip("this test requires support for live migration and to set OS_LIVE_MIGRATE to 1") - } -} - // RequireLong will ensure long-running tests can run. func RequireLong(t *testing.T) { if testing.Short() { @@ -75,38 +35,6 @@ func RequireLong(t *testing.T) { } } -// RequireNovaNetwork will restrict a test to only be run in -// environments that support nova-network. -func RequireNovaNetwork(t *testing.T) { - if os.Getenv("OS_NOVANET") == "" { - t.Skip("this test requires nova-network and to set OS_NOVANET to 1") - } -} - -// RequireCinderNoAuth will restrict a test to be only run in environments that -// have Cinder using noauth. -func RequireCinderNoAuth(t *testing.T) { - if os.Getenv("CINDER_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" { - t.Skip("this test requires Cinder using noauth, set OS_USERNAME and CINDER_ENDPOINT") - } -} - -// RequireIronicNoAuth will restrict a test to be only run in environments that -// have Ironic using noauth. -func RequireIronicNoAuth(t *testing.T) { - if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" { - t.Skip("this test requires IRONIC using noauth, set OS_USERNAME and IRONIC_ENDPOINT") - } -} - -// RequireIronicHTTPBasic will restrict a test to be only run in environments -// that have Ironic using http_basic. -func RequireIronicHTTPBasic(t *testing.T) { - if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" || os.Getenv("OS_PASSWORD") == "" { - t.Skip("this test requires Ironic using http_basic, set OS_USERNAME, OS_PASSWORD and IRONIC_ENDPOINT") - } -} - func getReleaseFromEnv(t *testing.T) string { current := strings.TrimPrefix(os.Getenv("OS_BRANCH"), "stable/") if current == "" { @@ -115,8 +43,8 @@ func getReleaseFromEnv(t *testing.T) string { return current } -// SkipRelease will have the test be skipped on a certain -// release. Releases are named such as 'stable/mitaka', master, etc. +// SkipRelease will have the test be skipped on a certain release. +// Releases are named such as 'stable/dalmatian', master, etc. func SkipRelease(t *testing.T, release string) { current := getReleaseFromEnv(t) if current == strings.TrimPrefix(release, "stable/") { @@ -124,8 +52,8 @@ func SkipRelease(t *testing.T, release string) { } } -// SkipReleasesBelow will have the test be skipped on releases below a certain -// one. Releases are named such as 'stable/mitaka', master, etc. +// SkipReleasesBelow will have the test be skipped on releases below a certain one. +// Releases are named such as 'stable/dalmatian', master, etc. func SkipReleasesBelow(t *testing.T, release string) { current := getReleaseFromEnv(t) @@ -134,9 +62,9 @@ func SkipReleasesBelow(t *testing.T, release string) { } } -// SkipReleasesAbove will have the test be skipped on releases above a certain -// one. The test is always skipped on master release. Releases are named such -// as 'stable/mitaka', master, etc. +// SkipReleasesAbove will have the test be skipped on releases above a certain one. +// The test is always skipped on master release. +// Releases are named such as 'stable/dalmatian', master, etc. func SkipReleasesAbove(t *testing.T, release string) { current := getReleaseFromEnv(t) @@ -150,9 +78,9 @@ func isReleaseNumeral(release string) bool { return err == nil } -// IsCurrentAbove will return true on releases above a certain -// one. The result is always true on master release. Releases are named such -// as 'stable/mitaka', master, etc. +// IsCurrentAbove will return true on releases above a certain one. +// The result is always true on master release. +// Releases are named such as 'stable/dalmatian', master, etc. func IsCurrentAbove(t *testing.T, release string) bool { current := getReleaseFromEnv(t) release = strings.TrimPrefix(release, "stable/") @@ -174,8 +102,9 @@ func IsCurrentAbove(t *testing.T, release string) bool { return false } -// IsCurrentBelow will return true on releases below a certain -// one. Releases are named such as 'stable/mitaka', master, etc. +// IsCurrentBelow will return true on releases below a certain one. +// The result is always false on master release. +// Releases are named such as 'stable/dalmatian', master, etc. func IsCurrentBelow(t *testing.T, release string) bool { current := getReleaseFromEnv(t) release = strings.TrimPrefix(release, "stable/") diff --git a/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go b/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go index 932c067ad0..faa667d05b 100644 --- a/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go @@ -15,7 +15,7 @@ import ( func TestAllocationsCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/baremetal/httpbasic/conditions.go b/internal/acceptance/openstack/baremetal/httpbasic/conditions.go new file mode 100644 index 0000000000..15d1c9f724 --- /dev/null +++ b/internal/acceptance/openstack/baremetal/httpbasic/conditions.go @@ -0,0 +1,14 @@ +package httpbasic + +import ( + "os" + "testing" +) + +// RequireIronicHTTPBasic will restrict a test to be only run in environments +// that have Ironic using http_basic. +func RequireIronicHTTPBasic(t *testing.T) { + if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" || os.Getenv("OS_PASSWORD") == "" { + t.Skip("this test requires Ironic using http_basic, set OS_USERNAME, OS_PASSWORD and IRONIC_ENDPOINT") + } +} diff --git a/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go b/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go index e35ae1e25a..a0c656d7f7 100644 --- a/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/nodes_test.go @@ -16,7 +16,7 @@ import ( func TestNodesCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) @@ -49,7 +49,7 @@ func TestNodesCreateDestroy(t *testing.T) { func TestNodesUpdate(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) @@ -74,7 +74,7 @@ func TestNodesUpdate(t *testing.T) { func TestNodesRAIDConfig(t *testing.T) { clients.SkipReleasesBelow(t, "stable/ussuri") clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) @@ -104,7 +104,7 @@ func TestNodesRAIDConfig(t *testing.T) { func TestNodesFirmwareInterface(t *testing.T) { clients.SkipReleasesBelow(t, "stable/2023.2") clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go b/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go index 9912c49322..7773f8b23e 100644 --- a/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go +++ b/internal/acceptance/openstack/baremetal/httpbasic/ports_test.go @@ -16,7 +16,7 @@ import ( func TestPortsCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) @@ -52,7 +52,7 @@ func TestPortsCreateDestroy(t *testing.T) { func TestPortsUpdate(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicHTTPBasic(t) + RequireIronicHTTPBasic(t) client, err := clients.NewBareMetalV1HTTPBasic() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/baremetal/noauth/allocations_test.go b/internal/acceptance/openstack/baremetal/noauth/allocations_test.go index e6cb33ac3d..d0b34737c5 100644 --- a/internal/acceptance/openstack/baremetal/noauth/allocations_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/allocations_test.go @@ -15,7 +15,7 @@ import ( func TestAllocationsCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/baremetal/noauth/conditions.go b/internal/acceptance/openstack/baremetal/noauth/conditions.go new file mode 100644 index 0000000000..762f141f52 --- /dev/null +++ b/internal/acceptance/openstack/baremetal/noauth/conditions.go @@ -0,0 +1,15 @@ +package noauth + +import ( + "os" + "testing" +) + +// RequireIronicNoAuth will restrict a test to be only run in environments that + +// have Ironic using noauth. +func RequireIronicNoAuth(t *testing.T) { + if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" { + t.Skip("this test requires IRONIC using noauth, set OS_USERNAME and IRONIC_ENDPOINT") + } +} diff --git a/internal/acceptance/openstack/baremetal/noauth/nodes_test.go b/internal/acceptance/openstack/baremetal/noauth/nodes_test.go index bd05203b2e..64b9826a03 100644 --- a/internal/acceptance/openstack/baremetal/noauth/nodes_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/nodes_test.go @@ -16,7 +16,7 @@ import ( func TestNodesCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) @@ -49,7 +49,7 @@ func TestNodesCreateDestroy(t *testing.T) { func TestNodesUpdate(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) @@ -74,7 +74,7 @@ func TestNodesUpdate(t *testing.T) { func TestNodesRAIDConfig(t *testing.T) { clients.SkipReleasesBelow(t, "stable/ussuri") clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/baremetal/noauth/ports_test.go b/internal/acceptance/openstack/baremetal/noauth/ports_test.go index 980b2dec32..3f10b3b85c 100644 --- a/internal/acceptance/openstack/baremetal/noauth/ports_test.go +++ b/internal/acceptance/openstack/baremetal/noauth/ports_test.go @@ -16,7 +16,7 @@ import ( func TestPortsCreateDestroy(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) @@ -52,7 +52,7 @@ func TestPortsCreateDestroy(t *testing.T) { func TestPortsUpdate(t *testing.T) { clients.RequireLong(t) - clients.RequireIronicNoAuth(t) + RequireIronicNoAuth(t) client, err := clients.NewBareMetalV1NoAuthClient() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/blockstorage/noauth/conditions.go b/internal/acceptance/openstack/blockstorage/noauth/conditions.go new file mode 100644 index 0000000000..b1fd42e3bb --- /dev/null +++ b/internal/acceptance/openstack/blockstorage/noauth/conditions.go @@ -0,0 +1,14 @@ +package noauth + +import ( + "os" + "testing" +) + +// RequireCinderNoAuth will restrict a test to be only run in environments that +// have Cinder using noauth. +func RequireCinderNoAuth(t *testing.T) { + if os.Getenv("CINDER_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" { + t.Skip("this test requires Cinder using noauth, set OS_USERNAME and CINDER_ENDPOINT") + } +} diff --git a/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go b/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go index 5b8bb2a982..f1daa352eb 100644 --- a/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go +++ b/internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go @@ -12,7 +12,7 @@ import ( ) func TestSnapshotsList(t *testing.T) { - clients.RequireCinderNoAuth(t) + RequireCinderNoAuth(t) client, err := clients.NewBlockStorageV3NoAuthClient() if err != nil { @@ -35,7 +35,7 @@ func TestSnapshotsList(t *testing.T) { } func TestSnapshotsCreateDelete(t *testing.T) { - clients.RequireCinderNoAuth(t) + RequireCinderNoAuth(t) client, err := clients.NewBlockStorageV3NoAuthClient() if err != nil { diff --git a/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go b/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go index 0c993addad..15d4815426 100644 --- a/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go +++ b/internal/acceptance/openstack/blockstorage/noauth/volumes_test.go @@ -12,7 +12,7 @@ import ( ) func TestVolumesList(t *testing.T) { - clients.RequireCinderNoAuth(t) + RequireCinderNoAuth(t) client, err := clients.NewBlockStorageV3NoAuthClient() if err != nil { @@ -35,7 +35,7 @@ func TestVolumesList(t *testing.T) { } func TestVolumesCreateDestroy(t *testing.T) { - clients.RequireCinderNoAuth(t) + RequireCinderNoAuth(t) client, err := clients.NewBlockStorageV3NoAuthClient() if err != nil { diff --git a/internal/acceptance/openstack/compute/v2/conditions.go b/internal/acceptance/openstack/compute/v2/conditions.go new file mode 100644 index 0000000000..565a3e1cfe --- /dev/null +++ b/internal/acceptance/openstack/compute/v2/conditions.go @@ -0,0 +1,22 @@ +package v2 + +import ( + "os" + "testing" +) + +// RequireGuestAgent will restrict a test to only be run in +// environments that support the QEMU guest agent. +func RequireGuestAgent(t *testing.T) { + if os.Getenv("OS_GUEST_AGENT") == "" { + t.Skip("this test requires support for qemu guest agent and to set OS_GUEST_AGENT to 1") + } +} + +// RequireLiveMigration will restrict a test to only be run in +// environments that support live migration. +func RequireLiveMigration(t *testing.T) { + if os.Getenv("OS_LIVE_MIGRATE") == "" { + t.Skip("this test requires support for live migration and to set OS_LIVE_MIGRATE to 1") + } +} diff --git a/internal/acceptance/openstack/compute/v2/migrate_test.go b/internal/acceptance/openstack/compute/v2/migrate_test.go index f22d6e67c6..6db845c0b3 100644 --- a/internal/acceptance/openstack/compute/v2/migrate_test.go +++ b/internal/acceptance/openstack/compute/v2/migrate_test.go @@ -31,7 +31,7 @@ func TestMigrate(t *testing.T) { func TestLiveMigrate(t *testing.T) { clients.RequireLong(t) clients.RequireAdmin(t) - clients.RequireLiveMigration(t) + RequireLiveMigration(t) client, err := clients.NewComputeV2Client() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/compute/v2/servers_test.go b/internal/acceptance/openstack/compute/v2/servers_test.go index 5934805ba2..0c5d034491 100644 --- a/internal/acceptance/openstack/compute/v2/servers_test.go +++ b/internal/acceptance/openstack/compute/v2/servers_test.go @@ -234,7 +234,7 @@ func TestServersMetadata(t *testing.T) { func TestServersActionChangeAdminPassword(t *testing.T) { clients.RequireLong(t) - clients.RequireGuestAgent(t) + RequireGuestAgent(t) client, err := clients.NewComputeV2Client() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/identity/v2/conditions.go b/internal/acceptance/openstack/identity/v2/conditions.go new file mode 100644 index 0000000000..9871afaf30 --- /dev/null +++ b/internal/acceptance/openstack/identity/v2/conditions.go @@ -0,0 +1,14 @@ +package v2 + +import ( + "os" + "testing" +) + +// RequireIdentityV2 will restrict a test to only be run in +// environments that support the Identity V2 API. +func RequireIdentityV2(t *testing.T) { + if os.Getenv("OS_IDENTITY_API_VERSION") != "2.0" { + t.Skip("this test requires support for the identity v2 API") + } +} diff --git a/internal/acceptance/openstack/identity/v2/extension_test.go b/internal/acceptance/openstack/identity/v2/extension_test.go index ada4ddef4f..f43523340a 100644 --- a/internal/acceptance/openstack/identity/v2/extension_test.go +++ b/internal/acceptance/openstack/identity/v2/extension_test.go @@ -13,7 +13,7 @@ import ( ) func TestExtensionsList(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2Client() @@ -37,7 +37,7 @@ func TestExtensionsList(t *testing.T) { } func TestExtensionsGet(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2Client() diff --git a/internal/acceptance/openstack/identity/v2/role_test.go b/internal/acceptance/openstack/identity/v2/role_test.go index 2eed42a3c3..49635f7f98 100644 --- a/internal/acceptance/openstack/identity/v2/role_test.go +++ b/internal/acceptance/openstack/identity/v2/role_test.go @@ -14,7 +14,7 @@ import ( ) func TestRolesAddToUser(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2AdminClient() @@ -53,7 +53,7 @@ func TestRolesAddToUser(t *testing.T) { } func TestRolesList(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2AdminClient() diff --git a/internal/acceptance/openstack/identity/v2/tenant_test.go b/internal/acceptance/openstack/identity/v2/tenant_test.go index d390f14d35..2c7092e91d 100644 --- a/internal/acceptance/openstack/identity/v2/tenant_test.go +++ b/internal/acceptance/openstack/identity/v2/tenant_test.go @@ -13,7 +13,7 @@ import ( ) func TestTenantsList(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2Client() @@ -38,7 +38,7 @@ func TestTenantsList(t *testing.T) { } func TestTenantsCRUD(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2AdminClient() diff --git a/internal/acceptance/openstack/identity/v2/token_test.go b/internal/acceptance/openstack/identity/v2/token_test.go index fba2dbc0a5..61d93f2187 100644 --- a/internal/acceptance/openstack/identity/v2/token_test.go +++ b/internal/acceptance/openstack/identity/v2/token_test.go @@ -14,7 +14,7 @@ import ( ) func TestTokenAuthenticate(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2UnauthenticatedClient() @@ -38,7 +38,7 @@ func TestTokenAuthenticate(t *testing.T) { } func TestTokenValidate(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2Client() diff --git a/internal/acceptance/openstack/identity/v2/user_test.go b/internal/acceptance/openstack/identity/v2/user_test.go index f54e218d30..e0f614e511 100644 --- a/internal/acceptance/openstack/identity/v2/user_test.go +++ b/internal/acceptance/openstack/identity/v2/user_test.go @@ -13,7 +13,7 @@ import ( ) func TestUsersList(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2AdminClient() @@ -38,7 +38,7 @@ func TestUsersList(t *testing.T) { } func TestUsersCreateUpdateDelete(t *testing.T) { - clients.RequireIdentityV2(t) + RequireIdentityV2(t) clients.RequireAdmin(t) client, err := clients.NewIdentityV2AdminClient() diff --git a/internal/acceptance/openstack/networking/v2/conditions.go b/internal/acceptance/openstack/networking/v2/conditions.go index 036cba6044..6ce6b145f3 100644 --- a/internal/acceptance/openstack/networking/v2/conditions.go +++ b/internal/acceptance/openstack/networking/v2/conditions.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "os" "testing" "github.com/gophercloud/gophercloud/v2" @@ -16,3 +17,11 @@ func RequireNeutronExtension(t *testing.T, client *gophercloud.ServiceClient, ex t.Skipf("this test requires %s Neutron extension", extension) } } + +// RequirePortForwarding will restrict a test to only be run in environments +// that support port forwarding +func RequirePortForwarding(t *testing.T) { + if os.Getenv("OS_PORTFORWARDING_ENVIRONMENT") == "" { + t.Skip("this test requires support for port forwarding") + } +} diff --git a/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go b/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go index 3d3f208529..d6f3e9595e 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/layer3/portforwardings_test.go @@ -15,7 +15,7 @@ import ( ) func TestLayer3PortForwardingsCreateDelete(t *testing.T) { - clients.RequirePortForwarding(t) + networking.RequirePortForwarding(t) client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/sharedfilesystems/v2/conditions.go b/internal/acceptance/openstack/sharedfilesystems/v2/conditions.go new file mode 100644 index 0000000000..de48b6939a --- /dev/null +++ b/internal/acceptance/openstack/sharedfilesystems/v2/conditions.go @@ -0,0 +1,14 @@ +package v2 + +import ( + "os" + "testing" +) + +// RequireManilaReplicas will restrict a test to only be run with enabled +// manila replicas. +func RequireManilaReplicas(t *testing.T) { + if os.Getenv("OS_MANILA_REPLICAS") != "true" { + t.Skip("manila replicas must be enabled to run this test") + } +} diff --git a/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go b/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go index 41913ac266..8432afeb77 100644 --- a/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/replicas_test.go @@ -18,7 +18,7 @@ import ( const replicasPathMicroversion = "2.56" func TestReplicaCreate(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -55,7 +55,7 @@ func TestReplicaCreate(t *testing.T) { } func TestReplicaPromote(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -131,7 +131,7 @@ func TestReplicaPromote(t *testing.T) { } func TestReplicaExportLocations(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -198,7 +198,7 @@ func TestReplicaExportLocations(t *testing.T) { } func TestReplicaListDetail(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -231,7 +231,7 @@ func TestReplicaListDetail(t *testing.T) { } func TestReplicaResetStatus(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) client, err := clients.NewSharedFileSystemV2Client() if err != nil { @@ -272,7 +272,7 @@ func TestReplicaResetStatus(t *testing.T) { // This test available only for cloud admins func TestReplicaForceDelete(t *testing.T) { - clients.RequireManilaReplicas(t) + RequireManilaReplicas(t) clients.RequireAdmin(t) client, err := clients.NewSharedFileSystemV2Client() From ff696573cc81bc41f2480bb7a6847dbf34a2a083 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 13 May 2025 18:19:56 +0100 Subject: [PATCH 14/17] tests: Skip vpnaas tests if extension missing Signed-off-by: Stephen Finucane (cherry picked from commit 8314ff1af652bb22cea9a49cc219c3a591e1e8a7) --- .../v2/extensions/vpnaas/group_test.go | 7 +++++++ .../v2/extensions/vpnaas/ikepolicy_test.go | 7 +++++++ .../v2/extensions/vpnaas/ipsecpolicy_test.go | 7 +++++++ .../v2/extensions/vpnaas/service_test.go | 9 +++++++++ .../extensions/vpnaas/siteconnection_test.go | 18 +++++++++++++----- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go index 8fe5e0638c..862324736f 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/group_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/vpnaas/endpointgroups" th "github.com/gophercloud/gophercloud/v2/testhelper" @@ -16,6 +17,9 @@ func TestGroupList(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + allPages, err := endpointgroups.List(client, nil).AllPages(context.TODO()) th.AssertNoErr(t, err) @@ -31,6 +35,9 @@ func TestGroupCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + group, err := CreateEndpointGroup(t, client) th.AssertNoErr(t, err) defer DeleteEndpointGroup(t, client, group.ID) diff --git a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go index c0407c99a4..eeb573edf0 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ikepolicy_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/vpnaas/ikepolicies" th "github.com/gophercloud/gophercloud/v2/testhelper" @@ -16,6 +17,9 @@ func TestIKEPolicyList(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + allPages, err := ikepolicies.List(client, nil).AllPages(context.TODO()) th.AssertNoErr(t, err) @@ -31,6 +35,9 @@ func TestIKEPolicyCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + policy, err := CreateIKEPolicy(t, client) th.AssertNoErr(t, err) defer DeleteIKEPolicy(t, client, policy.ID) diff --git a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go index f9aed9b2aa..74dc5a3758 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/ipsecpolicy_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/vpnaas/ipsecpolicies" th "github.com/gophercloud/gophercloud/v2/testhelper" @@ -16,6 +17,9 @@ func TestIPSecPolicyList(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + allPages, err := ipsecpolicies.List(client, nil).AllPages(context.TODO()) th.AssertNoErr(t, err) @@ -31,6 +35,9 @@ func TestIPSecPolicyCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + policy, err := CreateIPSecPolicy(t, client) th.AssertNoErr(t, err) defer DeleteIPSecPolicy(t, client, policy.ID) diff --git a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go index 2ac1c7734c..b932dbdeb3 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/service_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" layer3 "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2/extensions/layer3" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/vpnaas/services" @@ -17,6 +18,9 @@ func TestServiceList(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + allPages, err := services.List(client, nil).AllPages(context.TODO()) th.AssertNoErr(t, err) @@ -29,10 +33,15 @@ func TestServiceList(t *testing.T) { } func TestServiceCRUD(t *testing.T) { + // TODO(stephenfin): Why are we skipping this? Can we unskip? If not, we should remove. clients.SkipReleasesAbove(t, "stable/wallaby") + client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + router, err := layer3.CreateExternalRouter(t, client) th.AssertNoErr(t, err) defer layer3.DeleteRouter(t, client, router.ID) diff --git a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go index 8aa8e49f57..68a7f45192 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/vpnaas/siteconnection_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" - networks "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" layer3 "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2/extensions/layer3" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/routers" @@ -19,6 +19,9 @@ func TestConnectionList(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + allPages, err := siteconnections.List(client, nil).AllPages(context.TODO()) th.AssertNoErr(t, err) @@ -31,19 +34,24 @@ func TestConnectionList(t *testing.T) { } func TestConnectionCRUD(t *testing.T) { + // TODO(stephenfin): Why are we skipping this? Can we unskip? If not, we should remove. clients.SkipReleasesAbove(t, "stable/wallaby") + client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "vpnaas") + // Create Network - network, err := networks.CreateNetwork(t, client) + network, err := networking.CreateNetwork(t, client) th.AssertNoErr(t, err) - defer networks.DeleteNetwork(t, client, network.ID) + defer networking.DeleteNetwork(t, client, network.ID) // Create Subnet - subnet, err := networks.CreateSubnet(t, client, network.ID) + subnet, err := networking.CreateSubnet(t, client, network.ID) th.AssertNoErr(t, err) - defer networks.DeleteSubnet(t, client, subnet.ID) + defer networking.DeleteSubnet(t, client, subnet.ID) router, err := layer3.CreateExternalRouter(t, client) th.AssertNoErr(t, err) From 9728281ea9dbeb26b830026e0c9e7c84c3fc1666 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 14 May 2025 10:22:03 +0100 Subject: [PATCH 15/17] tests: Configure policy in fwaas functional workflow We already do this for the networking workflow. Now do it for the fwaas-specific workflow. Signed-off-by: Stephen Finucane (cherry picked from commit df9032a3eded801cd0865109c595c513630b207f) --- .github/workflows/functional-fwaas_v2.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/functional-fwaas_v2.yaml b/.github/workflows/functional-fwaas_v2.yaml index f715da56a9..cb84f9f465 100644 --- a/.github/workflows/functional-fwaas_v2.yaml +++ b/.github/workflows/functional-fwaas_v2.yaml @@ -1,3 +1,7 @@ +# TODO(stephenfin): neutron-fwaas may support OVN now. If so, we can combine +# this job with the functional-networking job. See [1] +# +# [1] https://bugs.launchpad.net/neutron/+bug/1971958 name: functional-fwaas_v2 on: pull_request: @@ -29,6 +33,14 @@ jobs: steps: - name: Checkout Gophercloud uses: actions/checkout@v4 + - name: Create additional neutron policies + run: | + mkdir /tmp/neutron-policies + cat << EOF >> /tmp/neutron-policies/port_binding.yaml + --- + "create_port:binding:profile": "rule:admin_only or rule:service_api" + "update_port:binding:profile": "rule:admin_only or rule:service_api" + EOF - name: Deploy devstack uses: gophercloud/devstack-action@v0.17 with: @@ -40,6 +52,10 @@ jobs: Q_ML2_PLUGIN_TYPE_DRIVERS=flat,gre,vlan,vxlan Q_ML2_TENANT_NETWORK_TYPE=vxlan Q_TUNNEL_TYPES=vxlan,gre + + [[post-config|\$NEUTRON_CONF]] + [oslo_policy] + policy_dirs = /tmp/neutron-policies enabled_services: 'q-svc,q-agt,q-dhcp,q-l3,q-meta,q-fwaas-v2,-cinder,-horizon,-tempest,-swift,-c-sch,-c-api,-c-vol,-c-bak,-ovn,-ovn-controller,-ovn-northd,-q-ovn-metadata-agent,${{ matrix.additional_services }}' - name: Checkout go uses: actions/setup-go@v5 From f1e827bd523e1948c4a209abd595e4571303500b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 14 May 2025 10:30:55 +0100 Subject: [PATCH 16/17] tests: Skip bgp tests if extension missing Signed-off-by: Stephen Finucane (cherry picked from commit 148e43ab9df8bf76a8410e7bb4a4b5463249d858) --- .../networking/v2/extensions/agents/agents_test.go | 9 ++++++--- .../networking/v2/extensions/bgp/peers/bgppeers_test.go | 4 ++++ .../v2/extensions/bgp/speakers/bgpspeakers_test.go | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go index 37b5e39c3b..068ea001c5 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go @@ -16,8 +16,8 @@ import ( th "github.com/gophercloud/gophercloud/v2/testhelper" ) -func TestAgentsRUD(t *testing.T) { - t.Skip("TestAgentsRUD needs to be re-worked to work with both ML2/OVS and OVN") +func TestAgentsCRUD(t *testing.T) { + t.Skip("TestAgentsCRUD needs to be re-worked to work with both ML2/OVS and OVN") clients.RequireAdmin(t) client, err := clients.NewNetworkV2Client() @@ -96,13 +96,16 @@ func TestAgentsRUD(t *testing.T) { th.AssertNoErr(t, err) } -func TestBGPAgentRUD(t *testing.T) { +func TestBGPAgentCRUD(t *testing.T) { timeout := 15 * time.Minute clients.RequireAdmin(t) client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgp") + // List BGP Agents listOpts := &agents.ListOpts{ AgentType: "BGP Dynamic Routing Agent", diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go index 8fdee3c034..baad9a8a5e 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/peers/bgppeers_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/gophercloud/gophercloud/v2/internal/acceptance/clients" + networking "github.com/gophercloud/gophercloud/v2/internal/acceptance/openstack/networking/v2" "github.com/gophercloud/gophercloud/v2/internal/acceptance/tools" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/bgp/peers" th "github.com/gophercloud/gophercloud/v2/testhelper" @@ -18,6 +19,9 @@ func TestBGPPeerCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgp") + // Create a BGP Peer bgpPeerCreated, err := CreateBGPPeer(t, client) th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go index 5b50d6df59..2ab5584d5b 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgp/speakers/bgpspeakers_test.go @@ -17,9 +17,13 @@ import ( func TestBGPSpeakerCRUD(t *testing.T) { clients.RequireAdmin(t) + client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgp") + // Create a BGP Speaker bgpSpeaker, err := CreateBGPSpeaker(t, client) th.AssertNoErr(t, err) From 5fa68ead7ab71d5381e68765bd9b4fd496b79162 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 14 May 2025 10:31:06 +0100 Subject: [PATCH 17/17] tests: Skip bgpvpn tests if extension missing We also fix some typos in test names. Signed-off-by: Stephen Finucane (cherry picked from commit 13997f39b2effa7ab02922e6f94a54172aa68eac) --- .../v2/extensions/bgpvpns/bgpvpns_test.go | 14 +++++++++++++- .../networking/v2/extensions/dns/dns_test.go | 4 ++-- .../networking/v2/extensions/mtu/mtu_test.go | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go index 01542d6ec3..3c915901e8 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns_test.go @@ -20,6 +20,9 @@ func TestBGPVPNCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgpvpn") + // Create a BGP VPN bgpVpnCreated, err := CreateBGPVPN(t, client) th.AssertNoErr(t, err) @@ -60,12 +63,15 @@ func TestBGPVPNCRUD(t *testing.T) { t.Logf("BGP VPN %s deleted", bgpVpnUpdated.Name) } -func TestBGPVPNNetworkAssociationCRD(t *testing.T) { +func TestBGPVPNNetworkAssociationCRUD(t *testing.T) { clients.RequireAdmin(t) client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgpvpn") + // Create a BGP VPN bgpVpnCreated, err := CreateBGPVPN(t, client) th.AssertNoErr(t, err) @@ -117,6 +123,9 @@ func TestBGPVPNRouterAssociationCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgpvpn") + // Create a BGP VPN bgpVpnCreated, err := CreateBGPVPN(t, client) th.AssertNoErr(t, err) @@ -182,6 +191,9 @@ func TestBGPVPNPortAssociationCRUD(t *testing.T) { client, err := clients.NewNetworkV2Client() th.AssertNoErr(t, err) + // Skip these tests if we don't have the required extension + networking.RequireNeutronExtension(t, client, "bgpvpn") + // Create a BGP VPN bgpVpnCreated, err := CreateBGPVPN(t, client) th.AssertNoErr(t, err) diff --git a/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go b/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go index d709a4252d..fd239f8a40 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/dns/dns_test.go @@ -141,8 +141,8 @@ func TestDNSPortCRUDL(t *testing.T) { th.AssertDeepEquals(t, newPort, getNewPort) } -func TestDNSFloatingIPCRDL(t *testing.T) { - t.Skip("Skipping TestDNSFloatingIPCRDL for now, as it doesn't work with ML2/OVN.") +func TestDNSFloatingIPCRUD(t *testing.T) { + t.Skip("Skipping TestDNSFloatingIPCRUD for now, as it doesn't work with ML2/OVN.") clients.RequireAdmin(t) client, err := clients.NewNetworkV2Client() diff --git a/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go index a71c96cc43..63e4f7790b 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/mtu/mtu_test.go @@ -16,7 +16,7 @@ import ( th "github.com/gophercloud/gophercloud/v2/testhelper" ) -func TestMTUNetworkCRUDL(t *testing.T) { +func TestMTUNetworkCRUD(t *testing.T) { clients.RequireAdmin(t) client, err := clients.NewNetworkV2Client()