-
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 - config server tooling and test cases implementation
- Loading branch information
Chandra Pamuluri
committed
Mar 8, 2023
1 parent
4c2443d
commit 34e949d
Showing
7 changed files
with
148 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2023 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package config_e2e_test provides config command specific E2E test cases | ||
package config_e2e_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/vmware-tanzu/tanzu-cli/test/e2e/context" | ||
"github.com/vmware-tanzu/tanzu-cli/test/e2e/framework" | ||
) | ||
|
||
const ContextNameConfigPrefix = "config-k8s-" | ||
|
||
// This test suite tests the 'tanzu config server' use cases | ||
// As part of this suite, create a KIND cluster, and creates context's | ||
// tests the 'tanzu config server list' and 'tanzu config server delete' commands | ||
var _ = framework.CLICoreDescribe("[Tests:E2E][Feature:Config-Server]", func() { | ||
var ( | ||
tf *framework.Framework | ||
clusterInfo *framework.ClusterInfo | ||
contextNames []string | ||
) | ||
|
||
BeforeSuite(func() { | ||
tf = framework.NewFramework() | ||
// Create KIND cluster, which is used in test cases to create server's/context's | ||
clusterInfo = context.CreateKindCluster(tf, "config-e2e-"+framework.RandomNumber(4)) | ||
contextNames = make([]string, 0) | ||
}) | ||
Context("tanzu config server command test cases ", func() { | ||
// Test case: Create context for k8s target with kubeconfig and its context as input | ||
It("create context with kubeconfig and context", func() { | ||
ctxName := ContextNameConfigPrefix + framework.RandomString(4) | ||
err := tf.ContextCmd.CreateConextWithKubeconfig(ctxName, clusterInfo.KubeConfigPath, clusterInfo.ClusterContext) | ||
Expect(err).To(BeNil(), "context should create without any error") | ||
contextNames = append(contextNames, ctxName) | ||
}) | ||
// Test case: Create context for k8s target with "default" kubeconfig and its context only as input value | ||
It("create context with kubeconfig and context", func() { | ||
ctxName := "context-defaultConfig-" + framework.RandomString(4) | ||
err := tf.ContextCmd.CreateContextWithDefaultKubeconfig(ctxName, clusterInfo.ClusterContext) | ||
Expect(err).To(BeNil(), "context should create without any error") | ||
contextNames = append(contextNames, ctxName) | ||
}) | ||
// Test case: test 'tanzu config server list' command, should list all contexts created as servers | ||
It("list servers should have all added contexts", func() { | ||
list, err := tf.Config.ConfigServerList() | ||
Expect(err).To(BeNil(), "config server list command should list available servers") | ||
Expect(len(list)).To(Equal(len(contextNames)), "list context should have all contexts (as servers) added in previous tests") | ||
}) | ||
// Test case: test 'tanzu config server delete' command, make sure to delete all context's created in previous test cases | ||
It("delete server command", func() { | ||
for _, ctx := range contextNames { | ||
err := tf.Config.ConfigServerDelete(ctx) | ||
Expect(err).To(BeNil(), "delete server should delete server without any error") | ||
} | ||
list := context.GetAvailableServers(tf, contextNames) | ||
Expect(len(list)).To(Equal(0), "delete server should have deleted all given server names") | ||
}) | ||
// Test case: (negative test) test 'tanzu context delete' command for context name which is not exists | ||
It("delete server which is not exists", func() { | ||
err := tf.Config.ConfigServerDelete(framework.RandomString(4)) | ||
Expect(err).ToNot(BeNil()) | ||
}) | ||
}) | ||
AfterSuite(func() { | ||
// delete the KIND cluster which was created in the suite setup | ||
_, err := tf.KindCluster.DeleteCluster(clusterInfo.Name) | ||
Expect(err).To(BeNil(), "kind cluster should be deleted without any error") | ||
}) | ||
}) |
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
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