Skip to content

Commit

Permalink
test: add csi-sanity action to PRs (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-old-user authored Feb 28, 2023
1 parent 9030b5d commit 4ecdb2b
Show file tree
Hide file tree
Showing 5 changed files with 266 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: sanity
on:
pull_request:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
# through 1 to 9
PLUGIN_VERBOSITY: ${{ vars.PLUGIN_VERBOSITY }}
# - ' '
# - '-ginkgo.v'
# - '-ginkgo.vv'
SANITY_VERBOSITY: ${{ vars.SANITY_VERBOSITY }}
COMPOSE_DEFAULTS: '--exit-code-from=sanity --always-recreate-deps --force-recreate'

jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: echo "${{ secrets.WEKAFS_API_SECRET_YAML }}" > tests/csi-sanity/wekafs-api-secret.yaml

- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v4
with:
context: .
file: tests/csi-sanity/ga-Dockerfile
tags: sanity:latest
load: true

legacy_sanity:
needs: build
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-nosnapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: legacy_sanity

directory_volume_no_snapshots:
if: success() || failure() # always() can't be canceled
needs: legacy_sanity
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-nosnapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: directory_volume_no_snapshots

fs_volume_no_snapshots:
if: success() || failure()
needs: directory_volume_no_snapshots
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-nosnapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: fs_volume_no_snapshots

directory_volume_and_snapshots:
if: success() || failure()
needs: fs_volume_no_snapshots
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-snapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: directory_volume_and_snapshots

snaphot_volumes_with_2nd_level_shapshots:
if: success() || failure()
needs: directory_volume_and_snapshots
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-snapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: snaphot_volumes_with_2nd_level_shapshots

filesystem_volumes:
if: success() || failure()
needs: snaphot_volumes_with_2nd_level_shapshots
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- run: docker-compose -f tests/csi-sanity/docker-compose-snapshotcaps.yaml up $COMPOSE_DEFAULTS
env:
SANITY_FUNCTION: filesystem_volumes
31 changes: 31 additions & 0 deletions tests/csi-sanity/docker-compose-nosnapshotcaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'

services:
plugin_controller_no_snaps:
image: sanity
command: wekafsplugin -nodeid 1 -v ${PLUGIN_VERBOSITY} --allowinsecurehttps --endpoint=unix://tmp/weka-csi-test/controller-no-snaps.sock --debugpath=/tmp/weka-csi-test/filesystems -metricsport=9091 --csimode=controller -enablemetrics -allowautofscreation -allowautofsexpansion -allowsnapshotsoflegacyvolumes -allowautoseedsnapshotcreation -suppresssnapshotcapability -suppressrvolumeclonecapability -alwaysallowsnapshotvolumes
volumes:
- test-volume:/tmp/weka-csi-test
privileged: true
network_mode: host
plugin_node_no_snaps:
image: sanity
command: wekafsplugin -nodeid 1 -v ${PLUGIN_VERBOSITY} --allowinsecurehttps --endpoint=unix://tmp/weka-csi-test/node-no-snaps.sock --debugpath=/tmp/weka-csi-test/filesystems -metricsport=9092 --csimode=node -enablemetrics -allowautofscreation -allowautofsexpansion -allowsnapshotsoflegacyvolumes -allowautoseedsnapshotcreation -suppresssnapshotcapability -suppressrvolumeclonecapability -alwaysallowsnapshotvolumes
volumes:
- test-volume:/tmp/weka-csi-test
privileged: true
network_mode: host
sanity:
image: sanity
command: run_sanity ${SANITY_FUNCTION} ${SANITY_VERBOSITY}
network_mode: host
volumes:
- test-volume:/tmp/weka-csi-test
healthcheck:
test: test -f /tmp/weka-csi-test/controller-no-snaps.sock && test -f /tmp/weka-csi-test/node-no-snaps.sock
start_period: 5s
timeout: 1s
retries: 5
interval: 3s
volumes:
test-volume:
31 changes: 31 additions & 0 deletions tests/csi-sanity/docker-compose-snapshotcaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'

services:
plugin_controller:
image: sanity
command: wekafsplugin -nodeid 1 -v ${PLUGIN_VERBOSITY} --allowinsecurehttps --endpoint=unix://tmp/weka-csi-test/controller.sock --debugpath=/tmp/weka-csi-test/filesystems -metricsport=9091 --csimode=controller -enablemetrics -allowautofscreation -allowautofsexpansion -allowsnapshotsoflegacyvolumes -allowautoseedsnapshotcreation -alwaysallowsnapshotvolumes
volumes:
- test-volume:/tmp/weka-csi-test
privileged: true
network_mode: host
plugin_node:
image: sanity
command: wekafsplugin -nodeid 1 -v ${PLUGIN_VERBOSITY} --allowinsecurehttps --endpoint=unix://tmp/weka-csi-test/node.sock --debugpath=/tmp/weka-csi-test/filesystems -metricsport=9092 --csimode=node -enablemetrics -allowautofscreation -allowautofsexpansion -allowsnapshotsoflegacyvolumes -allowautoseedsnapshotcreation -alwaysallowsnapshotvolumes
volumes:
- test-volume:/tmp/weka-csi-test
privileged: true
network_mode: host
sanity:
image: sanity
command: run_sanity ${SANITY_FUNCTION} ${SANITY_VERBOSITY}
network_mode: host
volumes:
- test-volume:/tmp/weka-csi-test
healthcheck:
test: test -f /tmp/weka-csi-test/controller.sock && test -f /tmp/weka-csi-test/node.sock
start_period: 5s
timeout: 1s
retries: 5
interval: 3s
volumes:
test-volume:
25 changes: 25 additions & 0 deletions tests/csi-sanity/ga-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.19-alpine

WORKDIR /app

COPY go.mod .
COPY go.sum .
RUN go mod download

RUN go install -v github.com/kubernetes-csi/csi-test/v5/cmd/[email protected]

COPY cmd cmd
COPY pkg pkg

RUN CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" go build -a -ldflags '-X main.version='$VERSION' -extldflags "-static"' -o wekafsplugin ./cmd/wekafsplugin/main.go


FROM golang:1.19-alpine

ADD tests/csi-sanity/wekafs-dirv1.yaml /test/wekafs-dirv1.yaml
ADD tests/csi-sanity/wekafs-fs.yaml /test/wekafs-fs.yaml
ADD tests/csi-sanity/wekafs-snapvol.yaml /test/wekafs-snapvol.yaml
ADD tests/csi-sanity/wekafs-api-secret.yaml /test/wekafs-api-secret.yaml
ADD tests/csi-sanity/ga_docker_run_sanity.sh /usr/bin/run_sanity
COPY --from=0 /go/bin/csi-sanity /usr/local/bin/csi-sanity
COPY --from=0 /app/wekafsplugin /usr/local/bin/wekafsplugin
89 changes: 89 additions & 0 deletions tests/csi-sanity/ga_docker_run_sanity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env sh

mkdir -p /tmp/weka-csi-test/filesystems/default/test/my/path

# ---------------------- LEGACY DIR VOLUME NO API BINDING (NO SNAPSHOT SUPPORT) ----------------------
legacy_sanity() {
echo "LEGACY SANITY STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller-no-snaps.sock \
--csi.endpoint /tmp/weka-csi-test/node-no-snaps.sock \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-ginkgo.always-emit-ginkgo-writer \
-ginkgo.progress $1\
-ginkgo.seed 0 \
-csi.testvolumeparameters /test/wekafs-dirv1.yaml
}

# ---------------------- DIR VOLUME WITH API BINDING EXCLUDING SNAPSHOTS ----------------------
directory_volume_no_snapshots() {
echo "DIRECTORY VOLUME NO SNAPSHOTS STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller-no-snaps.sock \
--csi.endpoint /tmp/weka-csi-test/node-no-snaps.sock \
-csi.secrets /test/wekafs-api-secret.yaml \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-ginkgo.seed 0 \
-ginkgo.progress $1\
-csi.testvolumeparameters /test/wekafs-dirv1.yaml
}

# ---------------------- FS VOLUME WITH API BINDING EXCLUDING SNAPSHOTS ----------------------
fs_volume_no_snapshots() {
echo "FS VOLUME NO SNAPSHOTS STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller-no-snaps.sock \
--csi.endpoint /tmp/weka-csi-test/node-no-snaps.sock \
-csi.secrets /test/wekafs-api-secret.yaml \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-csi.testvolumeparameters /test/wekafs-fs.yaml \
-ginkgo.seed 0 \
-ginkgo.progress $1
}

# ---------------------- DIR VOLUME WITH API BINDING AND SNAPSHOTS ----------------------
directory_volume_and_snapshots() {
echo "DIRECTORY VOLUME AND SNAPSHOTS STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller.sock \
--csi.endpoint /tmp/weka-csi-test/node.sock \
-csi.secrets /test/wekafs-api-secret.yaml \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-ginkgo.seed 0 \
-ginkgo.progress $1\
-csi.testvolumeparameters /test/wekafs-dirv1.yaml
}

# ---------------------- SNAPSHOT VOLUME WITH API BINDING AND SNAPSHOTS ----------------------
snaphot_volumes_with_2nd_level_shapshots() {
echo "SNAPSHOT VOLUMES WITH 2nd LEVEL SNAPSHOTS STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller.sock \
--csi.endpoint /tmp/weka-csi-test/node.sock \
-csi.secrets /test/wekafs-api-secret.yaml \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-ginkgo.seed 0 \
-ginkgo.progress $1\
-csi.testvolumeparameters /test/wekafs-snapvol.yaml
}

# ---------------------- FILESYSTEM VOLUME WITH API BINDING AND SNAPSHOTS ----------------------
filesystem_volumes() {
echo "FILESYSTEM VOLUMES STARTED"

csi-sanity -csi.stagingdir /tmp/csi-test-staging \
--csi.controllerendpoint /tmp/weka-csi-test/controller.sock \
--csi.endpoint /tmp/weka-csi-test/node.sock \
-csi.secrets /test/wekafs-api-secret.yaml \
-csi.mountdir=/tmp/weka-csi-test/sanity-workspace/ \
-ginkgo.seed 0 \
-ginkgo.progress $1\
-csi.testvolumeparameters /test/wekafs-fs.yaml
}

"$@"

0 comments on commit 4ecdb2b

Please sign in to comment.