From cef1e1d78eb3d159ac48161999ce3f45221b0dab Mon Sep 17 00:00:00 2001 From: Adam0Brien Date: Fri, 22 Nov 2024 11:24:48 +0000 Subject: [PATCH] wait for all pods to complete before testing --- deploy/kind/e2e/e2e-batch.yaml | 9 ++---- .../spicedb-kind-setup/kind-kube/README.md | 5 --- .../spicedb-kind-setup/postgres/README.md | 5 --- scripts/start-inventory-kind.sh | 31 ++++++++++--------- 4 files changed, 18 insertions(+), 32 deletions(-) delete mode 100644 deploy/kind/relations/spicedb-kind-setup/kind-kube/README.md delete mode 100644 deploy/kind/relations/spicedb-kind-setup/postgres/README.md diff --git a/deploy/kind/e2e/e2e-batch.yaml b/deploy/kind/e2e/e2e-batch.yaml index 9846f2a9..4bc41cff 100644 --- a/deploy/kind/e2e/e2e-batch.yaml +++ b/deploy/kind/e2e/e2e-batch.yaml @@ -5,7 +5,7 @@ metadata: spec: completions: 1 backoffLimit: 0 - template: # curl -v http://spicedb-cr:50051/readyz + template: spec: initContainers: - name: wait-for-inventory @@ -21,12 +21,7 @@ spec: done echo "Inventory service is ready!" -# echo "Waiting for relations-service to be ready..." -# while ! curl -s http://relationships-service:9000/api/authz/readyz; do -# echo "Relations service not ready yet. Sleeping for 5 seconds..." -# sleep 5 -# done -# echo "Inventory service is ready!" + containers: - name: e2e-http-tests image: localhost/inventory-e2e-tests:e2e-test diff --git a/deploy/kind/relations/spicedb-kind-setup/kind-kube/README.md b/deploy/kind/relations/spicedb-kind-setup/kind-kube/README.md deleted file mode 100644 index c165d588..00000000 --- a/deploy/kind/relations/spicedb-kind-setup/kind-kube/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Create a Kubernetes cluster -`kind create cluster --config kind-ingress.config` - -# Configure Conture -kubectl apply -f contour.yaml \ No newline at end of file diff --git a/deploy/kind/relations/spicedb-kind-setup/postgres/README.md b/deploy/kind/relations/spicedb-kind-setup/postgres/README.md deleted file mode 100644 index 00c58837..00000000 --- a/deploy/kind/relations/spicedb-kind-setup/postgres/README.md +++ /dev/null @@ -1,5 +0,0 @@ -`kubectl create namespace spicedb` - -`kubectl apply -f secret.yaml -n spicedb` -`kubectl apply -f storage.yaml -n spicedb` -`kubectl apply -f postgresql.yaml -n spicedb` \ No newline at end of file diff --git a/scripts/start-inventory-kind.sh b/scripts/start-inventory-kind.sh index 060efdb2..5d50b2c6 100755 --- a/scripts/start-inventory-kind.sh +++ b/scripts/start-inventory-kind.sh @@ -21,21 +21,8 @@ ${DOCKER} save -o inventory-e2e-tests.tar localhost/inventory-e2e-tests:e2e-test kind load image-archive inventory-api.tar --name inventory-cluster kind load image-archive inventory-e2e-tests.tar --name inventory-cluster -#kubectl create configmap inventory-api-psks --from-file=config/psks.yaml -# -#kubectl apply -f https://strimzi.io/install/latest\?namespace\=default -#kubectl apply -f deploy/kind/inventory/kessel-inventory.yaml -#kubectl apply -f deploy/kind/inventory/invdatabase.yaml -#kubectl apply -f deploy/kind/e2e/e2e-batch.yaml -#kubectl apply -f deploy/kind/inventory/strimzi.yaml - -# Create the kessel namespace -kubectl create namespace kessel - -# Deploy ConfigMap for inventory-api kubectl create configmap inventory-api-psks --from-file=config/psks.yaml -# Deploy Inventory dependencies kubectl apply -f https://strimzi.io/install/latest\?namespace\=default kubectl apply -f deploy/kind/inventory/kessel-inventory.yaml kubectl apply -f deploy/kind/inventory/invdatabase.yaml @@ -45,10 +32,9 @@ kubectl apply -f deploy/kind/inventory/strimzi.yaml kubectl apply -f https://projectcontour.io/quickstart/contour.yaml kubectl get crd httpproxies.projectcontour.io -# add configmap +# add configmap for spicedb schema kubectl create configmap spicedb-schema --from-file=deploy/schema.zed -# Deploy SpiceDB and Relations-API in the kessel namespace kubectl apply -f deploy/kind/relations/spicedb-kind-setup/postgres/secret.yaml kubectl apply -f deploy/kind/relations/spicedb-kind-setup/postgres/postgresql.yaml kubectl apply -f deploy/kind/relations/spicedb-kind-setup/postgres/storage.yaml @@ -59,5 +45,20 @@ kubectl apply -f deploy/kind/relations/spicedb-kind-setup/relations-api/secret.y kubectl apply -f deploy/kind/relations/spicedb-kind-setup/relations-api/deployment.yaml kubectl apply -f deploy/kind/relations/spicedb-kind-setup/relations-api/svc.yaml + + +echo "Waiting for all pods to be fully ready..." +while true; do + PODS_READY=$(kubectl get pods --no-headers | awk '{print $2}' | grep -v '1/1\|2/2' | wc -l) + if [ "$PODS_READY" -eq 0 ]; then + echo "All pods are ready!" + break + else + echo "Waiting for pods to be ready... ($PODS_READY not ready yet)" + sleep 5 + fi +done + kubectl apply -f deploy/kind/e2e/e2e-batch.yaml + echo "Setup complete." \ No newline at end of file