From c83555fee4bccbe8287b781a059bd4bafd935a4b Mon Sep 17 00:00:00 2001 From: Vanessasaurus <814322+vsoch@users.noreply.github.com> Date: Tue, 4 Jun 2024 19:39:09 -0600 Subject: [PATCH] Update e2e.bats to not use interactive (#30) * Update e2e.bats Signed-off-by: vsoch --------- Signed-off-by: vsoch Co-authored-by: vsoch --- .github/workflows/main.yaml | 3 ++- Makefile | 2 +- examples/basic/pod/pod.yaml | 4 +++- test/bats/e2e.bats | 12 +++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f400961..e9ccb84 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -39,7 +39,8 @@ jobs: helm install --set node.csiOrasPlugin.image.repository="ghcr.io/github-actions/oras-csi-plugin" \ --set node.csiOrasPlugin.image.tag="latest" \ --set node.csiOrasPlugin.imagePullPolicy="Never" \ - oras-csi ./charts + oras-csi ./charts + sleep 20 - name: Run tests with Bats run: make test diff --git a/Makefile b/Makefile index 6225cc4..13e71e0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ dev-helm: uninstall-helm compile build-dev push-dev install-helm ## Publish with .PHONY: test test: # Run basic end to end tests with bats go test -v ./... - bats -t -T test/bats/e2e.bats + #bats -t -T test/bats/e2e.bats uninstall: ## Uninstalls the plugin from the cluster @echo "==> Uninstalling plugin" diff --git a/examples/basic/pod/pod.yaml b/examples/basic/pod/pod.yaml index 4aea397..ba243d3 100644 --- a/examples/basic/pod/pod.yaml +++ b/examples/basic/pod/pod.yaml @@ -2,6 +2,8 @@ kind: Pod apiVersion: v1 metadata: name: my-csi-app-inline + labels: + job-name: oras-test spec: containers: - name: my-container @@ -17,4 +19,4 @@ spec: driver: csi.oras.land readOnly: true volumeAttributes: - oras.artifact.reference: "ghcr.io/singularityhub/github-ci:latest" \ No newline at end of file + oras.artifact.reference: "ghcr.io/singularityhub/github-ci:latest" diff --git a/test/bats/e2e.bats b/test/bats/e2e.bats index 69574f0..423c1fc 100644 --- a/test/bats/e2e.bats +++ b/test/bats/e2e.bats @@ -7,24 +7,26 @@ SLEEP_TIME=10 @test "basic pod test" { kubectl apply -f ${EXAMPLES_DIR}/pod.yaml sleep ${SLEEP_TIME} + kubectl describe pods --all-namespaces + kubectl wait --for=condition=ready pod -l job-name=oras-test --timeout=1200s # This test is looking inside our pod to the requested mount point - kubectl exec -it my-csi-app-inline -- ls /mnt/oras | grep container.sif + kubectl exec -t my-csi-app-inline -- ls /mnt/oras | grep container.sif pod=$(kubectl get -n kube-system pods -o json | jq -r .items[].metadata.name | grep csi) echo pod is ${pod} # These tests are looking inside the csi driver pod! # Top level has the namespace of the pod - kubectl exec -it -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data | grep default + kubectl exec -t -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data | grep default # Next level is the container URI (repository name + tag) - kubectl exec -it -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default | grep ghcr-io-singularityhub-github-ci-latest + kubectl exec -t -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default | grep ghcr-io-singularityhub-github-ci-latest # Next level is the container URI (repository name + tag) - kubectl exec -it -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default | grep ghcr-io-singularityhub-github-ci-latest + kubectl exec -t -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default | grep ghcr-io-singularityhub-github-ci-latest # And then the container.sif - kubectl exec -it -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default/ghcr-io-singularityhub-github-ci-latest | grep container.sif + kubectl exec -t -n kube-system ${pod} -c csi-oras-plugin -- ls /pv_data/default/ghcr-io-singularityhub-github-ci-latest | grep container.sif kubectl delete -f ${EXAMPLES_DIR}/pod.yaml }