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

Add automated testing of AWS templates, rework existing e2e testing to use kubeclient #220

Merged
merged 35 commits into from
Sep 5, 2024

Conversation

squizzi
Copy link

@squizzi squizzi commented Aug 22, 2024

This PR:

  • Reworks the existing e2e tests so that we no longer use iterations of exec.Command and instead use a new KubeClient type that implements kubernetes.Interface
  • Adds new Makefile targets make dev-aws-nuke and make cloudnuke to purge AWS resources affiliated with a desired deployment name, whether that's the test created one or the one created by config/dev/deployment.yaml
  • Utilizes this new Makefile target to purge deployed AWS resources during teardown.
  • Adds a series of provider-agnostic test validators to verify creation and deletion; which can be used to validate a provider deployed cluster, such as the newly added AWS tests.

Closes: #211
See: #201

@squizzi squizzi marked this pull request as draft August 22, 2024 00:10
@squizzi squizzi changed the title Add automating testing of AWS templates, rework existing e2e testing to use kubeclient Add automated testing of AWS templates, rework existing e2e testing to use kubeclient Aug 22, 2024
@squizzi
Copy link
Author

squizzi commented Aug 23, 2024

Any thoughts on what the timeout should be when validating resources coming online from a provider? I've seen AWS take up to 20 min sometimes to deploy resources, I currently have it set to 30 min with 10 second polling.

@squizzi
Copy link
Author

squizzi commented Aug 29, 2024

👋 this can be reviewed, but do note the aws-hosted-cp template is still not functional so for now I'm skipping that test while I continue to debug it for inclusion. This way the provider-agnostic verification code can be potentially committed and this is no longer blocking other provider testing initiatives.

@squizzi squizzi marked this pull request as ready for review August 29, 2024 19:36
@squizzi squizzi force-pushed the aws-e2e-tests branch 2 times, most recently from fcbad81 to 9732d36 Compare August 29, 2024 22:57
@squizzi
Copy link
Author

squizzi commented Aug 29, 2024

I don't know what's going on with the AWS key/secret that IT added, for whatever reason clusterawsadm is barfing when it tries to encode the credentials but make test-e2e works locally for me.

Edit: womp womp

Run echo $(aws sts get-caller-identity)

Unable to locate credentials. You can configure credentials by running "aws configure".

Local run of make test-e2e (with some lines omitted for brevity):

$ make test-e2e
make test-e2e
KIND_CLUSTER_NAME="hmc-test" KIND_VERSION=v0.23.0 go test ./test/e2e/ -v -ginkgo.v -timeout=2h
=== RUN   TestE2E
  Starting hmc suite
Running Suite: e2e suite - /home/squizzi/go/src/github.com/Mirantis/hmc/test/e2e
================================================================================
Random Seed: 1725033619

Will run 3 of 3 specs
------------------------------
controller Operator should run successfully
/home/squizzi/go/src/github.com/Mirantis/hmc/test/e2e/e2e_test.go:59
  STEP: building and deploying the controller-manager @ 08/30/24 09:00:19.688
  running: make test-apply
  running: ./bin/clusterawsadm bootstrap credentials encode-as-profile
  STEP: validating that the hmc-controller and capi provider controllers are running @ 08/30/24 09:01:49.489
  Controller pod validation failed: expected 1 hmc-controller-manager controller pod, got 2
  Controller pod validation failed: expected 1 hmc-controller-manager controller pod, got 2
  Controller pod validation failed: expected 1 cluster-api controller pod, got 0
  Controller pod validation failed: expected 1 cluster-api controller pod, got 0
  Controller pod validation failed: expected 1 hmc-controller-manager controller pod, got 2
  Controller pod validation failed: expected 1 cluster-api controller pod, got 0
  Controller pod validation failed: expected 1 cluster-api controller pod, got 0
  Controller pod validation failed: controller pod: capi-controller-manager-7f49f575d4-r7dkh in Pending status
  Controller pod validation failed: expected 1 infrastructure-aws controller pod, got 0
  Controller pod validation failed: expected 1 infrastructure-aws controller pod, got 0
  Controller pod validation failed: controller pod: capa-controller-manager-bc5cbb7b7-mpf74 in Pending status
  Controller pod validation failed: expected 1 infrastructure-azure controller pod, got 0
  Controller pod validation failed: expected 1 infrastructure-azure controller pod, got 0
  Controller pod validation failed: expected 1 infrastructure-azure controller pod, got 0
  Controller pod validation failed: controller pod: capz-controller-manager-58677bc6fd-wcm2b in Pending status
• [239.989 seconds]
------------------------------
controller AWS Templates should work with an AWS provider and aws-standalone-cp template
/home/squizzi/go/src/github.com/Mirantis/hmc/test/e2e/e2e_test.go:136
  STEP: ensuring AWS credentials are set @ 08/30/24 09:04:19.677
  STEP: creating a Deployment @ 08/30/24 09:04:19.68
  Generated cluster name: "1a5b1a9c-e2e-test"
  running: ./bin/clusterawsadm ami list --os=ubuntu-20.04 -o json
  STEP: waiting for infrastructure providers to deploy successfully @ 08/30/24 09:04:21.233
  [clusters] validation error: failed to get clusters 1a5b1a9c-e2e-test: clusters.cluster.x-k8s.io "1a5b1a9c-e2e-test" not found
  [clusters] validation error: Cluster 1a5b1a9c-e2e-test is not ready with conditions:
  [clusters] validation error: Cluster 1a5b1a9c-e2e-test is not ready with conditions:
  Type: ControlPlaneReady, Status: False, Reason: WaitingForControlPlane, Message: 
  Type: ControlPlaneInitialized, Status: False, Reason: WaitingForControlPlaneProviderInitialized, Message: Waiting for control plane provider to indicate the control plane has been initialized
  Type: Ready, Status: False, Reason: WaitingForControlPlane, Message: 
  [clusters] validation error: Cluster 1a5b1a9c-e2e-test is not ready with conditions:
  Type: ControlPlaneReady, Status: False, Reason: WaitingForControlPlane, Message: 
  Type: ControlPlaneInitialized, Status: False, Reason: WaitingForControlPlaneProviderInitialized, Message: Waiting for control plane provider to indicate the control plane has been initialized
  Type: Ready, Status: False, Reason: WaitingForControlPlane, Message: 
  [clusters] validation succeeded
  [machines] validation succeeded
  [control-planes] validation succeeded
  [csi-driver] validation error: 1a5b1a9c-e2e-test-csi-test-pvc PersistentVolume not yet 'Bound', current phase: "Pending"
  [csi-driver] validation error: 1a5b1a9c-e2e-test-csi-test-pvc PersistentVolume not yet 'Bound', current phase: "Pending"
  [csi-driver] validation error: 1a5b1a9c-e2e-test-csi-test-pvc PersistentVolume not yet 'Bound', current phase: "Pending"
  [csi-driver] validation succeeded
  [ccm] validation error: loadbalancer-1a5b1a9c-e2e-test Service does not yet have an external hostname
  [ccm] validation error: loadbalancer-1a5b1a9c-e2e-test Service does not yet have an external hostname
  [ccm] validation succeeded

@squizzi squizzi force-pushed the aws-e2e-tests branch 8 times, most recently from fc0c166 to 4cff550 Compare August 30, 2024 20:04
* Simplify GitHub actions workflow to try to get secrets working.
* Update permissions in workflow.

Signed-off-by: Kyle Squizzato <[email protected]>
The workflow will require we label the PR with "test-e2e".

Signed-off-by: Kyle Squizzato <[email protected]>
Signed-off-by: Kyle Squizzato <[email protected]>
@squizzi squizzi force-pushed the aws-e2e-tests branch 2 times, most recently from 08f9450 to 916301a Compare September 5, 2024 15:12
kylewuolle
kylewuolle previously approved these changes Sep 5, 2024
slysunkin
slysunkin previously approved these changes Sep 5, 2024
@squizzi squizzi dismissed a13x5’s stale review September 5, 2024 19:23

Can you take another look? Outside of controller-runtime being used as the client I think I've addressed all your concerns. We can always change the client up later but it would be a non-trivial rework of this PR to modify it now and this is blocking a few people at this point.

@squizzi
Copy link
Author

squizzi commented Sep 5, 2024

I need to update the Deployment types to ManagedCluster as well for the dynamic client, missed that.

@a13x5
Copy link
Contributor

a13x5 commented Sep 5, 2024

@squizzi Yes the choose of client is not that important. The rest looks good.

a13x5
a13x5 previously approved these changes Sep 5, 2024
@squizzi squizzi dismissed stale reviews from a13x5, slysunkin, and kylewuolle via 7557577 September 5, 2024 20:54
@a13x5 a13x5 merged commit 4a91acb into Mirantis:main Sep 5, 2024
1 check passed
bnallapeta pushed a commit to bnallapeta/hmc that referenced this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Common k8s cluster verification wf/action
4 participants