From 105f98227489e49322aa1b08942e8b8d893c97d8 Mon Sep 17 00:00:00 2001 From: Adam0Brien Date: Thu, 21 Nov 2024 11:34:58 +0000 Subject: [PATCH] only try tests once --- .github/workflows/e2e-test.yml | 41 +++---------------- deploy/kind/e2e/e2e-batch.yaml | 4 +- deploy/kind/inventory/kessel-inventory.yaml | 1 + deploy/kind/inventory/strimzi.yaml | 23 ++++------- .../spicedb-kind-setup/kind-kube/README.md | 5 --- .../spicedb-kind-setup/postgres/README.md | 5 --- .../postgres/postgresql.yaml | 3 +- .../spicedb-kind-setup/postgres/storage.yaml | 3 +- .../spicedb-kind-setup/relations-api/svc.yaml | 3 +- .../spicedb-kind-setup/sm-spicedb.yaml | 10 ----- .../spicedb-kind-setup/spicedb-cr.yaml | 5 ++- scripts/start-inventory-kind.sh | 31 +++++++------- 12 files changed, 41 insertions(+), 93 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/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b85557bd..74e42c2d 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -15,55 +15,24 @@ 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 + kubectl get svc 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..44003066 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: @@ -26,7 +27,6 @@ spec: - name: INV_HTTP_URL value: "kessel-inventory-service:8081" - name: KAFKA_BOOTSTRAP_SERVERS - value: "localhost:9092" + value: "my-cluster-kafka-bootstrap:9092" # my-cluster-kafka-bootstrap:9092 command: ["/usr/local/bin/e2e-inventory-tests", "-test.v"] restartPolicy: Never - backoffLimit: 4 diff --git a/deploy/kind/inventory/kessel-inventory.yaml b/deploy/kind/inventory/kessel-inventory.yaml index f725a822..2798cf5e 100644 --- a/deploy/kind/inventory/kessel-inventory.yaml +++ b/deploy/kind/inventory/kessel-inventory.yaml @@ -150,6 +150,7 @@ stringData: eventing: eventer: stdout kafka: + bootstrap-servers: "my-cluster-kafka-bootstrap:9092" storage: disable-persistence: true database: postgres diff --git a/deploy/kind/inventory/strimzi.yaml b/deploy/kind/inventory/strimzi.yaml index e3de6219..651a8ddc 100644 --- a/deploy/kind/inventory/strimzi.yaml +++ b/deploy/kind/inventory/strimzi.yaml @@ -1,8 +1,8 @@ -# Taken from: https://github.com/strimzi/strimzi-kafka-operator/blob/main/examples/kafka/kafka-ephemeral.yaml apiVersion: kafka.strimzi.io/v1beta2 kind: Kafka metadata: name: my-cluster + namespace: default spec: kafka: version: 3.8.0 @@ -12,24 +12,17 @@ spec: port: 9092 type: internal tls: false - - name: tls - port: 9093 - type: internal - tls: true config: - offsets.topic.replication.factor: 3 - transaction.state.log.replication.factor: 3 - transaction.state.log.min.isr: 2 - default.replication.factor: 3 - min.insync.replicas: 2 - inter.broker.protocol.version: "3.8" + zookeeper.connect: my-cluster-zookeeper-client:2181 + offsets.topic.replication.factor: 1 + transaction.state.log.replication.factor: 1 + transaction.state.log.min.isr: 1 + default.replication.factor: 1 + min.insync.replicas: 1 + advertised.listeners: PLAINTEXT://my-cluster-kafka-bootstrap.default.svc.cluster.local:9092 storage: type: ephemeral zookeeper: replicas: 1 storage: type: ephemeral - entityOperator: - topicOperator: {} - userOperator: {} - 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/postgres/postgresql.yaml b/deploy/kind/relations/spicedb-kind-setup/postgres/postgresql.yaml index 96d60bdf..d037939c 100644 --- a/deploy/kind/relations/spicedb-kind-setup/postgres/postgresql.yaml +++ b/deploy/kind/relations/spicedb-kind-setup/postgres/postgresql.yaml @@ -51,4 +51,5 @@ spec: volumes: - name: postgres-storage persistentVolumeClaim: - claimName: postgres-pvc \ No newline at end of file + claimName: postgres-pvc + diff --git a/deploy/kind/relations/spicedb-kind-setup/postgres/storage.yaml b/deploy/kind/relations/spicedb-kind-setup/postgres/storage.yaml index 5e9954aa..0c7faa18 100644 --- a/deploy/kind/relations/spicedb-kind-setup/postgres/storage.yaml +++ b/deploy/kind/relations/spicedb-kind-setup/postgres/storage.yaml @@ -27,4 +27,5 @@ spec: - ReadWriteMany resources: requests: - storage: 1Gi \ No newline at end of file + storage: 1Gi + diff --git a/deploy/kind/relations/spicedb-kind-setup/relations-api/svc.yaml b/deploy/kind/relations/spicedb-kind-setup/relations-api/svc.yaml index 1f8d3d73..36cc6d35 100644 --- a/deploy/kind/relations/spicedb-kind-setup/relations-api/svc.yaml +++ b/deploy/kind/relations/spicedb-kind-setup/relations-api/svc.yaml @@ -28,4 +28,5 @@ spec: port: number: 9000 path: / - pathType: Prefix \ No newline at end of file + pathType: Prefix + diff --git a/deploy/kind/relations/spicedb-kind-setup/sm-spicedb.yaml b/deploy/kind/relations/spicedb-kind-setup/sm-spicedb.yaml index b39d61b0..f6063f91 100644 --- a/deploy/kind/relations/spicedb-kind-setup/sm-spicedb.yaml +++ b/deploy/kind/relations/spicedb-kind-setup/sm-spicedb.yaml @@ -19,13 +19,3 @@ spec: - port: metrics path: /metrics interval: 15s - - - - - - - - - - diff --git a/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml b/deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml index 78ab227b..284b13a7 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 --- @@ -30,4 +30,5 @@ stringData: # -----BEGIN CERTIFICATE----- # --- example aws rds ca cert # -----END CERTIFICATE----- -# --- \ No newline at end of file +# --- + diff --git a/scripts/start-inventory-kind.sh b/scripts/start-inventory-kind.sh index 060efdb2..7aefa554 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 +sleep 30 ##wait for kafka pod to run echo "Setup complete." \ No newline at end of file