Skip to content

Testing guide

cguran-ionos edited this page Oct 5, 2023 · 1 revision

In order to test something implemented, you can add integration tests and then:

  • make -j2 build VERSION=latest --debug
  • make e2e VERSION=latest USE_HELM3=true skipcleanup=true

If you get an error that the images *.dirty was not found in the registry, check that you have correctly set VERSION=... Note: make sure to use VERSION in uppercase. Using skipcleanup=true means that the clusters will not be deleted at the end. Useful commands: k get pods k logs <pod_name> -f --all-containers

Useful cleanup commands after running tests:

  • docker rmi -f $(docker images -aq) - deletes all docker images
  • kind delete clustes --all

To run a local image and debug without tests, using kubectl apply:

  • Create your local registry docker run -d -p 5000:5000 --restart=always --name registry registry:2
  • Tag your image docker tag ghcr.io/ionos-cloud/crossplane-provider-ionoscloud-controller:latest <local_docker_ip>:5000/myprov
  • docker push <local_docker_ip>:5000/myprov
  • Change in install_provider.sh from the registry from ghcr.io/ionos-cloud/crossplane-provider-ionoscloud-controller:latest to <local_docker_ip>:5000/myprov
  • Start debugging in your IDE of choice from main.go. You shold see that it reads the crds and starts getting events.
  • Run the following:

kind create cluster --name crossplane-example

kubectl config use-context kind-crossplane-example

kubectl create namespace crossplane-system

  • kubectl config set-context --current --namespace=crossplane-system
  • helm repo add crossplane-stable https://charts.crossplane.io/stable
  • helm repo update
  • helm install crossplane --namespace crossplane-system crossplane-stable/crossplane
  • kubectl apply -f package/crds/ -R
  • export BASE64_PW=$(echo -n "${IONOS_PASSWORD}" | base64)
  • kubectl create secret generic --namespace crossplane-system example-provider-secret --from-literal=credentials="{"user":"${IONOS_USERNAME}","password":"${BASE64_PW}"}"
  • kubectl apply -f examples/provider/config.yaml
  • sleep 10```
  • kubectl apply --namespace crossplane-system -f examples/provider/debug-config.yaml
  • kubectl apply --namespace crossplane-system -f examples/provider/install-provider.yaml
  • kubectl apply --namespace crossplane-system -f examples/providers/other-providers.yaml
  • Run kubectl apply -f <name_of_crd>
Clone this wiki locally