From 659e0cdd6e1c1451aa4d103bc443c380465aebae Mon Sep 17 00:00:00 2001 From: Anuj Chaudhari Date: Wed, 2 Oct 2024 11:50:53 -0700 Subject: [PATCH] Update e2e tests --- .github/workflows/cli-coexistence_tests.yaml | 1 - .github/workflows/cli_core_e2e_test.yaml | 11 ++++++++++- test/e2e/Makefile | 8 +++++++- test/e2e/README.md | 2 +- test/e2e/framework/framework_constants.go | 1 + .../plugins_compatibility_suite_test.go | 7 ++++++- .../plugins_compatibility_test.go | 2 +- 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cli-coexistence_tests.yaml b/.github/workflows/cli-coexistence_tests.yaml index fae187c54..c66d9ddba 100644 --- a/.github/workflows/cli-coexistence_tests.yaml +++ b/.github/workflows/cli-coexistence_tests.yaml @@ -10,7 +10,6 @@ on: - "v[0-9]+.[0-9]+.[0-9]+-*" - "test/e2e/framework/v[0-9]+.[0-9]+.[0-9]+" - "test/e2e/framework/v[0-9]+.[0-9]+.[0-9]+-*" - jobs: build-and-run: name: Tanzu CLI Coexistence Tests diff --git a/.github/workflows/cli_core_e2e_test.yaml b/.github/workflows/cli_core_e2e_test.yaml index ad7737a5f..d18a70fd1 100644 --- a/.github/workflows/cli_core_e2e_test.yaml +++ b/.github/workflows/cli_core_e2e_test.yaml @@ -10,7 +10,9 @@ on: - "v[0-9]+.[0-9]+.[0-9]+-*" - "test/e2e/framework/v[0-9]+.[0-9]+.[0-9]+" - "test/e2e/framework/v[0-9]+.[0-9]+.[0-9]+-*" - +env: + TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD: ${{ secrets.GH_TOKEN_FOR_GHCR }} + jobs: build: name: Tanzu CLI Core E2E Tests @@ -38,6 +40,13 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN_FOR_GHCR }} + - name: Setup gcloud account env: GCP_SA: ${{ secrets.GCP_SA }} diff --git a/test/e2e/Makefile b/test/e2e/Makefile index 2605422f1..6ccb0cb76 100644 --- a/test/e2e/Makefile +++ b/test/e2e/Makefile @@ -17,7 +17,11 @@ TANZU_CLI_TMC_UNSTABLE_URL = "" endif ifndef TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL -TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL = gcr.io/eminent-nation-87317/tanzu-cli/test/v1/plugins/plugin-inventory:latest +TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL = ghcr.io/vmware-tanzu/tanzu-cli/test/v1/plugins/plugin-inventory:latest +endif + +ifndef TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD +TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD = "" endif ifndef TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_HOST @@ -85,6 +89,8 @@ e2e-plugin-compatibility-tests: export TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=$(TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL) ; \ export TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER="No" ; \ export TANZU_CLI_EULA_PROMPT_ANSWER="Yes" ; \ + export TANZU_CLI_AUTHENTICATED_REGISTRY=ghcr.io ; \ + export TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD=${TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD}; \ ${GINKGO} --keep-going --output-dir ${ROOT_DIR}/test/e2e/testresults --json-report=results.json --keep-separate-reports --race --nodes=1 ${GOTEST_VERBOSE} -r ${ROOT_DIR}/test/e2e/plugins_compatibility --trace > /tmp/out && { cat /tmp/out | grep -Ev 'STEP:|seconds|.go:'; rm /tmp/out; } || { exit_code=$$?; cat /tmp/out | grep -Ev 'STEP:|seconds|.go:'; rm /tmp/out; exit $$exit_code; } \ .PHONY: e2e-plugin-lifecycle-tests ## Execute CLI Core Plugin life cycle E2E test cases diff --git a/test/e2e/README.md b/test/e2e/README.md index 7b63510d8..e0013c3bd 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -243,7 +243,7 @@ the current CLI supports all older plugins and all plugins We have created a github repository `https://github.com/chandrareddyp/tanzu-cli-test-plugins` to host test plugins with different CLI Runtime versions which supported by current CLI Core, and -these test plugins are published manually to gcr.io/eminent-nation-87317/tanzu-cli/test/v1/plugins/plugin-inventory:latest +these test plugins are published manually to ghcr.io/vmware-tanzu/tanzu-cli/test/v1/plugins/plugin-inventory:latest using publish tooling, these test plugins used during e2e plugin compatibility test execution. ## How and when E2E tests are executed diff --git a/test/e2e/framework/framework_constants.go b/test/e2e/framework/framework_constants.go index 5d4d86baa..dea6cb5e7 100644 --- a/test/e2e/framework/framework_constants.go +++ b/test/e2e/framework/framework_constants.go @@ -57,6 +57,7 @@ const ( // Central repository TanzuCliE2ETestCentralRepositoryURL = "TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL" + TanzuCliE2ETestCentralRepositoryPassword = "TANZU_CLI_E2E_TEST_CENTRAL_REPO_PASSWORD" TanzuCliE2ETestLocalCentralRepositoryURL = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL" TanzuCliE2ETestLocalCentralRepositoryPluginDiscoveryImageSignaturePublicKeyPath = "TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH" TanzuCliPluginDiscoveryImageSignaturePublicKeyPath = "TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH" diff --git a/test/e2e/plugins_compatibility/plugins_compatibility_suite_test.go b/test/e2e/plugins_compatibility/plugins_compatibility_suite_test.go index ac231fb5e..684937f4e 100644 --- a/test/e2e/plugins_compatibility/plugins_compatibility_suite_test.go +++ b/test/e2e/plugins_compatibility/plugins_compatibility_suite_test.go @@ -31,9 +31,14 @@ var ( var _ = BeforeSuite(func() { tf = framework.NewFramework() + // Login to airgapped repository + dockerloginCmd := fmt.Sprintf("docker login %s --username USERNAME --password %s", os.Getenv(framework.TanzuCliE2ETestCentralRepositoryURL), os.Getenv(framework.TanzuCliE2ETestCentralRepositoryPassword)) + _, _, err := tf.Exec.Exec(dockerloginCmd) + Expect(err).To(BeNil()) + // setup the test central repo centralURI := os.Getenv(framework.TanzuCliE2ETestCentralRepositoryURL) - err := framework.UpdatePluginDiscoverySource(tf, centralURI) + err = framework.UpdatePluginDiscoverySource(tf, centralURI) Expect(err).To(BeNil(), "should not get any error for plugin source update") // get all plugins with name prefix "test-plugin-" diff --git a/test/e2e/plugins_compatibility/plugins_compatibility_test.go b/test/e2e/plugins_compatibility/plugins_compatibility_test.go index 9c5cfd35a..ffe149a52 100644 --- a/test/e2e/plugins_compatibility/plugins_compatibility_test.go +++ b/test/e2e/plugins_compatibility/plugins_compatibility_test.go @@ -24,7 +24,7 @@ import ( // Each test plugin built using specific Tanzu CLI Runtime library versions. // Here are sequence of test cases in below suite: // a. Before installing test plugins, uninstall test plugins (if any installed already) and verify status using plugin list -// b. install all test plugins from repo gcr.io/eminent-nation-87317/tanzu-cli/test/v1/plugins/plugin-inventory:latest +// b. install all test plugins from repo ghcr.io/vmware-tanzu/tanzu-cli/test/v1/plugins/plugin-inventory:latest // c. list all plugins and make sure all above installed test plugins are listed with status "installed" // d. run basic commands on installed test plugins, to make sure works/co-exists with other plugins build with different runtime version // e. run hello-world commands on installed test plugins, to make sure works/co-exists with other plugins build with different runtime version