Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱E2E template parametrization #218

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

wgslr
Copy link
Member

@wgslr wgslr commented Jun 2, 2021

What this PR does / why we need it:
This PR replaces hardcoded values in e2e testing template with env variable substitution.

@metal3-io-bot metal3-io-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 2, 2021
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 872b3fc to de35a45 Compare June 2, 2021 14:00
@wgslr
Copy link
Member Author

wgslr commented Jun 2, 2021

/cc @furkatgofurov7

@wgslr wgslr changed the base branch from master to release-0.4 June 3, 2021 09:04
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch 2 times, most recently from a81256c to 125bf96 Compare June 3, 2021 15:23
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, have you tested it locally? Also, we can't for now run tests in this patch since we do not have jenkins jobs + according changes in place yet.

Comment on lines 10 to 12
export KUBERNETES_VERSION=v1.21.1
export API_ENDPOINT_HOST=192.168.111.249
export API_ENDPOINT_PORT=6443
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these and other vars below without quotes also should have a common format as other vars to keep consistency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I quoted all of them.


# preserve the template, to be substituted based on value defined in e2e_test.go
# shellcheck disable=SC2016
export CONTROL_PLANE_MACHINE_COUNT='${CONTROL_PLANE_MACHINE_COUNT}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After giving a bit more thought on this, I am wondering if this is good idea to leave this var dependent to go code value from e2e_test.go file. It seems it is possible to make it define here, have a look: here and here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I can define the variable and have it substituted in envsubst. But I'm not sure why is decoupling from e2e_test.go better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, that way it is easier IMO to set number of controlplane and worker machines for the user rather than looking for go code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've reverted that change. Although it means that the number given in e2e_test.go will be a bit confusing; it can be even set to a random number like 5 and the test will still pass alright.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by today's call adjusting it in the template is not easier than in go. Maybe let's restore the CONTROL_PLANE_MACHINE_COUNT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's restore it.

@wgslr
Copy link
Member Author

wgslr commented Jun 4, 2021

Yes, I did run the tests manually on my VM and they pass.

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There couple of more items that needs parameterization, please go through it once again. These are the ones I spotted, you can use below names borrowed from m3-dev-env if you have not defined them yet in env.sh, otherwise you can reuse already defined ones:

Comment on lines -191 to -193
#rolloutStrategy:
# rollingUpdate:
# maxSurge: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not keep commented out code around

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch 2 times, most recently from 4528697 to ae067ab Compare June 9, 2021 10:58
@metal3-io-bot metal3-io-bot added the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Jun 17, 2021
@wgslr wgslr changed the base branch from release-0.4 to master June 18, 2021 07:08
@metal3-io-bot metal3-io-bot removed the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Jun 18, 2021
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from ae067ab to 7a0b48d Compare June 18, 2021 10:24
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch 2 times, most recently from f4bd392 to 399a947 Compare June 21, 2021 12:09
preKubeadmCommands:
- netplan apply
- systemctl enable --now crio kubelet
- if (curl -sk --max-time 10 https://192.168.111.249:6443/healthz); then echo "keepalived already running";else systemctl start keepalived; fi
- if (curl -sk --max-time 10 https://${API_ENDPOINT_HOST}:${API_ENDPOINT_PORT}/healthz); then echo "keepalived already running";else systemctl start keepalived; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be CLUSTER_APIENDPOINT_HOST and CLUSTER_APIENDPOINT_PORT to keep the same variable names as are used in the metal3-dev-env.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I changed it elsewhere in the file but not here

Comment on lines 29 to 30
M3_DEV_ENV_REPO="https://github.com/nordix/metal3-dev-env.git"
M3_DEV_ENV_BRANCH="run-arbitrary-command-wgslr"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
M3_DEV_ENV_REPO="https://github.com/nordix/metal3-dev-env.git"
M3_DEV_ENV_BRANCH="run-arbitrary-command-wgslr"
M3_DEV_ENV_REPO="https://github.com/metal3-io/metal3-dev-env.git"
M3_DEV_ENV_BRANCH=master

TODO Revert the change before merging

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed for testing with integration test ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed for checking that e2e tests work. The change can be removed as soon as m3-dev-env#703 gets merged

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 399a947 to 895f177 Compare June 21, 2021 13:28
Copy link
Member

@fmuyassarov fmuyassarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 895f177 to cf44319 Compare June 22, 2021 13:19
@metal3-io-bot metal3-io-bot added the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Jun 23, 2021
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from fb05f9d to 2a782ab Compare June 24, 2021 06:51
@metal3-io-bot metal3-io-bot removed the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Jun 24, 2021
@wgslr
Copy link
Member Author

wgslr commented Jun 24, 2021

/test-v1a5-e2e

@wgslr
Copy link
Member Author

wgslr commented Jun 28, 2021

/test-integration
/test-v1a5-e2e

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from cf61bba to 0a8c838 Compare June 29, 2021 07:32
@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

/test-v1a5-e2e

@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

/test-integration

Copy link
Member

@namnx228 namnx228 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me. Just leave a comment.

- sourcePath: "${PWD}/templates/test/cluster-template-prow-single-master.yaml"
targetName: "cluster-template-single-master.yaml"
- sourcePath: "${PWD}/templates/test/cluster-template-prow-ha.yaml"
- sourcePath: "${PWD}/templates/test/cluster-template-prow-ha_envsubst.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You sure it is not cluster-template-prow-ha.yaml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The cluster-template-prow-ha_envsubst.yaml is generated by passing cluster-template-prow-ha.yaml through envsubst, which is done in the e2e-substitutions make target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this part while reviewing, would taking e2e-substitutions into e2e-tests make target help with that, because otherwise we would have to have _envsubst added for each template yaml naming where we could have multiple of them in the future

Comment on lines 7 to 8
export CAPI_VERSION=${CAPI_VERSION:-"v1alpha4"}
export CAPM3_VERSION=${CAPM3_VERSION:-"v1alpha5"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why v1a4/v1a5? we are not there yet right? I think we can keep both CAPI_VERSION and CAPM3_VERSION set to v1a3 && v1a4 accordingly for now, and we will update it as part of #167

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running in the CI it's overridden by env vars, which are already set to v1alpha4/alpha5. But I can stick to the old values as the defaults for manual runs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the point is as of now we do not have a working CAPM3 v1a5 with CAPI v1a4 yet, the vars can be set to anything, it just to avoid confusion for users thinking they are running e2e with latest CAPI.

@@ -1,397 +0,0 @@
apiVersion: cluster.x-k8s.io/v1alpha3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, we can live without this file and control number of ctpl/workers from the go code itself using the vars from environment.sh?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, we can live without this file and control number of ctpl/workers from the go code itself using the vars from environment.sh?

Have the same concern. It would be nice if we can have that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We can control the number of ctpl and workers using ControlPlaneMachineCount and WorkerMachineCount fields in ConfigClusterInput in the go code. No need to modify environment.sh either, except for setting NUM_NODES high enough to accomodate all the machines.

Copy link
Member

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly an improvement over having everything hard-coded. But I'm wondering if it would make sense to use go templates instead of envsubst in the long run?

Environment variables are probably fine as long as we just want them set to one value for all tests. However, I guess we may want to set different values for different e2e tests and still run them all as part of one test suite. For example, we may want to create a HA cluster in one test and a single machine cluster in another. With go templates it would be very natural to define these parameters in the test itself instead of setting them through environment variables.
What do you think?

@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

For example, we may want to create a HA cluster in one test and a single machine cluster in another.

This particular example - differentiating node numbers - is already achievable by chaning values in the go code. But I see your point; if we reach a use case that demands more customization of the templates it may be necessary to move to a templating solution. Do you have some particular templating mechanism in mind? For reference, AWS provider uses kustomize

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 0a8c838 to c7be3ca Compare June 29, 2021 10:25
@lentzi90
Copy link
Member

Do you have some particular templating mechanism in mind? For reference, AWS provider uses kustomize

Interesting! Then for AWS it would still require changes outside of the go code to modify the flavors. 🤔
I was thinking about go template which is already built in to the language and should be familiar to many from Helm templates. This would allow us to specify the values we want inside the test code.

@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

/test-v1a5-e2e
/test-integration

@jan-est
Copy link
Contributor

jan-est commented Jun 29, 2021

LGTM

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last thing to clarify before we move on with this one:

Makefile Outdated
Comment on lines 113 to 116
.PHONY: e2e-substitutions
e2e-substitutions: $(ENVSUBST)
$(ENVSUBST) < $(E2E_CONF_FILE) > $(E2E_CONF_FILE_ENVSUBST)
$(ENVSUBST) < $(E2E_TEMPLATE_FILE) > $(E2E_TEMPLATE_FILE_ENVSUBST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need a separate make target for env substitution? previously we had it within the e2e-tests target is not it?

- sourcePath: "${PWD}/templates/test/cluster-template-prow-single-master.yaml"
targetName: "cluster-template-single-master.yaml"
- sourcePath: "${PWD}/templates/test/cluster-template-prow-ha.yaml"
- sourcePath: "${PWD}/templates/test/cluster-template-prow-ha_envsubst.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this part while reviewing, would taking e2e-substitutions into e2e-tests make target help with that, because otherwise we would have to have _envsubst added for each template yaml naming where we could have multiple of them in the future

@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

/test-v1a5-e2e

@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 3593b2b to 0cab4fa Compare June 29, 2021 16:53
@wgslr
Copy link
Member Author

wgslr commented Jun 29, 2021

/test-v1a5-e2e
/test-integration

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: furkatgofurov7, lentzi90, namnx228

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2021
@wgslr wgslr force-pushed the e2e-parametrization-wgslr branch from 0cab4fa to 0e706fe Compare June 30, 2021 07:17
@wgslr
Copy link
Member Author

wgslr commented Jun 30, 2021

/test-v1a5-e2e
/test-integration

@jan-est
Copy link
Contributor

jan-est commented Jun 30, 2021

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2021
@metal3-io-bot metal3-io-bot merged commit dd40583 into metal3-io:master Jun 30, 2021
@kashifest kashifest deleted the e2e-parametrization-wgslr branch December 9, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants