From e3fc476a355b34525dc44268024b49a19bf83bd7 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 8 Apr 2025 21:54:16 +0000 Subject: [PATCH] Move Windows test out of Install Script workflow Placing this in the install script test, which only runs when specific files are changed, was preventing it from being run on code changes. In addition to moving this into the integration workflow, fix codecov for Windows and upload data after running a test pod. Signed-off-by: Brad Davidson (cherry picked from commit cd4be0b8c1409fc0d41df9097ddb8324903386a5) Signed-off-by: Brad Davidson --- .github/workflows/install.yaml | 26 ---------- .github/workflows/integration.yaml | 47 +++++++++++++++++++ .../integration/startup/testdata/agnhost.yaml | 16 +++++++ 3 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 tests/integration/startup/testdata/agnhost.yaml diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml index 10b9f7313b..54badda3f1 100644 --- a/.github/workflows/install.yaml +++ b/.github/workflows/install.yaml @@ -105,29 +105,3 @@ jobs: with: ## If no one connects after 5 minutes, shut down server. wait-timeout-minutes: 5 - test-windows: - name: "Smoke Test (windows)" - needs: build - runs-on: windows-2022 - timeout-minutes: 10 - steps: - - name: "Checkout" - uses: actions/checkout@v4 - with: {fetch-depth: 1} - - name: "Download k3s binary" - uses: actions/download-artifact@v4 - with: - name: k3s-windows - path: dist/artifacts/ - - name: "Run K3s" - timeout-minutes: 5 - run: | - $ErrorActionPreference = "Continue" - $PSNativeCommandUseErrorActionPreference = $true - $Server = Start-Job -ScriptBlock { ./dist/artifacts/k3s.exe server --token=token --embedded-registry --disable=metrics-server } - Start-Sleep -Seconds 15 - D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl get node -o wide - D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl get pod -A -o wide - Stop-Job -Job $Server - Receive-Job -Wait -Job $Server - Remove-Job -Job $Server diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index d3b40fe0ce..51b6baf199 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -78,3 +78,50 @@ jobs: files: ./${{ matrix.itest }}.out flags: inttests # optional verbose: true # optional (default = false) + itest-windows: + name: Integration Tests (windows) + needs: build-windows + runs-on: windows-2022 + timeout-minutes: 10 + env: + GOCOVERDIR: "D:/tmp/k3scov" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: {fetch-depth: 1} + - name: Install Go + uses: ./.github/actions/setup-go + - name: Download k3s binary + uses: actions/download-artifact@v4 + with: + name: k3s-windows + path: dist/artifacts/ + - name: Run K3s + timeout-minutes: 5 + env: + CONTAINERD_LOG_LEVEL: "debug" + run: | + $ErrorActionPreference = "Continue" + $PSNativeCommandUseErrorActionPreference = $true + New-Item -Type Directory -Force $Env:GOCOVERDIR | Out-Null + $Server = Start-Job -ScriptBlock { ./dist/artifacts/k3s.exe server --token=token --debug --disable=metrics-server } + Start-Sleep -Seconds 15 + D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl apply -f ./tests/integration/startup/testdata/agnhost.yaml + D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl wait --for=jsonpath='{.status.phase}'=Running --timeout=5m pod/agnhost + D:/var/lib/rancher/k3s/data/current/bin/k3s.exe crictl ps + D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl get pod -A -o wide + D:/var/lib/rancher/k3s/data/current/bin/k3s.exe kubectl get node -o wide + $RET = $LASTEXITCODE + Stop-Job -Job $Server + Receive-Job -Wait -Job $Server + Remove-Job -Job $Server + exit $RET + - name: Generate coverage report + run: go tool covdata textfmt -i $Env:GOCOVERDIR -o windows.out + - name: Upload Results To Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./windows.out + flags: inttests # optional + verbose: true # optional (default = false) diff --git a/tests/integration/startup/testdata/agnhost.yaml b/tests/integration/startup/testdata/agnhost.yaml new file mode 100644 index 0000000000..99e1c55bfc --- /dev/null +++ b/tests/integration/startup/testdata/agnhost.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Pod +metadata: + name: agnhost +spec: + containers: + - name: agnhost + image: registry.k8s.io/e2e-test-images/agnhost:2.53 + args: + - inclusterclient + - -v=9 + - --poll-interval=5 + dnsConfig: + nameservers: + - 8.8.8.8 + dnsPolicy: None