-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e: plugin compatibility tooling and test cases
- Loading branch information
Chandra Pamuluri
authored and
chandra sekhar reddy pamuluri
committed
Mar 7, 2023
1 parent
7410306
commit 11122fe
Showing
8 changed files
with
237 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/e2e/plugins_compatibility/plugins_compatibility_helper_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// plugincompatibility provides plugins compatibility E2E test cases | ||
package plugincompatibility | ||
|
||
import ( | ||
"strings" | ||
|
||
. "github.com/onsi/gomega" | ||
|
||
"github.com/vmware-tanzu/tanzu-cli/test/e2e/framework" | ||
) | ||
|
||
// PluginsForCompatibilityTesting search for test-plugin-'s from the test central repository and returns all test-plugin-'s | ||
func PluginsForCompatibilityTesting(tf *framework.Framework) []string { | ||
list, err := tf.PluginCmd.SearchPlugins("") | ||
Expect(err).To(BeNil(), "should not occur any error while searching for plugins") | ||
testPlugins := make([]string, 0) | ||
for _, plugin := range list { | ||
if strings.HasPrefix(plugin.Name, framework.TestPluginsPrefix) { | ||
testPlugins = append(testPlugins, plugin.Name) | ||
} | ||
} | ||
return testPlugins | ||
} |
17 changes: 17 additions & 0 deletions
17
test/e2e/plugins_compatibility/plugins_compatibility_suite_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// plugincompatibility provides plugins compatibility E2E test cases | ||
package plugincompatibility_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestPluginsCompatibility(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "PluginsCompatibility Suite") | ||
} |
79 changes: 79 additions & 0 deletions
79
test/e2e/plugins_compatibility/plugins_compatibility_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// plugincompatibility provides plugins compatibility E2E test cases | ||
package plugincompatibility | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/vmware-tanzu/tanzu-plugin-runtime/log" | ||
|
||
"github.com/vmware-tanzu/tanzu-cli/test/e2e/framework" | ||
) | ||
|
||
// This test suite has test case for plugin compatibility use cases | ||
// Goal of these test suites is to validate the plugins built with different Tanzu CLI Runtime Library can co-exists and operate at the same time. | ||
// Below test suite, searches for test plugins (plugin name prefix with "test-plugin-") in the test central repository and | ||
// installs all test plugins, executes basic commands on all installed test plugins, and finally uninstalls all test plugins. | ||
// Each test plugin built using specific Tanzu CLI Runtime library versions. | ||
var _ = framework.CLICoreDescribe("[Tests:E2E][Feature:Plugin-Compatibility]", func() { | ||
var ( | ||
tf *framework.Framework | ||
plugins []string | ||
) | ||
// In the BeforeSuite sets the "features.global.central-repository" flag | ||
// and searches for the test-plugin-'s from the TANZU_CLI_E2E_TEST_CENTRAL_REPO_URL test central repository | ||
BeforeSuite(func() { | ||
tf = framework.NewFramework() | ||
err := tf.Config.ConfigSetFeatureFlag(framework.CentralRepositoryFeatureFlag, framework.True) | ||
Expect(err).To(BeNil()) | ||
// get all plugins with name prefix "test-plugin-" | ||
plugins = PluginsForCompatibilityTesting(tf) | ||
Expect(len(plugins)).NotTo(BeZero(), fmt.Sprintf("there are no test-plugin-'s in test central repo:%s , make sure its valid test central repo with test-plugins", os.Getenv(framework.TanzuCliE2ETestCentralRepositoryURL))) | ||
}) | ||
Context("Install plugins for plugins compatibility", func() { | ||
// Test case: install all test plugins | ||
It("Install all test plugins", func() { | ||
for _, plugin := range plugins { | ||
log.Infof("Installing test plugin:%s", plugin) | ||
err := tf.PluginCmd.InstallPlugin(plugin) | ||
Expect(err).To(BeNil(), fmt.Sprintf("should not occur any error while installing the test plugin: %s", plugin)) | ||
} | ||
}) | ||
}) | ||
Context("Test installed compatibility test-plugins", func() { | ||
// Test case: run basic commands on installed test plugins, to make sure works/co-exists with other plugins build with different runtime version | ||
It("run basic commands on the installed test-plugins", func() { | ||
for _, plugin := range plugins { | ||
info, err := tf.PluginCmd.ExecuteSubCommand(plugin + " info") | ||
Expect(err).To(BeNil(), "should not occur any error when plugin info command executed") | ||
Expect(info).NotTo(BeNil(), "there should be some out for plugin info command executed") | ||
} | ||
}) | ||
}) | ||
Context("Test installed compatibility test-plugins with hello-world command", func() { | ||
// Test case: run hello-world commands on installed test plugins, to make sure works/co-exists with other plugins build with different runtime version | ||
It("run hello-world commands on the installed test-plugins", func() { | ||
for _, plugin := range plugins { | ||
output, err := tf.PluginCmd.ExecuteSubCommand(plugin + " hello-world") | ||
Expect(err).To(BeNil(), "should not occur any error when plugin hello-world command executed") | ||
Expect(output).To(ContainSubstring("the command hello-world executed successfully")) | ||
} | ||
}) | ||
}) | ||
Context("Uninstall all installed compatibility test-plugins", func() { | ||
// Test case: uninstall all installed compatibility test-plugins | ||
It("uninstall all test-plugins", func() { | ||
for _, plugin := range plugins { | ||
log.Infof("Uninstalling test plugin: %s", plugin) | ||
err := tf.PluginCmd.UninstallPlugin(plugin) | ||
Expect(err).To(BeNil(), fmt.Sprintf("should not occur any error while uninstalling the test plugin: %s", plugin)) | ||
} | ||
}) | ||
}) | ||
}) |