Skip to content

Commit

Permalink
only try tests once
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam0Brien committed Nov 25, 2024
1 parent c78edef commit 105f982
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 93 deletions.
41 changes: 5 additions & 36 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/kind/e2e/e2e-batch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: e2e-inventory-http-tests
spec:
completions: 1
backoffLimit: 0
template:
spec:
initContainers:
Expand All @@ -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
1 change: 1 addition & 0 deletions deploy/kind/inventory/kessel-inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ stringData:
eventing:
eventer: stdout
kafka:
bootstrap-servers: "my-cluster-kafka-bootstrap:9092"
storage:
disable-persistence: true
database: postgres
Expand Down
23 changes: 8 additions & 15 deletions deploy/kind/inventory/strimzi.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: {}

5 changes: 0 additions & 5 deletions deploy/kind/relations/spicedb-kind-setup/kind-kube/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions deploy/kind/relations/spicedb-kind-setup/postgres/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ spec:
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
claimName: postgres-pvc

Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ spec:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storage: 1Gi

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ spec:
port:
number: 9000
path: /
pathType: Prefix
pathType: Prefix

10 changes: 0 additions & 10 deletions deploy/kind/relations/spicedb-kind-setup/sm-spicedb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ spec:
- port: metrics
path: /metrics
interval: 15s










5 changes: 3 additions & 2 deletions deploy/kind/relations/spicedb-kind-setup/spicedb-cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
logLevel: debug
datastoreEngine: postgres
#datastoreTLSSecretName: datastore-tls
replicas: 2
replicas: 1
secretName: spicedb-config

---
Expand All @@ -30,4 +30,5 @@ stringData:
# -----BEGIN CERTIFICATE-----
# --- example aws rds ca cert
# -----END CERTIFICATE-----
# ---
# ---

31 changes: 16 additions & 15 deletions scripts/start-inventory-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."

0 comments on commit 105f982

Please sign in to comment.