diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b85557bd..257231f4 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -15,55 +15,23 @@ jobs: - name: Inventory Up - Kind Cluster run: make inventory-up-kind - - name: Monitor Pods in Kind - run: | - - for i in {1..100}; do - MIGRATE_STATUS=$(kubectl get pods -l job-name=spicedb-cr-migrate -o jsonpath='{.status.containerStatuses[0].ready}') - if [ "$MIGRATE_STATUS" = "Completed" ]; then - echo "SpiceDB migration completed." - break - elif [ "$MIGRATE_STATUS" = "Failed" ]; then - echo "SpiceDB migration failed." - exit 1 - fi - sleep 1 - done - - for i in {1..100}; do - ZK_STATUS=$(kubectl get pods my-cluster-zookeeper-0 -o jsonpath='{.status.phase}') - ZK_READY=$(kubectl get pods my-cluster-zookeeper-0 -o jsonpath='{.status.containerStatuses[0].ready}') - if [ "$ZK_STATUS" = "Running" ] && [ "$ZK_READY" = "true" ]; then - echo "Zookeeper is running and ready." - exit 0 - else - echo "Zookeeper is not ready yet. Status: $ZK_STATUS, Ready: $ZK_READY" - - fi - sleep 1 - done - - echo "Timeout reached while waiting for Zookeeper to be ready." - exit 1 - - - name: View Test Pod Logs run: | - for i in {1..300}; do + for i in {1..50}; do STATUS=$(kubectl get pods --selector=job-name=e2e-inventory-http-tests -o jsonpath='{.items[0].status.containerStatuses[0].state.terminated.reason}') TEST_POD=$(kubectl get pods --selector=job-name=e2e-inventory-http-tests -o jsonpath='{.items[0].metadata.name}') if [ "$STATUS" = "Completed" ]; then - echo "Test pod completed successfully." + echo "E2E test pod completed successfully." kubectl logs $TEST_POD kubectl get pods exit 0 elif [ "$STATUS" = "Error" ]; then - echo "Test pod failed." + echo "E2E test pod failed." kubectl logs $TEST_POD kubectl get pods exit 1 fi - sleep 1 + sleep 3 done diff --git a/deploy/kind/e2e/e2e-batch.yaml b/deploy/kind/e2e/e2e-batch.yaml index 8e6aa441..4bc41cff 100644 --- a/deploy/kind/e2e/e2e-batch.yaml +++ b/deploy/kind/e2e/e2e-batch.yaml @@ -4,6 +4,7 @@ metadata: name: e2e-inventory-http-tests spec: completions: 1 + backoffLimit: 0 template: spec: initContainers: @@ -19,6 +20,8 @@ spec: sleep 5 done echo "Inventory service is ready!" + + containers: - name: e2e-http-tests image: localhost/inventory-e2e-tests:e2e-test @@ -29,4 +32,3 @@ spec: value: "localhost:9092" command: ["/usr/local/bin/e2e-inventory-tests", "-test.v"] restartPolicy: Never - backoffLimit: 4 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/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml b/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml index 78ab227b..5cbbde36 100644 --- a/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml +++ b/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml @@ -8,7 +8,7 @@ spec: logLevel: debug datastoreEngine: postgres #datastoreTLSSecretName: datastore-tls - replicas: 2 + replicas: 1 secretName: spicedb-config --- diff --git a/scripts/start-inventory-kind.sh b/scripts/start-inventory-kind.sh index 060efdb2..c69023d4 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$' | 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