github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/examples/bobsbooks/bobs_books_test.go (about)

     1  // Copyright (c) 2021, 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 bobsbooks
     5  
     6  import (
     7  	"fmt"
     8  	"time"
     9  
    10  	. "github.com/onsi/ginkgo/v2"
    11  	. "github.com/onsi/gomega"
    12  	"github.com/verrazzano/verrazzano/pkg/k8s/resource"
    13  	"github.com/verrazzano/verrazzano/pkg/k8sutil"
    14  	"github.com/verrazzano/verrazzano/tests/e2e/pkg"
    15  	dump "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/clusterdump"
    16  	"github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework"
    17  	"github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework/metrics"
    18  	v1 "k8s.io/api/core/v1"
    19  	"k8s.io/apimachinery/pkg/api/errors"
    20  )
    21  
    22  const (
    23  	shortWaitTimeout         = 10 * time.Minute
    24  	shortPollingInterval     = 10 * time.Second
    25  	longWaitTimeout          = 20 * time.Minute
    26  	longPollingInterval      = 20 * time.Second
    27  	imagePullWaitTimeout     = 40 * time.Minute
    28  	imagePullPollingInterval = 30 * time.Second
    29  
    30  	trait                  = "robert-helidon-trait"
    31  	helidonService         = "robert-helidon"
    32  	bobsService            = "bobbys-helidon-stock-application"
    33  	frontEndRepoCreds      = "bobbys-front-end-weblogic-credentials"
    34  	bookstoreWeblogicCreds = "bobs-bookstore-weblogic-credentials"
    35  
    36  	// application specific constants
    37  	robertCoh            = "robert-coh"
    38  	bobsBookStore        = "bobs-bookstore"
    39  	robertsCoherence     = "roberts-coherence"
    40  	bobbysFrontEnd       = "bobbys-front-end"
    41  	managedServer1       = "managed-server1"
    42  	fluentdStdoutSidecar = "fluentd-stdout-sidecar"
    43  
    44  	// various labels
    45  	k8sLabelDomainUID        = "kubernetes.labels.weblogic_domainUID"
    46  	k8sLabelWLServerName     = "kubernetes.labels.weblogic_serverName"
    47  	k8sPodName               = "kubernetes.pod_name"
    48  	k8sLabelContainerName    = "kubernetes.container_name"
    49  	K8sLabelCoherenceCluster = "kubernetes.labels.coherenceCluster"
    50  )
    51  
    52  var (
    53  	t                  = framework.NewTestFramework("bobsbooks")
    54  	generatedNamespace = pkg.GenerateNamespace("bobs-books")
    55  	expectedPods       = []string{
    56  		"bobbys-front-end-adminserver",
    57  		"bobs-bookstore-adminserver",
    58  		"bobbys-coherence-0",
    59  		"roberts-coherence-0",
    60  		"roberts-coherence-1",
    61  		"bobbys-helidon-stock-application",
    62  		"robert-helidon",
    63  		"mysql"}
    64  	host        = ""
    65  	metricsTest pkg.MetricsTest
    66  	appName     = "bobs-books"
    67  )
    68  var isMinVersion140 bool
    69  var beforeSuite = t.BeforeSuiteFunc(func() {
    70  	if !skipDeploy {
    71  		start := time.Now()
    72  		deployBobsBooksExample(namespace)
    73  		metrics.Emit(t.Metrics.With("deployment_elapsed_time", time.Since(start).Milliseconds()))
    74  	}
    75  
    76  	t.Logs.Info("Container image pull check")
    77  	Eventually(func() bool {
    78  		return pkg.ContainerImagePullWait(namespace, expectedPods)
    79  	}, imagePullWaitTimeout, imagePullPollingInterval).Should(BeTrue())
    80  
    81  	t.Logs.Info("Bobs Books Application: check expected pods are running")
    82  	Eventually(func() bool {
    83  		result, err := pkg.PodsRunning(namespace, expectedPods)
    84  		if err != nil {
    85  			AbortSuite(fmt.Sprintf("One or more pods are not running in the namespace: %v, error: %v", namespace, err))
    86  		}
    87  		return result
    88  	}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: Pods are not ready")
    89  
    90  	t.Logs.Info("Bobs Books Application: check expected Services are running")
    91  	Eventually(func() bool {
    92  		result, err := pkg.DoesServiceExist(namespace, helidonService)
    93  		if err != nil {
    94  			AbortSuite(fmt.Sprintf("App Service %s is not running in the namespace: %v, error: %v", helidonService, namespace, err))
    95  		}
    96  		return result
    97  	}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: Services are not ready")
    98  
    99  	Eventually(func() bool {
   100  		result, err := pkg.DoesServiceExist(namespace, bobsService)
   101  		if err != nil {
   102  			AbortSuite(fmt.Sprintf("App Service %s is not running in the namespace: %v, error: %v", bobsService, namespace, err))
   103  		}
   104  		return result
   105  	}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: Services are not ready")
   106  
   107  	t.Logs.Info("Bobs Books Application: check expected VirtualService is ready")
   108  	Eventually(func() bool {
   109  		result, err := pkg.DoesVirtualServiceExist(namespace, trait)
   110  		if err != nil {
   111  			AbortSuite(fmt.Sprintf("App VirtualService %s is not running in the namespace: %v, error: %v", trait, namespace, err))
   112  		}
   113  		return result
   114  	}, shortWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: VirtualService is not ready")
   115  
   116  	t.Logs.Info("Bobs Books Application: check expected Secrets exist")
   117  	Eventually(func() bool {
   118  		result, err := pkg.DoesSecretExist(namespace, frontEndRepoCreds)
   119  		if err != nil {
   120  			AbortSuite(fmt.Sprintf("App Secret %s does not exist in the namespace: %v, error: %v", frontEndRepoCreds, namespace, err))
   121  		}
   122  		return result
   123  	}, shortWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: Secret does not exist")
   124  
   125  	Eventually(func() bool {
   126  		result, err := pkg.DoesSecretExist(namespace, bookstoreWeblogicCreds)
   127  		if err != nil {
   128  			AbortSuite(fmt.Sprintf("App Secret %s does not exist in the namespace: %v, error: %v", bookstoreWeblogicCreds, namespace, err))
   129  		}
   130  		return result
   131  	}, shortWaitTimeout, longPollingInterval).Should(BeTrue(), "Bobs Books Application Failed to Deploy: Secret does not exist")
   132  
   133  	var err error
   134  	// Get the host from the Istio gateway resource.
   135  	start := time.Now()
   136  	t.Logs.Info("Bobs Books Application: check expected Gateway is ready")
   137  	Eventually(func() (string, error) {
   138  		host, err = k8sutil.GetHostnameFromGateway(namespace, "")
   139  		return host, err
   140  	}, shortWaitTimeout, shortPollingInterval).Should(Not(BeEmpty()), "Bobs Books Application Failed to Deploy: Gateway is not ready")
   141  
   142  	kubeconfig, err := k8sutil.GetKubeConfigLocation()
   143  	if err != nil {
   144  		AbortSuite(fmt.Sprintf("Failed to get the Kubeconfig location for the cluster: %v", err))
   145  	}
   146  	metricsTest, err = pkg.NewMetricsTest(kubeconfig, map[string]string{})
   147  	if err != nil {
   148  		AbortSuite(fmt.Sprintf("Failed to create the Metrics test object: %v", err))
   149  	}
   150  
   151  	metrics.Emit(t.Metrics.With("get_host_name_elapsed_time", time.Since(start).Milliseconds()))
   152  
   153  	beforeSuitePassed = true
   154  	kubeconfigPath, err := k8sutil.GetKubeConfigLocation()
   155  	if err != nil {
   156  		Fail(fmt.Sprintf("Failed to get default kubeconfig path: %s", err.Error()))
   157  	}
   158  	isMinVersion140, err = pkg.IsVerrazzanoMinVersion("1.4.0", kubeconfigPath)
   159  	if err != nil {
   160  		Fail(err.Error())
   161  	}
   162  })
   163  
   164  var failed = false
   165  var beforeSuitePassed = false
   166  var _ = t.AfterEach(func() {
   167  	failed = failed || CurrentSpecReport().Failed()
   168  })
   169  
   170  var afterSuite = t.AfterSuiteFunc(func() {
   171  	if failed || !beforeSuitePassed {
   172  		// bobbys frontend
   173  		dump.CaptureContainerLogs(namespace, "bobbys-front-end-adminserver", "weblogic-server", "/scratch/logs/bobbys-front-end")
   174  		dump.CaptureContainerLogs(namespace, "bobbys-front-end-managed-server1", "weblogic-server", "/scratch/logs/bobbys-front-end")
   175  		// Bobs Bookstore
   176  		dump.CaptureContainerLogs(namespace, "bobs-bookstore-adminserver", "weblogic-server", "/scratch/logs/bobs-bookstore")
   177  		dump.CaptureContainerLogs(namespace, "bobs-bookstore-managed-server1", "weblogic-server", "/scratch/logs/bobs-bookstore")
   178  		dump.ExecuteBugReport(namespace)
   179  	}
   180  	if !skipUndeploy {
   181  		undeployBobsBooksExample()
   182  	}
   183  })
   184  
   185  var _ = AfterSuite(afterSuite)
   186  var _ = BeforeSuite(beforeSuite)
   187  
   188  func deployBobsBooksExample(namespace string) {
   189  	t.Logs.Info("Deploy BobsBooks example")
   190  	wlsUser := "weblogic"
   191  	wlsPass := pkg.GetRequiredEnvVarOrFail("WEBLOGIC_PSW")
   192  	dbPass := pkg.GetRequiredEnvVarOrFail("DATABASE_PSW")
   193  	regServ := pkg.GetRequiredEnvVarOrFail("OCR_REPO")
   194  	regUser := pkg.GetRequiredEnvVarOrFail("OCR_CREDS_USR")
   195  	regPass := pkg.GetRequiredEnvVarOrFail("OCR_CREDS_PSW")
   196  
   197  	start := time.Now()
   198  	t.Logs.Info("Create namespace")
   199  	Eventually(func() (*v1.Namespace, error) {
   200  		nsLabels := map[string]string{
   201  			"verrazzano-managed": "true",
   202  			"istio-injection":    istioInjection}
   203  		return pkg.CreateNamespace(namespace, nsLabels)
   204  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(BeNil())
   205  
   206  	t.Logs.Info("Create Docker repository secret")
   207  	Eventually(func() (*v1.Secret, error) {
   208  		return pkg.CreateDockerSecret(namespace, "bobs-books-repo-credentials", regServ, regUser, regPass)
   209  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(BeNil())
   210  
   211  	t.Logs.Info("Create Bobbys front end WebLogic credentials secret")
   212  	Eventually(func() (*v1.Secret, error) {
   213  		return pkg.CreateCredentialsSecret(namespace, "bobbys-front-end-weblogic-credentials", wlsUser, wlsPass, nil)
   214  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(BeNil())
   215  
   216  	t.Logs.Info("Create Bobs Bookstore WebLogic credentials secret")
   217  	Eventually(func() (*v1.Secret, error) {
   218  		return pkg.CreateCredentialsSecret(namespace, "bobs-bookstore-weblogic-credentials", wlsUser, wlsPass, nil)
   219  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(BeNil())
   220  
   221  	t.Logs.Info("Create database credentials secret")
   222  	Eventually(func() (*v1.Secret, error) {
   223  		m := map[string]string{"password": dbPass, "username": wlsUser, "url": "jdbc:mysql://mysql:3306/books"}
   224  		return pkg.CreateCredentialsSecretFromMap(namespace, "mysql-credentials", m, nil)
   225  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(BeNil())
   226  
   227  	// Note: creating the app config first to verify that default metrics traits are created properly if the app config exists before the components
   228  	t.Logs.Info("Create application resources")
   229  	Eventually(func() error {
   230  		file, err := pkg.FindTestDataFile("examples/bobs-books/bobs-books-app.yaml")
   231  		if err != nil {
   232  			return err
   233  		}
   234  		return resource.CreateOrUpdateResourceFromFileInGeneratedNamespace(file, namespace)
   235  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(HaveOccurred())
   236  
   237  	t.Logs.Info("Create component resources")
   238  	Eventually(func() error {
   239  		file, err := pkg.FindTestDataFile("examples/bobs-books/bobs-books-comp.yaml")
   240  		if err != nil {
   241  			return err
   242  		}
   243  		return resource.CreateOrUpdateResourceFromFileInGeneratedNamespace(file, namespace)
   244  	}, shortWaitTimeout, shortPollingInterval, "Failed to create Bobs Books component resources").ShouldNot(HaveOccurred())
   245  	metrics.Emit(t.Metrics.With("deployment_elapsed_time", time.Since(start).Milliseconds()))
   246  }
   247  
   248  func undeployBobsBooksExample() {
   249  	t.Logs.Info("Undeploy BobsBooks example")
   250  	t.Logs.Info("Delete application")
   251  	start := time.Now()
   252  	Eventually(func() error {
   253  		file, err := pkg.FindTestDataFile("examples/bobs-books/bobs-books-app.yaml")
   254  		if err != nil {
   255  			return err
   256  		}
   257  		return resource.DeleteResourceFromFileInGeneratedNamespace(file, namespace)
   258  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(HaveOccurred())
   259  
   260  	t.Logs.Info("Delete components")
   261  	Eventually(func() error {
   262  		file, err := pkg.FindTestDataFile("examples/bobs-books/bobs-books-comp.yaml")
   263  		if err != nil {
   264  			return err
   265  		}
   266  		return resource.DeleteResourceFromFileInGeneratedNamespace(file, namespace)
   267  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(HaveOccurred())
   268  
   269  	t.Logs.Info("Wait for pods to terminate")
   270  	Eventually(func() bool {
   271  		podsTerminated, _ := pkg.PodsNotRunning(namespace, expectedPods)
   272  		return podsTerminated
   273  	}, shortWaitTimeout, shortPollingInterval).Should(BeTrue())
   274  
   275  	t.Logs.Info("Delete namespace")
   276  	Eventually(func() error {
   277  		return pkg.DeleteNamespace(namespace)
   278  	}, shortWaitTimeout, shortPollingInterval).ShouldNot(HaveOccurred())
   279  
   280  	t.Logs.Info("Wait for namespace finalizer to be removed")
   281  	Eventually(func() bool {
   282  		return pkg.CheckNamespaceFinalizerRemoved(namespace)
   283  	}, shortWaitTimeout, shortPollingInterval).Should(BeTrue())
   284  
   285  	t.Logs.Info("Wait for namespace deletion")
   286  	Eventually(func() bool {
   287  		_, err := pkg.GetNamespace(namespace)
   288  		return err != nil && errors.IsNotFound(err)
   289  	}, shortWaitTimeout, shortPollingInterval).Should(BeTrue())
   290  
   291  	metrics.Emit(t.Metrics.With("undeployment_elapsed_time", time.Since(start).Milliseconds()))
   292  }
   293  
   294  var _ = t.Describe("Bobs Books test", Label("f:app-lcm.oam",
   295  	"f:app-lcm.helidon-workload",
   296  	"f:app-lcm.weblogic-workload",
   297  	"f:app-lcm.coherence-workload"), func() {
   298  
   299  	var host = ""
   300  	var err error
   301  	// Get the host from the Istio gateway resource.
   302  	// GIVEN the Istio gateway for the bobs-books namespace
   303  	// WHEN GetHostnameFromGateway is called
   304  	// THEN return the host name found in the gateway.
   305  	t.BeforeEach(func() {
   306  		start := time.Now()
   307  		Eventually(func() (string, error) {
   308  			host, err = k8sutil.GetHostnameFromGateway(namespace, "")
   309  			return host, err
   310  		}, shortWaitTimeout, shortPollingInterval).Should(Not(BeEmpty()))
   311  		metrics.Emit(t.Metrics.With("get_host_name_elapsed_time", time.Since(start).Milliseconds()))
   312  	})
   313  	t.Context("Ingress.", Label("f:mesh.ingress"), FlakeAttempts(8), func() {
   314  		// Verify the application endpoint is working.
   315  		// GIVEN the Bobs Books app is deployed
   316  		// WHEN the roberts-books UI is accessed
   317  		// THEN the expected returned page should contain an expected value.
   318  		t.It("Verify roberts-books UI endpoint is working.", func() {
   319  			Eventually(func() (*pkg.HTTPResponse, error) {
   320  				url := fmt.Sprintf("https://%s", host)
   321  				return pkg.GetWebPage(url, host)
   322  			}, shortWaitTimeout, shortPollingInterval).Should(And(pkg.HasStatus(200), pkg.BodyContains("Robert's Books")))
   323  		})
   324  		// Verify the application endpoint is working.
   325  		// GIVEN the Bobs Books app is deployed
   326  		// WHEN the bobbys-books UI is accessed
   327  		// THEN the expected returned page should contain an expected value.
   328  		t.It("Verify bobbys-books UI endpoint is working.", func() {
   329  			Eventually(func() (*pkg.HTTPResponse, error) {
   330  				url := fmt.Sprintf("https://%s/bobbys-front-end/", host)
   331  				return pkg.GetWebPage(url, host)
   332  			}, longWaitTimeout, longPollingInterval).Should(And(pkg.HasStatus(200), pkg.BodyContains("Bobby's Books")))
   333  		})
   334  		// Verify the application endpoint is working even without trailing slash.
   335  		// GIVEN the Bobs Books app is deployed
   336  		// WHEN the bobbys-books UI is accessed
   337  		// THEN the expected returned page should contain an expected value.
   338  		t.It("Verify bobbys-books UI endpoint without trailing slash is working.", func() {
   339  			Eventually(func() (*pkg.HTTPResponse, error) {
   340  				url := fmt.Sprintf("https://%s/bobbys-front-end", host)
   341  				return pkg.GetWebPage(url, host)
   342  			}, longWaitTimeout, longPollingInterval).Should(And(pkg.HasStatus(200), pkg.BodyContains("Bobby's Books")))
   343  		})
   344  		// Verify the application endpoint is working.
   345  		// GIVEN the Bobs Books app is deployed
   346  		// WHEN the bobs-orders UI is accessed
   347  		// THEN the expected returned page should contain an expected value.
   348  		t.It("Verify bobs-orders UI endpoint for orders is working.", func() {
   349  			Eventually(func() (*pkg.HTTPResponse, error) {
   350  				url := fmt.Sprintf("https://%s/bobs-bookstore-order-manager/orders", host)
   351  				return pkg.GetWebPage(url, host)
   352  			}, longWaitTimeout, longPollingInterval).Should(And(pkg.HasStatus(200), pkg.BodyContains("Bob's Order Manager")))
   353  		})
   354  		t.It("Verify bobs-orders UI endpoint for books is working.", func() {
   355  			Eventually(func() (*pkg.HTTPResponse, error) {
   356  				url := fmt.Sprintf("https://%s/bobs-bookstore-order-manager/books", host)
   357  				return pkg.GetWebPage(url, host)
   358  			}, longWaitTimeout, longPollingInterval).Should(And(pkg.HasStatus(200), pkg.BodyContains("Bob's Order Manager")))
   359  		})
   360  	})
   361  	t.Context("Metrics.", Label("f:observability.monitoring.prom"), FlakeAttempts(5), func() {
   362  
   363  		// Verify application Prometheus scraped targets
   364  		// GIVEN a deployed Bob's Books application
   365  		// WHEN the application configuration uses a default metrics trait
   366  		// THEN confirm that all the scrape targets are healthy
   367  		t.It("Verify all scrape targets are healthy for the application", func() {
   368  			Eventually(func() (bool, error) {
   369  				var componentNames = []string{"bobby-coh", "bobby-helidon", "bobby-wls", "bobs-orders-wls", robertCoh, "robert-helidon"}
   370  				return pkg.ScrapeTargetsHealthy(pkg.GetScrapePools(namespace, "bobs-books", componentNames, isMinVersion140))
   371  			}, shortWaitTimeout, shortPollingInterval).Should(BeTrue())
   372  		})
   373  		// Verify Istio Prometheus scraped metrics
   374  		// GIVEN a deployed Bob's Books application
   375  		// WHEN the application configuration is deployed
   376  		// THEN confirm that Istio metrics are being collected
   377  		t.It("Retrieve Istio Prometheus scraped metrics", func() {
   378  			pkg.Concurrently(
   379  				func() {
   380  					Eventually(func() bool {
   381  						return metricsTest.MetricsExist("istio_tcp_received_bytes_total", map[string]string{"destination_canonical_service": "bobbys-helidon-stock-application"})
   382  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue())
   383  				},
   384  			)
   385  		})
   386  	})
   387  	t.Context("WebLogic logging.", Label("f:observability.logging.es"), func() {
   388  		var bobsIndexName string
   389  		Eventually(func() error {
   390  			bobsIndexName, err = pkg.GetOpenSearchAppIndex(namespace)
   391  			return err
   392  		}, shortWaitTimeout, shortPollingInterval).Should(BeNil(), "Expected to get OpenSearch App Index")
   393  
   394  		// GIVEN a WebLogic application with logging enabled
   395  		// WHEN the Opensearch index is retrieved
   396  		// THEN verify that it is found
   397  		t.It("Verify Opensearch index exists", func() {
   398  			Eventually(func() bool {
   399  				return pkg.LogIndexFound(bobsIndexName)
   400  			}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find log index "+bobsIndexName)
   401  		})
   402  		pkg.Concurrently(
   403  			// GIVEN a WebLogic application with logging enabled
   404  			// WHEN the log records are retrieved from the Opensearch index
   405  			// THEN verify that a recent log record of bobbys-front-end-adminserver stdout is found
   406  			func() {
   407  				t.It("Verify recent bobbys-front-end-adminserver log record exists", func() {
   408  					Eventually(func() bool {
   409  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   410  							k8sLabelDomainUID:     bobbysFrontEnd,
   411  							k8sLabelWLServerName:  "AdminServer",
   412  							k8sPodName:            "bobbys-front-end-adminserver",
   413  							k8sLabelContainerName: "weblogic-server",
   414  						})
   415  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   416  				})
   417  			},
   418  			// GIVEN a WebLogic application with logging enabled
   419  			// WHEN the log records are retrieved from the Opensearch index
   420  			// THEN verify that a recent log record of bobbys-front-end-adminserver log file is found
   421  			func() {
   422  				t.It("Verify recent bobbys-front-end-adminserver log record exists", func() {
   423  					Eventually(func() bool {
   424  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   425  							k8sLabelDomainUID:     bobbysFrontEnd,
   426  							k8sLabelWLServerName:  "AdminServer",
   427  							k8sPodName:            "bobbys-front-end-adminserver",
   428  							k8sLabelContainerName: fluentdStdoutSidecar,
   429  						})
   430  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   431  				})
   432  			},
   433  			// GIVEN a WebLogic application with logging enabled
   434  			// WHEN the log records are retrieved from the Opensearch index
   435  			// THEN verify that a recent log record of bobbys-front-end-managed-server stdout is found
   436  			func() {
   437  				t.It("Verify recent bobbys-front-end-managed-server1 log record exists", func() {
   438  					Eventually(func() bool {
   439  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   440  							k8sLabelDomainUID:     bobbysFrontEnd,
   441  							k8sLabelWLServerName:  managedServer1,
   442  							k8sPodName:            "bobbys-front-end-managed-server1",
   443  							k8sLabelContainerName: "weblogic-server",
   444  						})
   445  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   446  				})
   447  			},
   448  
   449  			// GIVEN a WebLogic application with logging enabled
   450  			// WHEN the log records are retrieved from the Opensearch index
   451  			// THEN verify that a recent pattern-matched log record of bobbys-front-end-adminserver stdout is found
   452  			func() {
   453  				t.It("Verify recent pattern-matched AdminServer log record exists", func() {
   454  					Eventually(func() bool {
   455  						return pkg.FindLog(bobsIndexName,
   456  							[]pkg.Match{
   457  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   458  								{Key: "subSystem.keyword", Value: "WorkManager"},
   459  								{Key: "serverName.keyword", Value: "bobbys-front-end-adminserver"},
   460  								{Key: "serverName2.keyword", Value: "AdminServer"},
   461  								{Key: "message", Value: "standby threads"}},
   462  							[]pkg.Match{})
   463  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   464  				})
   465  			},
   466  			// GIVEN a WebLogic application with logging enabled
   467  			// WHEN the log records are retrieved from the Opensearch index
   468  			// THEN verify that a recent pattern-matched log record of bobbys-front-end-adminserver stdout is found
   469  			func() {
   470  				t.It("Verify recent pattern-matched AdminServer log record exists", func() {
   471  					Eventually(func() bool {
   472  						return pkg.FindLog(bobsIndexName,
   473  							[]pkg.Match{
   474  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   475  								{Key: "subSystem", Value: "WorkManager"},
   476  								{Key: "serverName", Value: "bobbys-front-end-adminserver"},
   477  								{Key: "serverName2", Value: "AdminServer"},
   478  								{Key: "message", Value: "Self-tuning"}},
   479  							[]pkg.Match{})
   480  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   481  				})
   482  			},
   483  			// GIVEN a WebLogic application with logging enabled
   484  			// WHEN the log records are retrieved from the Opensearch index
   485  			// THEN verify that a recent log record of bobbys-front-end-managed-server log file is found
   486  			func() {
   487  				t.It("Verify recent bobbys-front-end-managed-server1 log record exists", func() {
   488  					Eventually(func() bool {
   489  						return pkg.FindLog(bobsIndexName,
   490  							[]pkg.Match{
   491  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   492  								{Key: k8sLabelDomainUID, Value: bobbysFrontEnd},
   493  								{Key: k8sLabelWLServerName, Value: managedServer1},
   494  								{Key: "messageID", Value: "BEA-"}, //matches BEA-*
   495  								{Key: "serverName", Value: "bobbys-front-end-managed-server1"},
   496  							},
   497  							[]pkg.Match{})
   498  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   499  				})
   500  			},
   501  			// GIVEN a WebLogic application with logging enabled
   502  			// WHEN the log records are retrieved from the Opensearch index
   503  			// THEN verify that a recent pattern-matched log record of bobbys-front-end-managed-server stdout is found
   504  			func() {
   505  				t.It("Verify recent pattern-matched managed-server log record exists", func() {
   506  					Eventually(func() bool {
   507  						return pkg.FindLog(bobsIndexName,
   508  							[]pkg.Match{
   509  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   510  								{Key: "subSystem.keyword", Value: "WorkManager"},
   511  								{Key: "serverName.keyword", Value: "bobbys-front-end-managed-server1"},
   512  								{Key: "serverName2.keyword", Value: managedServer1},
   513  								{Key: "message", Value: "standby threads"}},
   514  							[]pkg.Match{})
   515  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   516  				})
   517  			},
   518  			// GIVEN a WebLogic application with logging enabled
   519  			// WHEN the log records are retrieved from the Opensearch index
   520  			// THEN verify that a recent pattern-matched log record of bobbys-front-end-managed-server stdout is found
   521  			func() {
   522  				t.It("Verify recent pattern-matched managed-server log record exists", func() {
   523  					Eventually(func() bool {
   524  						return pkg.FindLog(bobsIndexName,
   525  							[]pkg.Match{
   526  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   527  								{Key: "subSystem", Value: "WorkManager"},
   528  								{Key: "serverName", Value: "bobbys-front-end-managed-server1"},
   529  								{Key: "serverName2", Value: managedServer1},
   530  								{Key: "message", Value: "Self-tuning"}},
   531  							[]pkg.Match{})
   532  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   533  				})
   534  			},
   535  		)
   536  		pkg.Concurrently(
   537  			// GIVEN a WebLogic application with logging enabled
   538  			// WHEN the log records are retrieved from the Opensearch index
   539  			// THEN verify that a recent log record of bobs-bookstore-adminserver stdout is found
   540  			func() {
   541  				t.It("Verify recent bobs-bookstore-adminserver log record exists", func() {
   542  					Eventually(func() bool {
   543  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   544  							k8sLabelDomainUID:     bobsBookStore,
   545  							k8sLabelWLServerName:  "AdminServer",
   546  							k8sPodName:            "bobs-bookstore-adminserver",
   547  							k8sLabelContainerName: "weblogic-server",
   548  						})
   549  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   550  				})
   551  			},
   552  			// GIVEN a WebLogic application with logging enabled
   553  			// WHEN the log records are retrieved from the Opensearch index
   554  			// THEN verify that a recent log record of bobs-bookstore-adminserver log file is found
   555  			func() {
   556  				t.It("Verify recent bobs-bookstore-adminserver log record exists", func() {
   557  					Eventually(func() bool {
   558  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   559  							k8sLabelDomainUID:     bobsBookStore,
   560  							k8sLabelWLServerName:  "AdminServer",
   561  							k8sPodName:            "bobs-bookstore-adminserver",
   562  							k8sLabelContainerName: fluentdStdoutSidecar,
   563  						})
   564  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   565  				})
   566  			},
   567  			// GIVEN a WebLogic application with logging enabled
   568  			// WHEN the log records are retrieved from the Opensearch index
   569  			// THEN verify that a recent log record of bobs-bookstore-managed-server stdout is found
   570  			func() {
   571  				t.It("Verify recent bobs-bookstore-managed-server1 log record exists", func() {
   572  					Eventually(func() bool {
   573  						return pkg.LogRecordFound(bobsIndexName, time.Now().Add(-24*time.Hour), map[string]string{
   574  							k8sLabelDomainUID:     bobsBookStore,
   575  							k8sLabelWLServerName:  managedServer1,
   576  							k8sPodName:            "bobs-bookstore-managed-server1",
   577  							k8sLabelContainerName: "weblogic-server",
   578  						})
   579  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   580  				})
   581  			},
   582  			// GIVEN a WebLogic application with logging enabled
   583  			// WHEN the log records are retrieved from the Opensearch index
   584  			// THEN verify that a recent log record of bobs-bookstore-managed-server log file is found
   585  			func() {
   586  				t.It("Verify recent bobs-bookstore-managed-server1 log record exists", func() {
   587  					Eventually(func() bool {
   588  						return pkg.FindLog(bobsIndexName,
   589  							[]pkg.Match{
   590  								{Key: "kubernetes.container_name.keyword", Value: fluentdStdoutSidecar},
   591  								{Key: k8sLabelDomainUID, Value: bobsBookStore},
   592  								{Key: k8sLabelWLServerName, Value: managedServer1},
   593  								{Key: "messageID", Value: "BEA-"},                //matches BEA-*
   594  								{Key: "message", Value: "Admin Traffic Enabled"}, //"Admin Traffic Enabled" in last line
   595  								{Key: "serverName", Value: "bobs-bookstore-managed-server1"},
   596  								{Key: "subSystem.keyword", Value: "RJVM"}},
   597  							[]pkg.Match{})
   598  					}, longWaitTimeout, longPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   599  				})
   600  			},
   601  		)
   602  	})
   603  	t.Context("Coherence logging.", Label("f:observability.logging.es"), func() {
   604  		var indexName string
   605  		Eventually(func() error {
   606  			indexName, err = pkg.GetOpenSearchAppIndex(namespace)
   607  			return err
   608  		}, shortWaitTimeout, shortPollingInterval).Should(BeNil(), "Expected to get OpenSearch App Index")
   609  
   610  		// GIVEN a Coherence application with logging enabled
   611  		// WHEN the Opensearch index is retrieved
   612  		// THEN verify that it is found
   613  		t.It("Verify Opensearch index exists", func() {
   614  			Eventually(func() bool {
   615  				return pkg.LogIndexFound(indexName)
   616  			}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find log index "+indexName)
   617  		})
   618  		pkg.Concurrently(
   619  			// GIVEN a Coherence application with logging enabled
   620  			// WHEN the log records are retrieved from the Opensearch index
   621  			// THEN verify that a recent log record of roberts-coherence-0 stdout is found
   622  			func() {
   623  				t.It("Verify recent roberts-coherence-0 log record exists", func() {
   624  					Eventually(func() bool {
   625  						return pkg.LogRecordFound(indexName, time.Now().Add(-24*time.Hour), map[string]string{
   626  							K8sLabelCoherenceCluster:                            robertsCoherence,
   627  							"kubernetes.labels.app_oam_dev\\/component.keyword": robertCoh,
   628  							k8sPodName:                          "roberts-coherence-0",
   629  							"kubernetes.container_name.keyword": "coherence",
   630  						})
   631  					}, shortWaitTimeout, shortPollingInterval).Should(BeTrue(), "Expected to find a recent log record")
   632  				})
   633  			},
   634  			// GIVEN a Coherence application with logging enabled
   635  			// WHEN the log records are retrieved from the Opensearch index
   636  			// THEN verify that a recent log record of roberts-coherence-0 log file is found
   637  			func() {
   638  				t.It("Verify recent roberts-coherence-0 log record exists", func() {
   639  					Eventually(func() bool {
   640  						return pkg.FindLog(indexName,
   641  							[]pkg.Match{
   642  								{Key: "kubernetes.labels.app_oam_dev/component", Value: robertCoh},
   643  								{Key: K8sLabelCoherenceCluster, Value: robertsCoherence},
   644  								{Key: k8sPodName, Value: "roberts-coherence-0"},
   645  								{Key: "product", Value: "Oracle Coherence"},
   646  								{Key: k8sLabelContainerName, Value: fluentdStdoutSidecar}},
   647  							[]pkg.Match{ //MustNot
   648  								{Key: k8sLabelContainerName, Value: "coherence"}})
   649  					}, 5*time.Minute, 10*time.Second).Should(BeTrue(), "Expected to find a systemd log record")
   650  				})
   651  			},
   652  			// GIVEN a Coherence application with logging enabled
   653  			// WHEN the log records are retrieved from the Opensearch index
   654  			// THEN verify that a recent log record of roberts-coherence-1 stdout is found
   655  			func() {
   656  				t.It("Verify recent roberts-coherence-1 log record exists", func() {
   657  					Eventually(func() bool {
   658  						return pkg.FindLog(indexName,
   659  							[]pkg.Match{
   660  								{Key: K8sLabelCoherenceCluster, Value: robertsCoherence},
   661  								{Key: k8sPodName, Value: "roberts-coherence-1"},
   662  								{Key: "kubernetes.container_name.keyword", Value: "coherence"}},
   663  							[]pkg.Match{ //MustNot
   664  								{Key: k8sLabelContainerName, Value: fluentdStdoutSidecar},
   665  							})
   666  					}, 5*time.Minute, 10*time.Second).Should(BeTrue(), "Expected to find a systemd log record")
   667  
   668  				})
   669  			},
   670  			// GIVEN a Coherence application with logging enabled
   671  			// WHEN the log records are retrieved from the Opensearch index
   672  			// THEN verify that a recent log record of roberts-coherence-1 log file is found
   673  			func() {
   674  				t.It("Verify recent roberts-coherence-1 log record exists", func() {
   675  					Eventually(func() bool {
   676  						return pkg.FindLog(indexName,
   677  							[]pkg.Match{
   678  								{Key: K8sLabelCoherenceCluster, Value: robertsCoherence},
   679  								{Key: k8sPodName, Value: "roberts-coherence-1"},
   680  								{Key: "product", Value: "Oracle Coherence"},
   681  								{Key: k8sLabelContainerName, Value: fluentdStdoutSidecar}},
   682  							[]pkg.Match{})
   683  					}, 5*time.Minute, 10*time.Second).Should(BeTrue(), "Expected to find a systemd log record")
   684  				})
   685  			},
   686  			// GIVEN a Coherence application with logging enabled
   687  			// WHEN the log records are retrieved from the Opensearch index
   688  			// THEN verify that a recent log record of bobbys-coherence log file is found
   689  			func() {
   690  				t.It("Verify recent roberts-coherence-1 log record exists", func() {
   691  					Eventually(func() bool {
   692  						return pkg.FindLog(indexName,
   693  							[]pkg.Match{
   694  								{Key: "kubernetes.labels.app_oam_dev/component", Value: "bobby-coh"},
   695  								{Key: K8sLabelCoherenceCluster, Value: "bobbys-coherence"},
   696  								{Key: "coherence.cluster.name", Value: "bobbys-coherence"},
   697  								{Key: "product", Value: "Oracle Coherence"},
   698  								{Key: k8sLabelContainerName, Value: fluentdStdoutSidecar}},
   699  							[]pkg.Match{})
   700  					}, 5*time.Minute, 10*time.Second).Should(BeTrue(), "Expected to find a systemd log record")
   701  				})
   702  			},
   703  		)
   704  	})
   705  })