Skip to content

Commit

Permalink
correct the behaviour of e2e tests
Browse files Browse the repository at this point in the history
This change correct to behaviour of the drift e2e test case to:
- start with the auto mode and wait for the object applied state
- patch the object to be approvePlan: disable
- the object shoud continue to do drift detection correctly

Signed-off-by: Chanwit Kaewkasi <[email protected]>
  • Loading branch information
chanwit committed Sep 14, 2023
1 parent 55a2c42 commit 05a0d6c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@ jobs:
- name: Run drift detection tests
run: |
kubectl -n tf-system apply -f ./config/testdata/drift-detection
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=ready=unknown --timeout=4m
# apply should be true first
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=apply=true --timeout=4m
# patch .spec.approvePlan to "disable"
kubectl -n tf-system patch terraform/helloworld-drift-detection -p '{"spec":{"approvePlan":"disable"}}' --type=merge
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=ready=true --timeout=4m
# disable drift detection
# the object should work correctly
kubectl -n tf-system wait terraform/helloworld-drift-detection-disable --for=condition=ready --timeout=4m
# delete after tests
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/drift-detection/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: helloworld-drift-detection
spec:
interval: 10s
approvePlan: "disable"
approvePlan: "auto" # first it must be auto, then use kubectl to patch this to "disable"
path: ./
sourceRef:
kind: GitRepository
Expand Down
11 changes: 10 additions & 1 deletion local-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ kubectl -n tf-system delete -f ./config/testdata/always-clean-pod
echo "==================== Run drift detection tests"

kubectl -n tf-system apply -f ./config/testdata/drift-detection
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=ready=unknown --timeout=4m

# apply should be true first
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=apply=true --timeout=4m

# patch .spec.approvePlan to "disable"
kubectl -n tf-system patch terraform/helloworld-drift-detection -p '{"spec":{"approvePlan":"disable"}}' --type=merge
kubectl -n tf-system wait terraform/helloworld-drift-detection --for=condition=ready=true --timeout=4m

# disable drift detection
# the object should work correctly
kubectl -n tf-system wait terraform/helloworld-drift-detection-disable --for=condition=ready --timeout=4m

# delete after tests
Expand Down

0 comments on commit 05a0d6c

Please sign in to comment.