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