Skip to content

Commit

Permalink
relations/spicedb/inventory setup for e2e testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam0Brien committed Nov 21, 2024
1 parent 75d1034 commit c78edef
Show file tree
Hide file tree
Showing 20 changed files with 9,248 additions and 157 deletions.
54 changes: 46 additions & 8 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,55 @@ jobs:

- name: Monitor Pods in Kind
run: |
timeout 90s kubectl get pods -w || exit 0
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: |
TEST_POD=$(kubectl get pods --selector=job-name=e2e-inventory-http-tests -o jsonpath='{.items[0].metadata.name}')
kubectl logs $TEST_POD | tee test_logs.txt
if grep -q -E "FAIL" test_logs.txt; then
echo "Test failed. Errors found in logs."
exit 1
fi
for i in {1..300}; 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."
kubectl logs $TEST_POD
kubectl get pods
exit 0
elif [ "$STATUS" = "Error" ]; then
echo "Test pod failed."
kubectl logs $TEST_POD
kubectl get pods
exit 1
fi
sleep 1
done
- name: Inventory Down - Kind Cluster
run: make inventory-down-kind
Expand Down
5 changes: 3 additions & 2 deletions deploy/kind/e2e/e2e-batch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Job
metadata:
name: e2e-inventory-http-tests
spec:
completions: 1
template:
spec:
initContainers:
Expand All @@ -13,7 +14,7 @@ spec:
- "-c"
- |
echo "Waiting for kessel-inventory-service to be ready..."
while ! curl -s http://kessel-inventory-service/api/inventory/v1/readyz; do
while ! curl -s http://kessel-inventory-service:8081/api/inventory/v1/readyz; do
echo "Inventory service not ready yet. Sleeping for 5 seconds..."
sleep 5
done
Expand All @@ -23,7 +24,7 @@ spec:
image: localhost/inventory-e2e-tests:e2e-test
env:
- name: INV_HTTP_URL
value: "kessel-inventory-service:80"
value: "kessel-inventory-service:8081"
- name: KAFKA_BOOTSTRAP_SERVERS
value: "localhost:9092"
command: ["/usr/local/bin/e2e-inventory-tests", "-test.v"]
Expand Down
14 changes: 10 additions & 4 deletions deploy/kind/inventory/kessel-inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ spec:
app: kessel-inventory
ports:
- protocol: TCP
port: 80
port: 8081
targetPort: 8081
---
# PodDisruptionBudget
Expand Down Expand Up @@ -138,14 +138,20 @@ stringData:
grpc:
address: 0.0.0.0:9081
authn:
psk:
pre-shared-key-file: /psks.yaml
allow-unauthenticated: true
#psk:
#pre-shared-key-file: /psks.yaml
authz:
impl: allow-all
impl: kessel
kessel:
insecure-client: true
url: relationships-service.default.svc.cluster.local:9000
enable-oidc-auth: false
eventing:
eventer: stdout
kafka:
storage:
disable-persistence: true
database: postgres
sqlite3:
dsn: inventory.db
Expand Down
6 changes: 6 additions & 0 deletions deploy/kind/relations/spicedb-kind-setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Relations-api and SpiceDB setup

Setup for Relations-api and SpiceDB taken from:
```http
https://github.com/project-kessel/relations-api/tree/main/spicedb-kind-setup
```
Loading

0 comments on commit c78edef

Please sign in to comment.