github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/loggingtrait/coherenceworkload/coherence_loggingtrait_test.go (about) 1 // Copyright (c) 2021, 2022, 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 coherenceworkload 5 6 import ( 7 dump "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/clusterdump" 8 "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework" 9 "k8s.io/apimachinery/pkg/types" 10 "os" 11 "time" 12 13 . "github.com/onsi/ginkgo/v2" 14 . "github.com/onsi/gomega" 15 "github.com/verrazzano/verrazzano/tests/e2e/loggingtrait" 16 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 17 ) 18 19 const ( 20 shortWaitTimeout = 10 * time.Minute 21 shortPollingInterval = 10 * time.Second 22 23 componentsPath = "testdata/loggingtrait/coherenceworkload/coherence-logging-components.yaml" 24 applicationPath = "testdata/loggingtrait/coherenceworkload/coherence-logging-application.yaml" 25 applicationPodName = "carts-coh-0" 26 configMapName = "logging-stdout-carts-coh-coherence" 27 ) 28 29 var kubeConfig = os.Getenv("KUBECONFIG") 30 31 var ( 32 t = framework.NewTestFramework("coherenceworkload") 33 generatedNamespace = pkg.GenerateNamespace("sockshop-logging") 34 ) 35 36 var beforeSuite = t.BeforeSuiteFunc(func() { 37 loggingtrait.DeployApplication(namespace, istioInjection, componentsPath, applicationPath, applicationPodName, t) 38 beforeSuitePassed = true 39 }) 40 41 var _ = BeforeSuite(beforeSuite) 42 43 var failed = false 44 var beforeSuitePassed = false 45 var _ = t.AfterEach(func() { 46 failed = failed || CurrentSpecReport().Failed() 47 }) 48 49 var afterSuite = t.AfterSuiteFunc(func() { 50 if failed || !beforeSuitePassed { 51 dump.ExecuteBugReport(namespace) 52 } 53 loggingtrait.UndeployApplication(namespace, componentsPath, applicationPath, configMapName, t) 54 }) 55 56 var _ = AfterSuite(afterSuite) 57 58 var _ = t.Describe("Test coherence loggingtrait application", Label("f:app-lcm.oam", 59 "f:app-lcm.coherence-workload", 60 "f:app-lcm.logging-trait"), func() { 61 62 t.Context("for LoggingTrait.", func() { 63 // GIVEN the app is deployed and the pods are running 64 // WHEN the app pod is inspected 65 // THEN the container for the logging trait should exist 66 t.It("Verify that 'logging-stdout' container exists in the 'carts-coh-0' pod", func() { 67 Eventually(func() bool { 68 containerExists, err := pkg.DoesLoggingSidecarExist(kubeConfig, types.NamespacedName{Name: applicationPodName, Namespace: namespace}, "logging-stdout") 69 return containerExists && (err == nil) 70 }, shortWaitTimeout, shortPollingInterval).Should(BeTrue()) 71 }) 72 73 // GIVEN the app is deployed and the pods are running 74 // WHEN the configmaps in the app namespace are retrieved 75 // THEN the configmap for the logging trait should exist 76 t.It("Verify that 'logging-stdout-carts-coh-coherence' ConfigMap exists in the 'sockshop-logging' namespace", func() { 77 Eventually(func() bool { 78 configMap, err := pkg.GetConfigMap(configMapName, namespace) 79 return (configMap != nil) && (err == nil) 80 }, shortWaitTimeout, shortPollingInterval).Should(BeTrue()) 81 }) 82 }) 83 })