Skip to content

Commit

Permalink
Update Tanzu CLI coexistence tests CI workflow and the tests
Browse files Browse the repository at this point in the history
- Starting the local OCI registry have dependency on tanzu CLI binary to add the test local central repository certs to the config before starting the local OCI registry.
- Updated the co-existence tests to use the test local central repository certs

Signed-off-by: Prem Kumar Kalle <[email protected]>
  • Loading branch information
prkalle committed May 2, 2023
1 parent 2ca7fc0 commit 83a45c1
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/cli-coexistence_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1

- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go

- name: go cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup dependencies
run: |
make tools
echo "${PWD}/hack/tools/bin" >> $GITHUB_PATH
echo "${PWD}/bin" >> $GITHUB_PATH
- name: Build CLI Core
run: |
make build
- name: Start local OCI registry
run: |
make start-test-central-repo
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_VERSION = v0.28.1
endif

ifndef TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER
TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER = yes
TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER = no
endif

.PHONY: build-cli-coexistence ## Build CLI Coexistence docker image
Expand All @@ -316,7 +316,6 @@ build-cli-coexistence: start-test-central-repo
--build-arg TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_VERSION=$(TANZU_CLI_COEXISTENCE_LEGACY_TANZU_CLI_VERSION) \
--build-arg TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) \
--build-arg TANZU_CLI_PRE_RELEASE_REPO_IMAGE=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) \
--build-arg TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) \
--build-arg TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER=$(TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER) \
-t cli-coexistence \
.
Expand All @@ -333,7 +332,10 @@ cli-coexistence-tests:start-test-central-repo
-e TANZU_CLI_PRE_RELEASE_REPO_IMAGE=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) \
-e TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_URL) \
-e TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER=$(TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER) \
-e TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_HOST=$(TANZU_CLI_E2E_TEST_LOCAL_CENTRAL_REPO_HOST) \
-v $(ROOT_DIR):/tmp/tanzu-cli/ \
-v $(ROOT_DIR)/hack/central-repo/certs:/localhost_certs/ \
-v $(ROOT_DIR)/hack/central-repo/cosign-key-pair:/cosign-key-pair/ \
-w /tmp/tanzu-cli/ \
cli-coexistence \
${GO} test ${GOTEST_VERBOSE} ./test/e2e/coexistence... --ginkgo.v --ginkgo.randomize-all --ginkgo.trace --ginkgo.json-report=coexistence-tests.json
7 changes: 7 additions & 0 deletions test/e2e/coexistence/cli_coexistence_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ var (

e2eTestLocalCentralRepoURL string

e2eTestLocalCentralRepoCACertPath string
e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath string

// PluginsForLegacyTanzuCLICoexistenceTests is list of plugins (which are published in local central repo) used in plugin life cycle test cases
PluginsForLegacyTanzuCLICoexistenceTests []*framework.PluginInfo

Expand Down Expand Up @@ -57,6 +60,10 @@ var _ = ginkgo.BeforeSuite(func() {
newTanzuCLIVersion = os.Getenv(framework.CLICoexistenceNewTanzuCLIVersion)
gomega.Expect(newTanzuCLIVersion).NotTo(gomega.BeEmpty(), fmt.Sprintf("new tanzu CLI %s should be set", framework.CLICoexistenceNewTanzuCLIVersion))

// test local central repository CA certs are mounted at path /cosign-key-pair in docker
e2eTestLocalCentralRepoCACertPath = "/localhost_certs/localhost.crt"
e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath = "/cosign-key-pair/cosign.pub"

// verify the legacy Tanzu CLI installation path is set
legacyTanzuCLIInstallationPath := os.Getenv(framework.CLICoexistenceLegacyTanzuCLIInstallationPath)
gomega.Expect(legacyTanzuCLIInstallationPath).NotTo(gomega.BeEmpty(), fmt.Sprintf("legacy tanzu CLI installation path %s should be set", framework.CLICoexistenceLegacyTanzuCLIInstallationPath))
Expand Down
46 changes: 44 additions & 2 deletions test/e2e/coexistence/cli_coexistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
package coexistence_test

import (
"fmt"
"os"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

pluginlifecyclee2e "github.com/vmware-tanzu/tanzu-cli/test/e2e/plugin_lifecycle"

"github.com/vmware-tanzu/tanzu-cli/test/e2e/framework"
pluginlifecyclee2e "github.com/vmware-tanzu/tanzu-cli/test/e2e/plugin_lifecycle"
)

var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
Expand Down Expand Up @@ -87,6 +89,12 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
gomega.Expect(version).To(gomega.ContainSubstring(newTanzuCLIVersion))
gomega.Expect(err).To(gomega.BeNil())

// set up the test local central repository host CA cert in the config file
setTestLocalCentralRepoCertConfig([]framework.E2EOption{framework.WithTanzuCommandPrefix(framework.TzPrefix)})

// set up the local central repository discovery image signature public key path
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

ginkgo.By("Update plugin discovery source with test central repo")
_, err = tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL}, framework.WithTanzuCommandPrefix(framework.TzPrefix))
gomega.Expect(err).To(gomega.BeNil(), "should not get any error for plugin source update")
Expand Down Expand Up @@ -156,6 +164,12 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
gomega.Expect(version).To(gomega.ContainSubstring(newTanzuCLIVersion))
gomega.Expect(err).To(gomega.BeNil())

// set up the test local central repository host CA cert in the config file
setTestLocalCentralRepoCertConfig([]framework.E2EOption{})

// set up the local central repository discovery image signature public key path
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

ginkgo.By("Update plugin discovery source with test central repo")
_, err = tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL})
gomega.Expect(err).To(gomega.BeNil(), "should not get any error for plugin source update")
Expand Down Expand Up @@ -220,6 +234,12 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
gomega.Expect(version).To(gomega.ContainSubstring(newTanzuCLIVersion))
gomega.Expect(err).To(gomega.BeNil())

// set up the test local central repository host CA cert in the config file
setTestLocalCentralRepoCertConfig([]framework.E2EOption{})

// set up the local central repository discovery image signature public key path
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

ginkgo.By("Update plugin discovery source with test central repo")
_, err = tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL})
gomega.Expect(err).To(gomega.BeNil(), "should not get any error for plugin source update")
Expand Down Expand Up @@ -294,6 +314,12 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
gomega.Expect(version).To(gomega.ContainSubstring(newTanzuCLIVersion))
gomega.Expect(err).To(gomega.BeNil())

// set up the test local central repository host CA cert in the config file
setTestLocalCentralRepoCertConfig([]framework.E2EOption{framework.WithTanzuCommandPrefix(framework.TzPrefix)})

// set up the local central repository discovery image signature public key path
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

ginkgo.By("Update plugin discovery source with test central repo")
_, err = tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL}, framework.WithTanzuCommandPrefix(framework.TzPrefix))
gomega.Expect(err).To(gomega.BeNil(), "should not get any error for plugin source update")
Expand Down Expand Up @@ -368,6 +394,12 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
gomega.Expect(version).To(gomega.ContainSubstring(newTanzuCLIVersion))
gomega.Expect(err).To(gomega.BeNil())

// set up the test local central repository host CA cert in the config file
setTestLocalCentralRepoCertConfig([]framework.E2EOption{})

// set up the local central repository discovery image signature public key path
os.Setenv("TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_PUBLIC_KEY_PATH", e2eTestLocalCentralRepoPluginDiscoveryImageSignaturePublicKeyPath)

ginkgo.By("Update plugin discovery source with test central repo")
_, err = tf.PluginCmd.UpdatePluginDiscoverySource(&framework.DiscoveryOptions{Name: "default", SourceType: framework.SourceType, URI: e2eTestLocalCentralRepoURL})
gomega.Expect(err).To(gomega.BeNil(), "should not get any error for plugin source update")
Expand Down Expand Up @@ -522,3 +554,13 @@ var _ = ginkgo.Describe("CLI Coexistence Tests", func() {
})

})

func setTestLocalCentralRepoCertConfig(options []framework.E2EOption) {
e2eTestLocalCentralRepoPluginHost := os.Getenv(framework.TanzuCliE2ETestLocalCentralRepositoryHost)
gomega.Expect(e2eTestLocalCentralRepoPluginHost).NotTo(gomega.BeEmpty(), fmt.Sprintf("environment variable %s should set with local central repository host", framework.TanzuCliE2ETestLocalCentralRepositoryHost))

// set up the CA cert fort local central repository
_ = tf.Config.ConfigCertDelete(e2eTestLocalCentralRepoPluginHost, options...)
_, err := tf.Config.ConfigCertAdd(&framework.CertAddOptions{Host: e2eTestLocalCentralRepoPluginHost, CACertificatePath: e2eTestLocalCentralRepoCACertPath, SkipCertVerify: "false", Insecure: "false"}, options...)
gomega.Expect(err).To(gomega.BeNil())
}
2 changes: 1 addition & 1 deletion test/e2e/framework/config_lifecycle_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type ConfigCertOps interface {
ConfigCertAdd(certAddOpts *CertAddOptions, opts ...E2EOption) (string, error)

// ConfigCertDelete deletes cert config for a host, and returns error info
ConfigCertDelete(hostname string, opts ...E2EOption) error
ConfigCertDelete(host string, opts ...E2EOption) error
}

type ConfigCmdOps interface {
Expand Down

0 comments on commit 83a45c1

Please sign in to comment.