Integration tests ​
Usage ​
General setup & configurations ​
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. - 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.
Running the tests ​
- There is a rule
test-integrationin theMakefileof the provider repository, which can be used to start the integration test:bash$ make test-integration - This will ask for additional inputs. Most of them are self explanatory except:
- The script assumes that both the control and target clusters are already being created.
- In case of non-gardener setup (control cluster is not a gardener seed), the name of the machineclass must be
test-mc-v1and the value ofproviderSpec.secretRef.nameshould betest-mc-secret. - In case of azure,
TARGET_CLUSTER_NAMEmust be same as the name of the Azure ResourceGroup for the cluster. - If you are deploying the secret manually, a
Secretnamedtest-mc-secret(that contains the provider secret and cloud-config) in thedefaultnamespace of the Control Cluster should be created.
- The controllers log files (
mcm_process.logandmc_process.log) are stored in.ci/controllers-test/logsdirectory and can be used later.
With the Simulated Provider ​
Before running the simulated provider, please ensure that there's no old kwokctl versions present on your system since the cluster creation installs the required version. But that only happens if there's no existing installation present.
To run the integration tests against the simulated provider, rather than running the test-integration target from the provider repository, just run it on the project root. That is, machine-controller-manager/Makefile provides the same helper target that runs IT with the simulated provider.
make test-integrationNo additional inputs are required. The logs are stored in pkg/simulatedprovider/test/integration/controller/logs directory.
Adding Integration Tests for new providers ​
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.
Extending integration tests ​
- 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.