github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/verify-none-profile/none_profile_test.go (about) 1 // Copyright (c) 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package verifynoneprofile 5 6 import ( 7 . "github.com/onsi/gomega" 8 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 9 "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework" 10 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 11 "time" 12 ) 13 14 var t = framework.NewTestFramework("none-profile") 15 16 var _ = t.BeforeSuiteFunc(beforesuite) 17 18 const ( 19 waitTimeout = 5 * time.Minute 20 pollingInterval = 5 * time.Second 21 ) 22 23 // allowedNamespaces holds the list of namespaces permissible for installation with the default 'none' profile. 24 // Any other namespace not mentioned here is considered unnecessary 25 var allowedNamespaces = []string{ 26 "default", "kube-system", "kube-node-lease", "kube-public", 27 "cattle-system", "monitoring", "local-path-storage", "metallb-system", 28 "verrazzano-install", "verrazzano-system", 29 } 30 31 var beforesuite = t.BeforeSuiteFunc(func() { 32 }) 33 34 var _ = t.Describe("Verify None Profile Install", func() { 35 t.It("Should have the none profile installed and in Ready state", func() { 36 // Verify that none profile installation succeeded 37 Eventually(func() (bool, error) { 38 isReady, err := pkg.VzReadyV1beta1() 39 return isReady, err 40 }, waitTimeout, pollingInterval).Should(BeTrue(), "Expected Verrazzano CR to be in Ready state") 41 }) 42 }) 43 44 var _ = t.Describe("Verify Namespaces", func() { 45 t.It("Should have only certain set of namespaces", func() { 46 allowedNamespacesMap := make(map[string]bool) 47 for _, item := range allowedNamespaces { 48 allowedNamespacesMap[item] = true 49 } 50 51 ns, err := pkg.ListNamespaces(metav1.ListOptions{}) 52 Expect(err).ShouldNot(HaveOccurred()) 53 54 failures := []string{} 55 for _, item := range ns.Items { 56 _, isAllowed := allowedNamespacesMap[item.Name] 57 if !isAllowed { 58 failures = append(failures, item.Name) 59 } 60 } 61 Expect(failures).To(BeEmpty(), "Namespaces not allowed: %v, Allowed namespaces are only %v", failures, allowedNamespaces) 62 }) 63 })