Skip to content

Commit

Permalink
Env var for IT tests (#884)
Browse files Browse the repository at this point in the history
* Doc update for IT tests

* Added Target Resource group

* Refactored sentence

* Update pkg/test/integration/common/framework.go

Co-authored-by: Himanshu Sharma <79965161+himanshu-kun@users.noreply.github.com>

* Doc update

---------

Co-authored-by: Himanshu Sharma <79965161+himanshu-kun@users.noreply.github.com>
  • Loading branch information
sssash18 and himanshu-kun authored Dec 26, 2023
1 parent e8e1814 commit 626be90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions docs/development/integration_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ If the Control Cluster is a Gardener Shoot cluster then,

If the Control Cluster is a Gardener SEED cluster, then the suite ideally employs the already existing `MachineClass` and Secrets. However,

1. Define the variable `IS_CONTROL_SEED` in the `.env` file and set it to `true`.
1. Define the variable `IS_CONTROL_CLUSTER_SEED` in the `.env` file and set it to `true`.
`Warning:` Make sure to set the `CONTROL_NAMESPACE` variable to the shoot namespace where the control plane of the target resides.
1. Please pass `TARGET_RESOURCE_GROUP` in the `.env` file. It will be used for the `ResourceGroupName` in Azure clusters. Keep it as target cluster name for gardener shoot clusters.This is compulsory for Azure clusters.
1. (Optional) User can employ a custom `MachineClass` for the tests using below steps:
1. Deploy a `Secret` named `test-mc-secret` (that contains the provider secret and cloud-config) in the shoot namespace of the Control Cluster. That is, the value of `metadata.namespace` should be `technicalID` of the Shoot and it will be of the pattern `shoot--<project>--<shoot-name>`.
1. Create a `dev/machineclassv1.yaml` file and add an entry in the `.env` file with `MACHINECLASS_V1=dev/machineclassv1.yaml`.
Expand All @@ -57,4 +58,4 @@ For a new provider, Running Integration tests works with no changes. But for the
## Extending integration tests

- Update [ControllerTests](../../pkg/test/integration/common/framework.go#L481) to be extend the testcases for all providers. Common testcases for machine|machineDeployment creation|deletion|scaling are packaged into [ControllerTests](../../pkg/test/integration/common/framework.go#L481).
- 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 for `machine-controller-manager-provider-aws`, make changes to `test/integration/controller/controller_test.go` inside the `machine-controller-manager-provider-aws` repository. `commons` contains the `Cluster` and `Clientset` objects that makes it easy to extend the tests.
- 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 for `machine-controller-manager-provider-aws`, make changes to `test/integration/controller/controller_test.go` inside the `machine-controller-manager-provider-aws` repository. `commons` contains the `Cluster` and `Clientset` objects that makes it easy to extend the tests.
11 changes: 5 additions & 6 deletions pkg/test/integration/common/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ import (

const (
dwdIgnoreScalingAnnotation = "dependency-watchdog.gardener.cloud/ignore-scaling"

// Suffix for the`kubernetes-io-cluster` tag and cluster name for the orphan resource tracker
targetClusterPlaceholder = "integration-test-cluster"
)

var (
// path for storing log files (mcm & mc processes)
targetDir = filepath.Join("..", "..", "..", ".ci", "controllers-test", "logs")
// Suffix for the`kubernetes-io-cluster` tag and cluster name for the orphan resource tracker. Currently relevant only for Azure
targetClusterName = os.Getenv("TARGET_RESOURCE_GROUP")
// machine-controller-manager log file
mcmLogFile = filepath.Join(targetDir, "mcm_process.log")

Expand Down Expand Up @@ -491,13 +490,13 @@ func (c *IntegrationTestFramework) scaleMcmDeployment(replicas int32) error {
}

func (c *IntegrationTestFramework) updatePatchFile() {
clusterTag := "kubernetes-io-cluster-" + targetClusterPlaceholder
clusterTag := "kubernetes-io-cluster-" + targetClusterName
testRoleTag := "kubernetes-io-role-integration-test"

patchMachineClassData := MachineClassPatch{
ProviderSpec: ProviderSpecPatch{
Tags: []string{
targetClusterPlaceholder,
targetClusterName,
clusterTag,
testRoleTag,
},
Expand Down Expand Up @@ -822,7 +821,7 @@ func (c *IntegrationTestFramework) SetupBeforeSuite() {
Get(ctx, testMachineClassResources[0], metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())

clusterName := targetClusterPlaceholder
clusterName := targetClusterName

ginkgo.By("Looking for secrets refered in machineclass in the control cluster")
secretData, err := c.ControlCluster.
Expand Down

0 comments on commit 626be90

Please sign in to comment.