-
Notifications
You must be signed in to change notification settings - Fork 10
sync CCM<>CSI test cluster setup, add integration tests on schedule #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .git | ||
| .gitignore | ||
| *.md | ||
| .github/ | ||
| /charts/ | ||
| deploy/ | ||
| examples/ | ||
| helpers/ | ||
| scripts/ | ||
| test/ | ||
| Dockerfile | ||
| VERSION |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| name: CSI Integration Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| pull_request: | ||
|
|
||
| # Allow to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
| # Run this regularly, to get integration tests results against new | ||
| # Kubernetes releases. | ||
| schedule: | ||
| - cron: '15 3 * * *' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test-matrix: | ||
| name: "Get Kubernetes Releases" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: "Generate Test Matrix" | ||
| id: list | ||
| run: 'echo "tests=$(helpers/test-matrix)" >> $GITHUB_OUTPUT' | ||
|
|
||
| outputs: | ||
| tests: ${{ steps.list.outputs.tests }} | ||
|
|
||
| build-image: | ||
| name: "Build Container Image" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Evaluate image name | ||
| run: 'helpers/image-from-ref >> $GITHUB_ENV' | ||
|
|
||
| - name: Extract version | ||
| run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV | ||
|
|
||
| - name: Build image | ||
| run: make build | ||
|
|
||
| - name: Export image | ||
| run: 'docker image save "$IMAGE" -o image.tar' | ||
|
|
||
| - name: Store hash | ||
| run: 'shasum -a 256 image.tar | tee image.tar.sha256' | ||
|
|
||
| - name: Store image | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: tested-image | ||
| path: | | ||
| image.tar | ||
| image.tar.sha256 | ||
| retention-days: 30d | ||
|
|
||
| check-csi-integration: | ||
| # Preflight: verify the CLOUDSCALE_API_TOKEN at step-level and set an output | ||
| # so the integration job can be skipped. | ||
| # | ||
| # GitHub Actions limitations motivating this: | ||
| # - `secrets` are NOT available in `jobs.<id>.if` (job-level `if`), so you cannot | ||
| # directly gate/skip a job by testing a secret there. | ||
| name: Check CSI Integration Configuration | ||
| runs-on: ubuntu-latest | ||
|
|
||
| outputs: | ||
| integration-enabled: ${{ steps.check.outputs.enabled }} | ||
|
|
||
| steps: | ||
| - id: check | ||
| name: Verify CLOUDSCALE_API_TOKEN is present | ||
| env: | ||
| CLOUDSCALE_API_TOKEN: ${{ secrets.CLOUDSCALE_API_TOKEN }} | ||
| run: | | ||
| if [ -n "$CLOUDSCALE_API_TOKEN" ]; then | ||
| echo "enabled=true" >> $GITHUB_OUTPUT | ||
| echo "CLOUDSCALE_API_TOKEN found — integration will run." | ||
| else | ||
| echo "enabled=false" >> $GITHUB_OUTPUT | ||
| echo "CLOUDSCALE_API_TOKEN not configured — skipping integration." | ||
| fi | ||
|
|
||
| integration: | ||
| name: "Kubernetes ${{ matrix.kubernetes }}" | ||
| runs-on: ubuntu-latest | ||
|
|
||
| needs: | ||
| - test-matrix | ||
| - build-image | ||
| - check-csi-integration | ||
| if: needs.check-csi-integration.outputs.integration-enabled == 'true' | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| max-parallel: 1 | ||
| matrix: | ||
| include: "${{ fromJson(needs.test-matrix.outputs.tests) }}" | ||
|
|
||
| env: | ||
| CLOUDSCALE_API_TOKEN: ${{ secrets.CLOUDSCALE_API_TOKEN }} | ||
| KUBERNETES: '${{ matrix.kubernetes }}' | ||
| SUBNET: '${{ matrix.subnet }}' | ||
| CLUSTER_PREFIX: '${{ matrix.cluster_prefix }}' | ||
| IMAGE_SOURCE: import | ||
|
|
||
| # Prevent integration tests from running in parallel. Ideally this should | ||
| # be seuqential, but that won't work due to the following issue: | ||
| # | ||
| # https://github.com/orgs/community/discussions/5435 | ||
| # | ||
| # Instead we ensure that only one integration test per supported version | ||
| # is run at any given time. | ||
| concurrency: | ||
| group: integration-${{ matrix.kubernetes }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Load image | ||
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | ||
| with: | ||
| name: tested-image | ||
|
|
||
| - name: Validate hash | ||
| run: 'shasum --check image.tar.sha256' | ||
|
|
||
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Setup Helm | ||
| uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 | ||
| with: | ||
| version: v4.2.4 | ||
|
|
||
| - name: Evaluate image name | ||
| run: 'helpers/image-from-ref >> $GITHUB_ENV' | ||
|
|
||
| - name: Cleanup Leftovers | ||
| if: always() | ||
| run: helpers/cleanup | ||
|
|
||
| - name: Create Test Cluster | ||
| run: helpers/run-in-test-cluster | ||
|
|
||
| - name: Run Integration Tests | ||
| run: TESTARGS="-race" make test-integration | ||
|
|
||
| - name: Wait For Kubernetes-Internal Cleanup | ||
| if: always() | ||
| run: sleep 30 | ||
|
|
||
| - name: Destroy Test Cluster | ||
| if: always() | ||
| run: helpers/cleanup |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,5 @@ charts/csi-cloudscale/charts | |
| cmd/cloudscale-csi-plugin/cloudscale-csi-plugin | ||
| k8test/ | ||
| bin/ | ||
|
|
||
| __pycache__/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,11 +418,31 @@ This will create a binary with version `dev` and docker image pushed to | |
| `cloudscalech/cloudscale-csi-plugin:dev` | ||
|
|
||
|
|
||
| To run the integration tests run the following: | ||
| To run the integration tests locally with your local CSI build: | ||
|
|
||
| ``` | ||
| $ export KUBECONFIG=$(pwd)/kubeconfig | ||
| ```bash | ||
| # 1. Build and export the CSI image | ||
| $ VERSION=dev make publish | ||
|
|
||
| # 2. Create a test cluster with CCM and CSI | ||
| $ export CLOUDSCALE_API_TOKEN=your-token | ||
| $ export IMAGE=quay.io/cloudscalech/cloudscale-csi-plugin:dev | ||
| $ helpers/run-in-test-cluster | ||
|
|
||
| # This will: | ||
| # - Create a Kubernetes cluster on cloudscale.ch | ||
| # - Deploy CCM from the latest official release | ||
| # - Deploy CSI from your local build | ||
|
|
||
| # 3. Run integration tests | ||
| $ export KUBECONFIG=$(pwd)/k8test/cluster/admin.conf | ||
| $ make test-integration | ||
|
|
||
| # Run a single test | ||
| $ TESTARGS='-run TestPod_Single_SSD_Volume' make test-integration | ||
|
|
||
| # 4. Clean up | ||
| $ helpers/cleanup | ||
|
Comment on lines
+421
to
+445
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace/merge/move to |
||
| ``` | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,41 @@ | ||
| # Copyright 2018 DigitalOcean | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
Comment on lines
-1
to
-13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other inherited file keeps the notice: Can you restore it please restore it? |
||
| FROM golang:1.27-alpine AS builder | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few things coming into play here:
Happy to discuss :) |
||
|
|
||
| RUN apk add --no-cache git make bash | ||
|
|
||
| WORKDIR /src | ||
|
|
||
| # Copy go.mod/go.sum first for better layer caching | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
|
|
||
| # Copy all source code | ||
| COPY . . | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While overall the new Dockerfile is definitely an improvement, I think we should explicitly COPY the files we require for the build rather than COPY Makefile ./
COPY driver/ driver/
COPY cmd/ cmd/Reasoning:
A file I'd genuinely. gitignore is |
||
|
|
||
| # Build arguments for version information | ||
| ARG VERSION=dev | ||
| ARG COMMIT=unknown | ||
| ARG GIT_TREE_STATE=unknown | ||
|
|
||
| # Build using make (ensures consistent build logic) | ||
| RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make compile \ | ||
| VERSION="${VERSION}" \ | ||
| COMMIT="${COMMIT}" \ | ||
| GIT_TREE_STATE="${GIT_TREE_STATE}" | ||
|
|
||
| FROM alpine:3.23.3 | ||
|
|
||
| # e2fsprogs-extra is required for resize2fs used for the resize operation | ||
| # blkid: block device identification tool from util-linux | ||
| RUN apk add --no-cache ca-certificates \ | ||
| e2fsprogs \ | ||
| findmnt \ | ||
| xfsprogs \ | ||
| cryptsetup \ | ||
| udev \ | ||
| blkid \ | ||
| e2fsprogs-extra | ||
|
|
||
| ADD cloudscale-csi-plugin /bin/ | ||
| ADD csi-diskinfo.sh /bin/ | ||
| e2fsprogs \ | ||
| findmnt \ | ||
| xfsprogs \ | ||
| cryptsetup \ | ||
| udev \ | ||
| blkid \ | ||
| e2fsprogs-extra | ||
|
|
||
| COPY --from=builder /src/cmd/cloudscale-csi-plugin/cloudscale-csi-plugin /bin/ | ||
| COPY --from=builder /src/cmd/cloudscale-csi-plugin/csi-diskinfo.sh /bin/ | ||
|
|
||
| ENTRYPOINT ["/bin/cloudscale-csi-plugin"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contradicts
test/kubernetes/integration_test.go(also noted there)