diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 806c5a64ad..cd92b0dc74 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -94,6 +94,7 @@ jobs: tags: | type=semver,pattern={{version}} type=edge + type=schedule type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8795cf2bab..ba03619638 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: CI on: push: @@ -8,6 +8,8 @@ on: tags: - "v[0-9]+.[0-9]+.[0-9]+*" pull_request: + schedule: + - cron: "0 4 * * *" # run every day at 4am UTC defaults: run: @@ -26,6 +28,7 @@ jobs: runs-on: ubuntu-22.04 outputs: go_path: ${{ steps.vars.outputs.go_path }} + min_k8s_version: ${{ steps.vars.outputs.min_k8s_version }} steps: - name: Checkout Repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 @@ -37,7 +40,9 @@ jobs: - name: Output Variables id: vars - run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT + run: | + echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT + echo "min_k8s_version=1.23.17" >> $GITHUB_OUTPUT - name: Check if go.mod and go.sum are up to date run: go mod tidy && git diff --exit-code -- go.mod go.sum @@ -160,10 +165,61 @@ jobs: path: ${{ github.workspace }}/dist key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }} + build: + name: Build Image + needs: [vars, binary] + strategy: + fail-fast: false + matrix: + image: [ngf, nginx, plus] + platforms: ["linux/arm64, linux/amd64"] + uses: ./.github/workflows/build.yml + with: + image: ${{ matrix.image }} + platforms: ${{ matrix.platforms }} + permissions: + contents: read # for docker/build-push-action to read repo content + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + packages: write # for docker/build-push-action to push to GHCR + id-token: write # for docker/login to login to NGINX registry + secrets: inherit + + functional-tests: + name: Functional tests + needs: [vars, build] + strategy: + fail-fast: false + matrix: + image: [nginx, plus] + k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "latest"] + uses: ./.github/workflows/functional.yml + with: + image: ${{ matrix.image }} + k8s-version: ${{ matrix.k8s-version }} + permissions: + contents: read + + conformance-tests: + name: Conformance tests + needs: [vars, build] + strategy: + fail-fast: false + matrix: + image: [nginx, plus] + k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "latest"] + enable-experimental: [true, false] + uses: ./.github/workflows/conformance.yml + with: + image: ${{ matrix.image }} + k8s-version: ${{ matrix.k8s-version }} + enable-experimental: ${{ matrix.enable-experimental }} + permissions: + contents: write + helm-tests: name: Helm Tests runs-on: ubuntu-22.04 - needs: [vars, binary] + needs: [vars, build] steps: - name: Checkout Repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 @@ -210,7 +266,6 @@ jobs: target: goreleaser load: true cache-from: type=gha,scope=ngf - cache-to: type=gha,scope=ngf,mode=max pull: true - name: Build NGINX Docker Image @@ -221,7 +276,6 @@ jobs: context: "." load: true cache-from: type=gha,scope=nginx - cache-to: type=gha,scope=nginx,mode=max pull: true build-args: | NJS_DIR=internal/mode/static/nginx/modules/src @@ -254,25 +308,6 @@ jobs: -n nginx-gateway working-directory: ${{ github.workspace }}/deploy/helm-chart - build: - name: Build Image - needs: [vars, binary] - strategy: - fail-fast: false - matrix: - image: [ngf, nginx, plus] - platforms: ["linux/arm64, linux/amd64"] - uses: ./.github/workflows/build.yml - with: - image: ${{ matrix.image }} - platforms: ${{ matrix.platforms }} - permissions: - contents: read # for docker/build-push-action to read repo content - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - packages: write # for docker/build-push-action to push to GHCR - id-token: write # for docker/login to login to NGINX registry - secrets: inherit - publish-helm: name: Package and Publish Helm Chart runs-on: ubuntu-22.04 diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index b4de38ad56..e1bc64fb9b 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -1,49 +1,40 @@ name: Conformance Testing on: - push: - branches: - - main - - release-* - tags: - - "v[0-9]+.[0-9]+.[0-9]+*" - pull_request: - schedule: - - cron: "0 4 * * *" # run every day at 4am UTC + workflow_call: + inputs: + image: + required: true + type: string + k8s-version: + required: true + type: string + enable-experimental: + required: true + type: boolean defaults: run: shell: bash -concurrency: - group: ${{ github.ref_name }}-conformance - cancel-in-progress: true - permissions: contents: read jobs: conformance-tests: - name: Gateway Conformance Tests + name: Run Tests runs-on: ubuntu-22.04 - strategy: - matrix: - k8s-version: ["1.23.17", "latest"] - nginx-image: [nginx, nginx-plus] - enable-experimental: [true, false] permissions: contents: write # needed for uploading release artifacts steps: - name: Checkout Repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - name: Setup Golang Environment - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + - name: Fetch Cached Artifacts + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 with: - go-version: stable - - - name: Set GOPATH - run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + path: ${{ github.workspace }}/dist + key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }} - name: Docker Buildx uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0 @@ -57,6 +48,7 @@ jobs: tags: | type=semver,pattern={{version}} type=edge + type=schedule type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} @@ -65,10 +57,11 @@ jobs: uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 with: images: | - name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ matrix.nginx-image }} + name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ inputs.image == 'plus' && 'nginx-plus' || inputs.image }} tags: | type=semver,pattern={{version}} type=edge + type=schedule type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} @@ -76,18 +69,9 @@ jobs: run: | ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} - make update-ngf-manifest${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + make update-ngf-manifest${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./conformance - - name: Build binary - uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 - with: - version: latest - args: build --snapshot --clean - env: - TELEMETRY_ENDPOINT: "" # disables sending telemetry - TELEMETRY_ENDPOINT_INSECURE: "false" - - name: Build NGF Docker Image uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: @@ -97,18 +81,16 @@ jobs: target: goreleaser load: true cache-from: type=gha,scope=ngf - cache-to: type=gha,scope=ngf,mode=max pull: true - name: Build NGINX Docker Image uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: - file: build/Dockerfile${{ matrix.nginx-image == 'nginx' && '.nginx' || '' }}${{ matrix.nginx-image == 'nginx-plus' && '.nginxplus' || ''}} + file: build/Dockerfile${{ inputs.image == 'nginx' && '.nginx' || '' }}${{ inputs.image == 'plus' && '.nginxplus' || ''}} tags: ${{ steps.nginx-meta.outputs.tags }} context: "." load: true - cache-from: type=gha,scope=${{ matrix.nginx-image }} - cache-to: type=gha,scope=${{ matrix.nginx-image }},mode=max + cache-from: type=gha,scope=${{ inputs.image }} pull: true build-args: | NJS_DIR=internal/mode/static/nginx/modules/src @@ -134,26 +116,19 @@ jobs: - name: Deploy Kubernetes id: k8s run: | - k8s_version=${{ matrix.k8s-version }} - make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(matrix.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }} + k8s_version=${{ inputs.k8s-version }} + make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(inputs.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }} echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" working-directory: ./conformance - - name: Wait for release to exist - if: startsWith(github.ref, 'refs/tags/') - run: | - REF=${{ github.ref_name }} - until docker pull ghcr.io/nginxinc/nginx-gateway-fabric:${REF#v}; do sleep 5; done - until docker pull ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${REF#v}; do sleep 5; done - - name: Setup conformance tests run: | ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi - if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi - if [ ${{ matrix.enable-experimental }} == "true" ]; then export ENABLE_EXPERIMENTAL=true; fi - make install-ngf-local-no-build${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + if [ ${{ startsWith(inputs.k8s-version, '1.23') || startsWith(inputs.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi + if [ ${{ inputs.enable-experimental }} == "true" ]; then export ENABLE_EXPERIMENTAL=true; fi + make install-ngf-local-no-build${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./conformance - name: Run conformance tests @@ -165,7 +140,7 @@ jobs: working-directory: ./conformance - name: Upload profile to release - if: ${{ matrix.k8s-version == 'latest' && startsWith(github.ref, 'refs/tags/') }} + if: ${{ inputs.k8s-version == 'latest' && startsWith(github.ref, 'refs/tags/') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload ${{ github.ref_name }} conformance-profile.yaml diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 214e432172..760861133c 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -1,33 +1,26 @@ name: Functional Testing on: - push: - branches: - - main - - release-* - tags: - - "v[0-9]+.[0-9]+.[0-9]+*" - pull_request: + workflow_call: + inputs: + image: + required: true + type: string + k8s-version: + required: true + type: string defaults: run: shell: bash -concurrency: - group: ${{ github.ref_name }}-functional - cancel-in-progress: true - permissions: contents: read jobs: functional-tests: - name: Gateway Functional Tests + name: Run Tests runs-on: ubuntu-22.04 - strategy: - matrix: - k8s-version: ["1.23.17", "latest"] - nginx-image: [nginx, nginx-plus] steps: - name: Checkout Repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 @@ -43,7 +36,6 @@ jobs: - name: Docker Buildx uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0 - - name: NGF Docker meta id: ngf-meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 @@ -52,6 +44,7 @@ jobs: name=ghcr.io/nginxinc/nginx-gateway-fabric tags: | type=semver,pattern={{version}} + type=schedule type=edge type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} @@ -61,10 +54,11 @@ jobs: uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 with: images: | - name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ matrix.nginx-image }} + name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ inputs.image == 'plus' && 'nginx-plus' || inputs.image }} tags: | type=semver,pattern={{version}} type=edge + type=schedule type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} @@ -85,19 +79,17 @@ jobs: context: "." load: true cache-from: type=gha,scope=ngf - cache-to: type=gha,scope=ngf,mode=max pull: true target: goreleaser - name: Build NGINX Docker Image uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: - file: build/Dockerfile${{ matrix.nginx-image == 'nginx' && '.nginx' || '' }}${{ matrix.nginx-image == 'nginx-plus' && '.nginxplus' || ''}} + file: build/Dockerfile${{ inputs.image == 'nginx' && '.nginx' || '' }}${{ inputs.image == 'plus' && '.nginxplus' || ''}} tags: ${{ steps.nginx-meta.outputs.tags }} context: "." load: true - cache-from: type=gha,scope=${{ matrix.nginx-image }} - cache-to: type=gha,scope=${{ matrix.nginx-image }},mode=max + cache-from: type=gha,scope=${{ inputs.image }} pull: true build-args: | NJS_DIR=internal/mode/static/nginx/modules/src @@ -107,8 +99,8 @@ jobs: - name: Deploy Kubernetes id: k8s run: | - k8s_version=${{ matrix.k8s-version }} - make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(matrix.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }} + k8s_version=${{ inputs.k8s-version }} + make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(inputs.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }} echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" - name: Setup functional tests @@ -116,12 +108,12 @@ jobs: run: | ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} - make load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + make load-images${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./tests - name: Run functional telemetry tests run: | ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} - make test${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} GINKGO_LABEL=telemetry + make test${{ inputs.image == 'plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} GINKGO_LABEL=telemetry working-directory: ./tests diff --git a/.golangci.yml b/.golangci.yml index 1afc5317b1..88dfe6d3ba 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,6 @@ linters-settings: + ginkgolinter: + forbid-focus-container: true goimports: local-prefixes: github.com/nginxinc/nginx-gateway-fabric misspell: @@ -41,6 +43,7 @@ linters: - asciicheck - errcheck - errorlint + - ginkgolinter - gocyclo - gofmt - gofumpt diff --git a/internal/framework/controller/register_test.go b/internal/framework/controller/register_test.go index 03f5b7738a..ecb4337308 100644 --- a/internal/framework/controller/register_test.go +++ b/internal/framework/controller/register_test.go @@ -150,7 +150,7 @@ func TestRegister(t *testing.T) { } else { err := register() if test.expectedErr == nil { - g.Expect(err).To(BeNil()) + g.Expect(err).ToNot(HaveOccurred()) } else { g.Expect(err).To(MatchError(test.expectedErr)) } diff --git a/internal/framework/events/events_test.go b/internal/framework/events/events_test.go index 17f1383aa4..7d2415c2d6 100644 --- a/internal/framework/events/events_test.go +++ b/internal/framework/events/events_test.go @@ -28,8 +28,8 @@ func TestEventLoop_SwapBatches(t *testing.T) { eventLoop.swapBatches() - g.Expect(len(eventLoop.currentBatch)).To(Equal(len(nextBatch))) + g.Expect(eventLoop.currentBatch).To(HaveLen(len(nextBatch))) g.Expect(eventLoop.currentBatch).To(Equal(nextBatch)) - g.Expect(len(eventLoop.nextBatch)).To(Equal(0)) + g.Expect(eventLoop.nextBatch).To(BeEmpty()) g.Expect(cap(eventLoop.nextBatch)).To(Equal(3)) } diff --git a/internal/framework/events/first_eventbatch_preparer_test.go b/internal/framework/events/first_eventbatch_preparer_test.go index 8fd79b1b78..483434b936 100644 --- a/internal/framework/events/first_eventbatch_preparer_test.go +++ b/internal/framework/events/first_eventbatch_preparer_test.go @@ -58,7 +58,7 @@ var _ = Describe("FirstEventBatchPreparer", func() { batch, err := preparer.Prepare(context.Background()) Expect(batch).Should(BeEmpty()) - Expect(err).Should(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should prepare one event for each resource type", func() { @@ -97,7 +97,7 @@ var _ = Describe("FirstEventBatchPreparer", func() { batch, err := preparer.Prepare(context.Background()) Expect(batch).Should(Equal(expectedBatch)) - Expect(err).Should(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) }) diff --git a/internal/framework/events/loop_test.go b/internal/framework/events/loop_test.go index 589b1a32dd..807e1b0d4b 100644 --- a/internal/framework/events/loop_test.go +++ b/internal/framework/events/loop_test.go @@ -59,7 +59,7 @@ var _ = Describe("EventLoop", func() { var err error Eventually(errorCh).Should(Receive(&err)) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) // Because BeforeEach() creates the first batch and waits for it to be handled, in the tests below @@ -138,7 +138,7 @@ var _ = Describe("EventLoop", func() { cancel() err := eventLoop.Start(ctx) - Expect(err).Should(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) }) }) diff --git a/internal/framework/runnables/runnables_test.go b/internal/framework/runnables/runnables_test.go index f756146cd7..28af829306 100644 --- a/internal/framework/runnables/runnables_test.go +++ b/internal/framework/runnables/runnables_test.go @@ -32,7 +32,7 @@ func TestEnableAfterBecameLeader(t *testing.T) { g.Expect(enabled).To(BeFalse()) err := enableAfterBecameLeader.Start(context.Background()) - g.Expect(err).To(BeNil()) + g.Expect(err).ToNot(HaveOccurred()) g.Expect(enabled).To(BeTrue()) } diff --git a/internal/mode/provisioner/handler_test.go b/internal/mode/provisioner/handler_test.go index 0faa894a9a..d31e36a872 100644 --- a/internal/mode/provisioner/handler_test.go +++ b/internal/mode/provisioner/handler_test.go @@ -342,7 +342,7 @@ var _ = Describe("handler", func() { err := k8sclient.List(context.Background(), deps) Expect(err).ToNot(HaveOccurred()) - Expect(deps.Items).To(HaveLen(0)) + Expect(deps.Items).To(BeEmpty()) }) }) @@ -370,7 +370,7 @@ var _ = Describe("handler", func() { err := k8sclient.List(context.Background(), deps) Expect(err).ToNot(HaveOccurred()) - Expect(deps.Items).To(HaveLen(0)) + Expect(deps.Items).To(BeEmpty()) }) }) diff --git a/internal/mode/static/handler_test.go b/internal/mode/static/handler_test.go index 9b8a60fc52..b99ec28663 100644 --- a/internal/mode/static/handler_test.go +++ b/internal/mode/static/handler_test.go @@ -229,7 +229,7 @@ var _ = Describe("eventHandler", func() { "Failed to update control plane configuration: logging.level: Unsupported value: " + "\"invalid\": supported values: \"info\", \"debug\", \"error\"") Expect(statuses).To(Equal(expStatuses(cond))) - Expect(len(fakeEventRecorder.Events)).To(Equal(1)) + Expect(fakeEventRecorder.Events).To(HaveLen(1)) event := <-fakeEventRecorder.Events Expect(event).To(Equal( "Warning UpdateFailed Failed to update control plane configuration: logging.level: Unsupported value: " + @@ -252,7 +252,7 @@ var _ = Describe("eventHandler", func() { Expect(handler.GetLatestConfiguration()).To(BeNil()) - Expect(len(fakeEventRecorder.Events)).To(Equal(1)) + Expect(fakeEventRecorder.Events).To(HaveLen(1)) event := <-fakeEventRecorder.Events Expect(event).To(Equal("Warning ResourceDeleted NginxGateway configuration was deleted; using defaults")) Expect(zapLogLevelSetter.Enabled(zap.InfoLevel)).To(BeTrue()) diff --git a/internal/mode/static/sort/sort_test.go b/internal/mode/static/sort/sort_test.go index 6379309f60..e7cac06551 100644 --- a/internal/mode/static/sort/sort_test.go +++ b/internal/mode/static/sort/sort_test.go @@ -85,7 +85,7 @@ func TestLessObjectMeta(t *testing.T) { invertedResult := LessObjectMeta(test.meta2, test.meta1) g.Expect(result).To(Equal(test.expected)) - g.Expect(invertedResult).To(Equal(false)) + g.Expect(invertedResult).To(BeFalse()) }) } } diff --git a/internal/mode/static/state/graph/backend_tls_policy_test.go b/internal/mode/static/state/graph/backend_tls_policy_test.go index 0cedce2222..386e760494 100644 --- a/internal/mode/static/state/graph/backend_tls_policy_test.go +++ b/internal/mode/static/state/graph/backend_tls_policy_test.go @@ -405,7 +405,7 @@ func TestValidateBackendTLSPolicy(t *testing.T) { if !test.isValid && !test.ignored { g.Expect(conds).To(HaveLen(1)) } else { - g.Expect(conds).To(HaveLen(0)) + g.Expect(conds).To(BeEmpty()) } }) } diff --git a/internal/mode/static/state/graph/httproute_test.go b/internal/mode/static/state/graph/httproute_test.go index 7f4b99d376..d7580a37e2 100644 --- a/internal/mode/static/state/graph/httproute_test.go +++ b/internal/mode/static/state/graph/httproute_test.go @@ -250,7 +250,7 @@ func TestBuildSectionNameRefs(t *testing.T) { if test.expectedError != nil { g.Expect(err).To(Equal(test.expectedError)) } else { - g.Expect(err).To(BeNil()) + g.Expect(err).ToNot(HaveOccurred()) } }) } diff --git a/internal/mode/static/state/graph/secret_test.go b/internal/mode/static/state/graph/secret_test.go index 81aa595033..54ebc3ca8a 100644 --- a/internal/mode/static/state/graph/secret_test.go +++ b/internal/mode/static/state/graph/secret_test.go @@ -191,7 +191,7 @@ func TestSecretResolver(t *testing.T) { for _, test := range tests { err := resolver.resolve(test.nsname) if test.expectedErrMsg == "" { - g.Expect(err).To(BeNil(), fmt.Sprintf("case %q", test.name)) + g.Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("case %q", test.name)) } else { g.Expect(err).To(MatchError(test.expectedErrMsg), fmt.Sprintf("case %q", test.name)) } diff --git a/internal/mode/static/telemetry/collector_test.go b/internal/mode/static/telemetry/collector_test.go index cd5ae9cdaf..22bb40c39b 100644 --- a/internal/mode/static/telemetry/collector_test.go +++ b/internal/mode/static/telemetry/collector_test.go @@ -347,7 +347,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) }) @@ -414,7 +414,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) }) @@ -430,7 +430,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) @@ -539,7 +539,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) @@ -558,7 +558,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) @@ -576,7 +576,7 @@ var _ = Describe("Collector", Ordered, func() { data, err := dataCollector.Collect(ctx) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(expData).To(Equal(data)) }) diff --git a/internal/mode/static/telemetry/exporter_test.go b/internal/mode/static/telemetry/exporter_test.go index 1a51c6f318..6a86a01685 100644 --- a/internal/mode/static/telemetry/exporter_test.go +++ b/internal/mode/static/telemetry/exporter_test.go @@ -18,7 +18,7 @@ func TestLoggingExporter(t *testing.T) { err := exporter.Export(context.Background(), &Data{}) - g.Expect(err).To(BeNil()) + g.Expect(err).ToNot(HaveOccurred()) g.Expect(buffer.String()).To(ContainSubstring(`"level":"info"`)) g.Expect(buffer.String()).To(ContainSubstring(`"msg":"Exporting telemetry"`)) } diff --git a/tests/suite/longevity_test.go b/tests/suite/longevity_test.go index 0f13826204..9ce38fe9a0 100644 --- a/tests/suite/longevity_test.go +++ b/tests/suite/longevity_test.go @@ -76,7 +76,7 @@ var _ = Describe("Longevity", Label("longevity-setup", "longevity-teardown"), fu homeDir, err := os.UserHomeDir() Expect(err).ToNot(HaveOccurred()) - Expect(framework.WriteContent(resultsFile, "\n## Traffic\n")) + Expect(framework.WriteContent(resultsFile, "\n## Traffic\n")).To(Succeed()) Expect(writeTrafficResults(resultsFile, homeDir, "coffee.txt", "HTTP")).To(Succeed()) Expect(writeTrafficResults(resultsFile, homeDir, "tea.txt", "HTTPS")).To(Succeed()) diff --git a/tests/suite/system_suite_test.go b/tests/suite/system_suite_test.go index e1451fb97c..a9b7fc85a9 100644 --- a/tests/suite/system_suite_test.go +++ b/tests/suite/system_suite_test.go @@ -170,7 +170,7 @@ func setup(cfg setupConfig, extraInstallArgs ...string) { timeoutConfig.CreateTimeout, ) Expect(err).ToNot(HaveOccurred()) - Expect(podNames).ToNot(HaveLen(0)) + Expect(podNames).ToNot(BeEmpty()) if *serviceType != "LoadBalancer" { portFwdPort, err = framework.PortForward(k8sConfig, installCfg.Namespace, podNames[0], portForwardStopCh) diff --git a/tests/suite/upgrade_test.go b/tests/suite/upgrade_test.go index 0e5983401f..a64b6689ac 100644 --- a/tests/suite/upgrade_test.go +++ b/tests/suite/upgrade_test.go @@ -185,7 +185,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() { podNames, err := framework.GetReadyNGFPodNames(k8sClient, ngfNamespace, releaseName, timeoutConfig.GetTimeout) Expect(err).ToNot(HaveOccurred()) - Expect(podNames).ToNot(HaveLen(0)) + Expect(podNames).ToNot(BeEmpty()) // ensure that the leader election lease has been updated to the new pods leaseCtx, leaseCancel := context.WithTimeout(context.Background(), 1*time.Minute)