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: plugin sync e2e test implementation for TMC target #229

Merged
merged 1 commit into from
May 5, 2023

Conversation

chandrareddyp
Copy link
Contributor

@chandrareddyp chandrareddyp commented Apr 24, 2023

What this PR does / why we need it

This PR has E2E test cases and tooling implementations for TMC specific use cases. It uses rodolpheche/wiremock HTTP mock server to mock TMC HTTP calls. CLI Core code has been updated to skip HTTPS hard coding when the environment variable TANZU_CLI_E2E_TEST_ENVIRONMENT is set to true, since CLI Core supports only HTTPS calls with well know CA, we have created a story to support HTTPS with self-signed certificates.
To run these tests locally, you need to set the TANZU_API_TOKEN with TMC API token, then call the target make e2e-plugin-sync-tmc

Which issue(s) this PR fixes

Fixes # NA

Describe testing done for PR

❯ echo TANZU_API_TOKEN=<tmc-api-token>
❯ make e2e-plugin-sync-tmc
=== RUN   TestPluginSyncLifecycle
Running Suite: Plugin-Sync-TMC-Lifecycle E2E Test Suite - /Users/cpamuluri/tkg/tasks/e2e_tests/separate_module/tanzu-cli/test/e2e/plugin_sync/tmc
=================================================================================================================================================
Random Seed: 1682829266

Will run 31 of 31 specs
[i] Executing command: tanzu plugin source update default --uri localhost:9876/tanzu-cli/plugins/central:small
[i] Executing command: tanzu plugin group search -o json
[i] Executing command: tanzu plugin search -o json
[i] Executing command: tanzu config init
[i] Executing command: tanzu plugin source update default --uri localhost:9876/tanzu-cli/plugins/central:small
•[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
•[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-srDG --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] All required plugins are already installed and up-to-date
[i] context plugin-sync-tmc-srDG created successfully
[i] Executing command: tanzu context list -o json
•[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context delete plugin-sync-tmc-srDG --yes
[i] context plugin-sync-tmc-srDG deleted successfully
[i] Executing command: docker container stop wiremock
•[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
•[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-22Um --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] Installing plugin 'account:v9.9.9' with target 'mission-control'
[i] Installing plugin 'apply:v9.9.9' with target 'mission-control'
[i] Installing plugin 'audit:v9.9.9' with target 'mission-control'
[i] Successfully installed all required plugins
[i] context plugin-sync-tmc-22Um created successfully
[i] Executing command: tanzu context list -o json
•[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu plugin delete account --yes --target mission-control
[i] Executing command: tanzu plugin list -o json
[i] Executing command: tanzu plugin sync
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context delete plugin-sync-tmc-22Um --yes
[i] context plugin-sync-tmc-22Um deleted successfully
[i] Executing command: tanzu plugin list -o json
[i] Executing command: docker container stop wiremock
•[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
•[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-ecX0 --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] Installing plugin 'account:v9.9.9' with target 'mission-control'
[i] Installing plugin 'apply:v9.9.9' with target 'mission-control'
[!] unable to automatically sync the plugins from target context. Please run 'tanzu plugin sync' command to sync plugins manually
[i] context plugin-sync-tmc-ecX0 created successfully
[i] Executing command: tanzu context list -o json
•[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu plugin sync
[x] error while executing command:'%s plugin sync', error:'error while running 'tanzu plugin sync', stdOut: , stdErr: [i] Checking for required plugins...
[x] : unable to find plugin 'audit' for target 'mission-control'
, err: exit status 1' stdErr:'[i] Checking for required plugins...
[x] : unable to find plugin 'audit' for target 'mission-control'
' stdOut: ''
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context delete plugin-sync-tmc-ecX0 --yes
[i] context plugin-sync-tmc-ecX0 deleted successfully
[i] Executing command: docker container stop wiremock
••[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-p3bu --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] Installing plugin 'account:v9.9.9' with target 'mission-control'
[i] Installing plugin 'apply:v9.9.9' with target 'mission-control'
[i] Installing plugin 'audit:v9.9.9' with target 'mission-control'
[i] Successfully installed all required plugins
[i] context plugin-sync-tmc-p3bu created successfully
[i] Executing command: tanzu context list -o json
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-qLPL --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] Installing plugin 'cluster:v9.9.9' with target 'mission-control'
[i] Installing plugin 'clustergroup:v9.9.9' with target 'mission-control'
[i] Installing plugin 'continuousdelivery:v9.9.9' with target 'mission-control'
[i] Successfully installed all required plugins
[i] context plugin-sync-tmc-qLPL created successfully
[i] Executing command: tanzu context list -o json
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context use plugin-sync-tmc-p3bu
[i] Executing command: tanzu context list -o json
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context delete plugin-sync-tmc-p3bu --yes
[i] context plugin-sync-tmc-p3bu deleted successfully
[i] Executing command: tanzu context delete plugin-sync-tmc-qLPL --yes
[i] context plugin-sync-tmc-qLPL deleted successfully
[i] Executing command: docker container stop wiremock
•[i] Executing command: docker info
[i] Executing command: kind create cluster --name plugin-sync-k8s-9075
[i] Executing command: docker info
•[i] Executing command: kubectl --context kind-plugin-sync-k8s-9075 apply -f ../../framework/config/cli.tanzu.vmware.com_cliplugins.yaml
[i] the config:../../framework/config/cli.tanzu.vmware.com_cliplugins.yaml applied successfully to context:kind-plugin-sync-k8s-9075
[i] Executing command: kubectl --context kind-plugin-sync-k8s-9075 apply -f /Users/cpamuluri/.tanzu-cli-e2e/temp/cr_cluster_kubernetes_v9.9.9.yaml
[i] the config:/Users/cpamuluri/.tanzu-cli-e2e/temp/cr_cluster_kubernetes_v9.9.9.yaml applied successfully to context:kind-plugin-sync-k8s-9075
[i] Executing command: kubectl --context kind-plugin-sync-k8s-9075 apply -f /Users/cpamuluri/.tanzu-cli-e2e/temp/cr_feature_kubernetes_v9.9.9.yaml
[i] the config:/Users/cpamuluri/.tanzu-cli-e2e/temp/cr_feature_kubernetes_v9.9.9.yaml applied successfully to context:kind-plugin-sync-k8s-9075
[i] Executing command: kubectl --context kind-plugin-sync-k8s-9075 apply -f /Users/cpamuluri/.tanzu-cli-e2e/temp/cr_kubernetes-release_kubernetes_v9.9.9.yaml
[i] the config:/Users/cpamuluri/.tanzu-cli-e2e/temp/cr_kubernetes-release_kubernetes_v9.9.9.yaml applied successfully to context:kind-plugin-sync-k8s-9075
•[i] Executing command: tanzu context create --kubeconfig /Users/cpamuluri/.tanzu-cli-e2e/.kube/config --kubecontext kind-plugin-sync-k8s-9075 --name plugin-sync-k8s-2rUo
[i] context plugin-sync-k8s-2rUo created successfully
[i] Executing command: tanzu context list -o json
•[i] Executing command: tanzu plugin list -o json
•[i] Executing command: docker container stop wiremock
[i] Executing command: docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock -v /Users/cpamuluri/.tanzu-cli-e2e/temp/tmc:/home/wiremock rodolpheche/wiremock:2.25.1
•[i] Executing command: tanzu context create --endpoint http://localhost:8080 --name plugin-sync-tmc-my3X --staging  --force-csp true
[i] out:
 stdErr:[i] API token env var is set
[ok] successfully created a TMC context
[i] Checking for required plugins...
[i] Installing plugin 'account:v9.9.9' with target 'mission-control'
[i] Installing plugin 'apply:v9.9.9' with target 'mission-control'
[i] Installing plugin 'audit:v9.9.9' with target 'mission-control'
[i] Successfully installed all required plugins
[i] context plugin-sync-tmc-my3X created successfully
[i] Executing command: tanzu context list -o json
•[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context use plugin-sync-k8s-2rUo
[i] Executing command: tanzu context list -o json
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu plugin delete cluster --yes --target kubernetes
[i] Executing command: tanzu plugin list -o json
[i] Executing command: tanzu plugin sync
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context use plugin-sync-tmc-my3X
[i] Executing command: tanzu context list -o json
[i] Executing command: tanzu plugin list -o json
•[i] Executing command: tanzu context delete plugin-sync-tmc-my3X --yes
[i] context plugin-sync-tmc-my3X deleted successfully
[i] Executing command: docker container stop wiremock
[i] Executing command: tanzu context delete plugin-sync-k8s-2rUo --yes
[i] context plugin-sync-k8s-2rUo deleted successfully
[i] Executing command: docker info
[i] Executing command: kind delete cluster --name plugin-sync-k8s-9075
•

Ran 31 of 31 Specs in 131.942 seconds
SUCCESS! -- 31 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestPluginSyncLifecycle (131.95s)
PASS
coverage: [no statements]
ok      github.com/vmware-tanzu/tanzu-cli/test/e2e/plugin_sync/tmc      132.539s     coverage: [no statements]
❯ 

Release note

Plugin sync E2E test cases and tooling added for TMC target

Additional information

Special notes for your reviewer

@chandrareddyp chandrareddyp requested a review from a team as a code owner April 24, 2023 21:51
@chandrareddyp chandrareddyp changed the title E2E: plugin sync e2e test implementation WIP: E2E: plugin sync e2e test implementation Apr 25, 2023
@chandrareddyp chandrareddyp force-pushed the e2e-tmc-plugin-sync branch 6 times, most recently from 31144e2 to c20b48b Compare May 1, 2023 12:29
@chandrareddyp chandrareddyp changed the title WIP: E2E: plugin sync e2e test implementation E2E: plugin sync e2e test implementation for TMC target May 1, 2023
@chandrareddyp chandrareddyp requested a review from anujc25 May 1, 2023 16:31
@chandrareddyp chandrareddyp force-pushed the e2e-tmc-plugin-sync branch 4 times, most recently from e7a5c62 to 543188d Compare May 4, 2023 17:51
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

This looks great @chandrareddyp. I have added a few minor comments but overall looks good.

We should add a TMC test case where the endpoint gets updated to return additional plugins, and CLI should be able to sync the newer plugins with tanzu plugin sync.

test/e2e/framework/framework_helper.go Outdated Show resolved Hide resolved
test/e2e/plugin_sync/tmc/plugin_sync_tmc_lifecycle_test.go Outdated Show resolved Hide resolved
@chandrareddyp chandrareddyp force-pushed the e2e-tmc-plugin-sync branch 3 times, most recently from 1b031bf to fc1591e Compare May 4, 2023 22:26
@chandrareddyp
Copy link
Contributor Author

We should add a TMC test case where the endpoint gets updated to return additional plugins, and CLI should be able to sync the newer plugins with tanzu plugin sync.

Added "Use Case 5: Update the TMC endpoint with additional plugins, and ensure that the plugin sync updates the latest additional plugins."

Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

LGTM. This is great. Thanks for adding these important tests.

@chandrareddyp chandrareddyp merged commit c96c455 into vmware-tanzu:main May 5, 2023
vuil pushed a commit to vuil/tanzu-cli that referenced this pull request May 16, 2023
…u#229)

Co-authored-by: Chandra Pamuluri <cpamuluri@cpamuluri-a01.vmware.com>
@marckhouzam marckhouzam added this to the v0.90.0 milestone Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants