Integration tests for machine-controller-manager-provider-{provider-name} can be executed manually by following below steps.
- Clone the repository
machine-controller-manager-provider-{provider-name}on the local system. - Navigate to
machine-controller-manager-provider-{provider-name}directory and create adevsub-directory in it. - Create a
.envfile at the root of themachine-controller-manager-provider-{provider-name}project. This file serves as an environments file where all key-value pairs that are used in theMakefileare defined. - Copy the kubeconfig of the Control Cluster into
dev/control-kubeconfig.yamland add an entry in the.envfile withCONTROL_KUBECONFIG=dev/control-kubeconfig.yaml. - Add
CONTROL_NAMESPACE=<namespace of the control cluster>to the.envfile. This is the namespace that is used to deploy all resources and run tests. - (optional) Copy the kubeconfig of the Target Cluster into
dev/target-kubeconfig.yamland add an entry in the.envfile withTARGET_KUBECONFIG=dev/target-kubeconfig.yaml. - If the tags on instances & associated resources on the provider are of
Stringtype (for example, GCP tags on its instances are of typeStringand not key-value pair) then addTAGS_ARE_STRINGS := truein theMakefileand export it. For GCP this has already been hard coded in theMakefile. - If the intention is to run any controllers in the control cluster, then
.envshould have at least one ofMCM_IMAGEandMC_IMAGEdefined. These images will be used along withkubernetes/deployment.yamlto deploy/update controllers in the Control Cluster. If the intention is to run the controllers locally then removeMCM_IMAGEandMC_IMAGEkey-value pairs defined in.envand setMACHINE_CONTROLLER_MANAGER_DEPLOYMENT_NAME=machine-controller-managerin theMakefilefile. - In order to apply the CRDs when the Control Cluster is a Gardener Shoot or if none of the controller images are specified,
machine-controller-managerrepository will be cloned automatically. Incase, this repository already exists in local system, then create a softlink as below which helps to test changes inmachine-controller-managerquickly.ln -sf <path-for-machine-controller-manager-repo> dev/mcm
- Please pass
TARGET_CLUSTER_NAMEin the.envfile. It will be used to initialize the orphan resource tracker. Keep it as the cluster name whose kubeconfig is specified in theTARGET_KUBECONFIGvariable.
If the Control Cluster is a Gardener Shoot cluster then,
- Deploy a
Secretnamedtest-mc-secret(that contains the provider secret and cloud-config) in thedefaultnamespace of the Control Cluster. - Create a
dev/machineclassv1.yamlfile in the cloned repository and add an entry in the.envfile withMACHINECLASS_V1=dev/machineclassv1.yaml. The name of theMachineClassitself should betest-mc-v1. The value ofproviderSpec.secretRef.nameshould betest-mc-secret. - (Optional) Create an additional
dev/machineclassv2.yamlfile similar to above but with a bigger machine type and add an entry in the.envfile withMACHINECLASS_V2=dev/machineclassv2.yaml.
If the Control Cluster is a Gardener SEED cluster, then the suite ideally employs the already existing MachineClass and Secrets. However,
- Define the variable
IS_CONTROL_CLUSTER_SEEDin the.envfile and set it totrue.Warning:Make sure to set theCONTROL_NAMESPACEvariable to the shoot namespace where the control plane of the target resides. - (Optional) User can employ a custom
MachineClassfor the tests using below steps:- Deploy a
Secretnamedtest-mc-secret(that contains the provider secret and cloud-config) in the shoot namespace of the Control Cluster. That is, the value ofmetadata.namespaceshould betechnicalIDof the Shoot and it will be of the patternshoot--<project>--<shoot-name>. - Create a
dev/machineclassv1.yamlfile and add an entry in the.envfile withMACHINECLASS_V1=dev/machineclassv1.yaml.providerSpec.secretRef.nameshould refer the secret created in the previous step.metadata.namespaceandproviderSpec.secretRef.namespaceshould betechnicalID(shoot--<project>--<shoot-name>) of the shoot.- The name of the
MachineClassitself should betest-mc-v1.
- Deploy a
- There is a rule
test-integrationin theMakefile, which can be used to start the integration test:$ make test-integration Starting integration tests... Running Suite: Controller Suite ===============================
- The controllers log files (
mcm_process.logandmc_process.log) are stored in.ci/controllers-test/logsrepo and can be used later.
For a new provider, Running Integration tests works with no changes. But for the orphan resource test cases to work correctly, the provider-specific API calls and the Resource Tracker Interface (RTI) should be implemented. Please check machine-controller-manager-provider-aws for reference.
- Update ControllerTests to be extend the testcases for all providers. Common testcases for machine|machineDeployment creation|deletion|scaling are packaged into ControllerTests.
- To extend the provider specfic test cases, the changes should be done in the
machine-controller-manager-provider-{provider-name}repository. For example, to extended the testcases formachine-controller-manager-provider-aws, make changes totest/integration/controller/controller_test.goinside themachine-controller-manager-provider-awsrepository.commonscontains theClusterandClientsetobjects that makes it easy to extend the tests.