Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.63 KB

README.md

File metadata and controls

26 lines (20 loc) · 1.63 KB

e2e tests

How to run the test locally?

  • Install chainsaw: go install github.com/kyverno/chainsaw@latest
  • Execute make test-e2e

How to add a new test locally?

  • Create a clean cluster kind delete cluster --name kind && make create-kind deploy-kind && kubectl port-forward deploy/netbox 8080:8080 -n default
  • During development, we would need to have a clean NetBox instance between runs, which we can do with the following commands as soon as we create a new cluster
    • Backup: kubectl exec pod/netbox-db-0 -- bash -c "pg_dump --clean -U postgres netbox" > database.sql
  • The simplest test case is tests/e2e/GivenPrefixClaimWithPreserveWhenAppliedThenSucceed
    • We always need a chainsaw-test.yaml
  • Perform a clean run by resetting the database first, then execute the test
    • Reset database cat database.sql | kubectl exec -i pod/netbox-db-0 -- psql -U postgres -d netbox
      • Make sure that in the e2e namespace, no leftover CRs are there
    • Execute the entire e2e test make test-e2e
      • Or just perform a specific run, e.g. chainsaw test --test-dir tests/e2e/Prefix/IPv4/GivenPrefixClaimWhenAppliedThenFailedPrefixExhausted

Some debugging tips

  • kubectl get prefixclaim,prefix,ipaddressclaim,ipaddress,iprange,iprangeclaim -A
  • For monitoring failures, we can use event (which is a native k8s object)
    • e.g. kubectl events --for prefixclaim.netbox.dev/prefixclaim-apply-prefixexhausted-3 -o yaml
  • I am not entirely sure why is resetting the database not clean enough, maybe the redis is doing some caching that I am not aware of