Skip to content

Commit

Permalink
Add chainsaw tests for bindings services
Browse files Browse the repository at this point in the history
  • Loading branch information
hjkatz committed Dec 11, 2024
1 parent e6e3a14 commit 3222ac5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ e2e-start-ngrok: ## Start the ngrok-agent for e2e tests
$(eval ASSETS_DIR := /tmp/assets-$(shell date +%s))

mkdir -p $(ASSETS_DIR)
# Note: contents must match chainsaw tests
@echo "Hello from ngrok-operator" > $(ASSETS_DIR)/hello_world.txt

# start an agent
Expand Down
45 changes: 45 additions & 0 deletions tests/chainsaw/bindings/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,48 @@ spec:
status:
~.(endpoints):
status: "bound"
# TargetService
- assert:
resource:
apiVersion: v1
kind: Service
metadata:
name: assets-allowed
namespace: e2e
spec:
type: ExternalName
externalName: ngrok-adb90775-7749-5b56-92f4-d52ee756975b.ngrok-operator.svc.cluster.local # stable hash
~.(ports):
name: http
port: 80
targetPort: 80
protocol: TCP
# UpstreamService
- assert:
resource:
apiVersion: v1
kind: Service
metadata:
name: ngrok-adb90775-7749-5b56-92f4-d52ee756975b # stable hash
namespace: ngrok-operator
spec:
type: ClusterIP
~.(ports):
name: http
port: 80
# targetPort: < -- port is allocated and may be out of order, do not assert
protocol: TCP

- name: test assets retrieval via BoundEndpoint TargetService
try:
- script:
content: |
# See contents in `make e2e-start-ngrok` task
WANT="Hello from ngrok-operator"
# 2>/dev/null to suppress kubectl default output
# first line is the contents, last line in "deleted pod" message
# remove newline to compare strings directly
GOT=$(kubectl run --restart=Never --rm --attach --image=dersimn/netutils net-utils -- curl -s http://assets-allowed.e2e/hello_world.txt 2>/dev/null | head -n1 | tr -d '\n')
[ $? -eq 0 ] || { echo "Failed to retrieve assets"; exit 1; }
[ "$GOT" = "$WANT" ] || { echo "Incorrect assets content: want '$WANT', got '$GOT'"; exit 1; }

0 comments on commit 3222ac5

Please sign in to comment.