From 8b7d14b54e45530f731c65629c6fc1d74c6ecb5f Mon Sep 17 00:00:00 2001 From: Joe Skazinski Date: Wed, 6 Oct 2021 19:37:35 -0600 Subject: [PATCH] test: new command line script for running csi-sanity Created a new sanity-cli test script to be used for running tests from the command line, requires updates to .env Signed-off-by: Joe Skazinski --- .github/workflows/publish.yml | 5 ++-- .gitignore | 9 +++--- test/.env | 16 ++++++++++ test/.env-example | 3 -- test/sanity-cli | 56 +++++++++++++++++++++++++++++++++++ test/{sanity => sanity-go} | 0 test/secrets.template.yml | 42 +++++++++++++------------- test/volume.template.yml | 2 ++ 8 files changed, 103 insertions(+), 30 deletions(-) create mode 100644 test/.env delete mode 100644 test/.env-example create mode 100755 test/sanity-cli rename test/{sanity => sanity-go} (100%) create mode 100644 test/volume.template.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 01fc9b93..c0f56255 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -46,8 +46,9 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + - name: Build and Push Docker Image + id: docker_build + uses: docker/build-push-action@v2 with: context: . push: true diff --git a/.gitignore b/.gitignore index 3615e99e..1f53f28b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ # go dependencies /vendor -# test cluster config -test/.env - # v1.x files _legacy @@ -17,4 +14,8 @@ seagate-exos-x-csi-controller # vs code .vscode/ -node_modules/ \ No newline at end of file +node_modules/ + +# test files +test/secrets.yml +test/volume.yml diff --git a/test/.env b/test/.env new file mode 100644 index 00000000..22fbc399 --- /dev/null +++ b/test/.env @@ -0,0 +1,16 @@ +# +# Fill in all values below using the example as a template. +# Passwords with special characters must be escaped and quoted. +# +# Example: +# TEST_USERNAME=username +# TEST_PASSWORD=\"\!password\" +# TEST_IP=http://1.2.3.4 +# TEST_POOL=A|B +# TEST_FSTYPE=ext3|ext4|xfs +# +TEST_USERNAME= +TEST_PASSWORD= +TEST_IP= +TEST_POOL= +TEST_FSTYPE= diff --git a/test/.env-example b/test/.env-example deleted file mode 100644 index bbcec4e9..00000000 --- a/test/.env-example +++ /dev/null @@ -1,3 +0,0 @@ -STORAGE_USERNAME= -STORAGE_PASSWORD= -STORAGE_API_ADDR= diff --git a/test/sanity-cli b/test/sanity-cli new file mode 100755 index 00000000..189b171d --- /dev/null +++ b/test/sanity-cli @@ -0,0 +1,56 @@ +#! /usr/bin/env bash + +echo "" +echo "[] sanity-cli" + +secretsTemplate="secrets.template.yml" +secrets="secrets.yml" +volumeTemplate="volume.template.yml" +volume="volume.yml" + +set -e + +function pause() +{ + echo "" + read -s -n 1 -p "===== Press any key to contine =====" + echo "" +} + +function setup { + cd $(dirname $0) + set -a; . .env; set +a + + echo "" + + envsubst < ${secretsTemplate} > ${secrets} + echo "===== ${secrets} =====" + cat ${secrets} + echo "===== END =====" + + echo "" + + envsubst < ${volumeTemplate} > ${volume} + echo "===== ${volume} =====" + cat ${volume} + echo "===== END =====" +} + +setup +pause + +controller=unix:///var/run/csi-exos-x.seagate.com/csi-controller.sock +node=unix:///var/run/csi-exos-x.seagate.com/csi-node.sock +sanity=/home/seagate/github.com/kubernetes-csi/csi-test/cmd/csi-sanity/csi-sanity +focus="CreateVolume" +focus="DeleteVolume" +focus="" + +echo "" +echo "[] csi-sanity" +echo "sudo ${sanity} -csi.controllerendpoint ${controller} -csi.endpoint ${node} -csi.secrets ${secrets} -ginkgo.focus \"${focus}\" -csi.testvolumeparameters ${volume} -ginkgo.failFast > sanity.log" +sudo ${sanity} -csi.controllerendpoint ${controller} -csi.endpoint ${node} -csi.secrets ${secrets} -ginkgo.focus "${focus}" -csi.testvolumeparameters ${volume} -ginkgo.failFast > sanity.log + +out=$? + +exit ${out} diff --git a/test/sanity b/test/sanity-go similarity index 100% rename from test/sanity rename to test/sanity-go diff --git a/test/secrets.template.yml b/test/secrets.template.yml index c9c866a7..2109d7a5 100644 --- a/test/secrets.template.yml +++ b/test/secrets.template.yml @@ -1,28 +1,28 @@ CreateVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP DeleteVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP ControllerPublishVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP ControllerUnpublishVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP NodeStageVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP NodePublishVolumeSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP ControllerValidateVolumeCapabilitiesSecret: - username: $STORAGE_USERNAME - password: $STORAGE_PASSWORD - apiAddress: $STORAGE_API_ADDR + username: $TEST_USERNAME + password: $TEST_PASSWORD + apiAddress: $TEST_IP diff --git a/test/volume.template.yml b/test/volume.template.yml new file mode 100644 index 00000000..3d8e4511 --- /dev/null +++ b/test/volume.template.yml @@ -0,0 +1,2 @@ +pool: $TEST_POOL +fsType: $TEST_FSTYPE