github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/update/fluentd/fluentd_update_test.go (about) 1 // Copyright (c) 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 fluentd 5 6 import ( 7 "fmt" 8 "time" 9 10 "github.com/google/uuid" 11 . "github.com/onsi/ginkgo/v2" 12 "github.com/onsi/gomega" 13 vzapi "github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1alpha1" 14 "github.com/verrazzano/verrazzano/platform-operator/apis/verrazzano/v1beta1" 15 pcons "github.com/verrazzano/verrazzano/platform-operator/constants" 16 "github.com/verrazzano/verrazzano/tests/e2e/pkg" 17 "github.com/verrazzano/verrazzano/tests/e2e/pkg/test/framework" 18 ) 19 20 const ( 21 labelValidation = "f:platform-lcm.fluentd-update-validation" 22 opensearchURL = "https://opensearch.example.com:9200" 23 opensearchURLV1beta1 = "https://opensearch.v1beta1.example.com:9200" 24 ) 25 26 var ( 27 t = framework.NewTestFramework("update fluentd") 28 tempuuid = uuid.NewString()[:7] 29 extEsSec = "my-extsec-" + tempuuid 30 wrongSec = "wrong-sec-" + tempuuid 31 ociLgSec = "my-ocilog-" + tempuuid 32 sysLogID = "my-sysLog-" + tempuuid 33 defLogID = "my-defLog-" + tempuuid 34 ) 35 36 var afterSuite = t.AfterSuiteFunc(func() { 37 pkg.DeleteSecret(pcons.VerrazzanoInstallNamespace, extEsSec) 38 pkg.DeleteSecret(pcons.VerrazzanoInstallNamespace, wrongSec) 39 start := time.Now() 40 gomega.Eventually(func() bool { 41 return ValidateDaemonset(pkg.VmiESURL, pkg.VmiESInternalSecret, "") 42 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", pkg.VmiESURL, time.Since(start))) 43 }) 44 45 var _ = AfterSuite(afterSuite) 46 47 var _ = t.Describe("Update Fluentd", Label("f:platform-lcm.update"), func() { 48 t.Describe("fluentd verify", Label("f:platform-lcm.fluentd-verify"), func() { 49 t.It("fluentd default config", func() { 50 start := time.Now() 51 gomega.Eventually(func() bool { 52 return ValidateDaemonset(pkg.VmiESURL, pkg.VmiESInternalSecret, "") 53 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", pkg.VmiESURL, time.Since(start))) 54 }) 55 }) 56 57 t.Describe("Validate external Opensearch config", Label(labelValidation), func() { 58 t.It("secret validation", func() { 59 m := &FluentdModifier{Component: vzapi.FluentdComponent{ 60 ElasticsearchSecret: extEsSec + "missing", 61 ElasticsearchURL: opensearchURL, 62 }} 63 expectedError := "must be created" 64 ValidateUpdate(m, expectedError) 65 }) 66 }) 67 68 t.Describe("Update external Opensearch", Label("f:platform-lcm.fluentd-external-opensearch"), func() { 69 t.It("external Opensearch", func() { 70 pkg.CreateCredentialsSecret(pcons.VerrazzanoInstallNamespace, extEsSec, "user", "pw", map[string]string{}) 71 v1alpha1Modifier := &FluentdModifier{Component: vzapi.FluentdComponent{ 72 ElasticsearchSecret: extEsSec, 73 ElasticsearchURL: opensearchURL, 74 }} 75 v1beta1Modifier := &FluentdModifierV1beta1{Component: v1beta1.FluentdComponent{ 76 OpenSearchSecret: extEsSec, 77 OpenSearchURL: opensearchURLV1beta1, 78 }} 79 80 // Update CR using v1alpha1 API client. 81 ValidateUpdate(v1alpha1Modifier, "") 82 start := time.Now() 83 gomega.Eventually(func() bool { 84 return ValidateDaemonset(opensearchURL, extEsSec, "") 85 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", opensearchURL, time.Since(start))) 86 87 //Update CR using v1beta1 API client. 88 ValidateUpdateV1beta1(v1beta1Modifier, "") 89 90 start = time.Now() 91 gomega.Eventually(func() bool { 92 return ValidateDaemonsetV1beta1(opensearchURLV1beta1, extEsSec, "") 93 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", opensearchURLV1beta1, time.Since(start))) 94 }) 95 }) 96 97 t.Describe("Validate OCI logging config", Label(labelValidation), func() { 98 t.It("secret validation", func() { 99 m := &FluentdModifier{Component: vzapi.FluentdComponent{ 100 OCI: &vzapi.OciLoggingConfiguration{APISecret: wrongSec}, 101 }} 102 expectedError1 := "must be created" 103 ValidateUpdate(m, expectedError1) 104 105 pkg.CreateCredentialsSecret(pcons.VerrazzanoInstallNamespace, wrongSec, "api", "pw", map[string]string{}) 106 107 expectedError2 := "Did not find OCI configuration" 108 ValidateUpdate(m, expectedError2) 109 }) 110 }) 111 112 t.Describe("Update OCI logging", Label("f:platform-lcm.fluentd-oci-logging"), func() { 113 t.It(" OCI logging", func() { 114 createOciLoggingSecret(ociLgSec) 115 m := &FluentdModifier{Component: vzapi.FluentdComponent{OCI: &vzapi.OciLoggingConfiguration{ 116 APISecret: ociLgSec, 117 SystemLogID: sysLogID, 118 DefaultAppLogID: defLogID, 119 }}} 120 ValidateUpdate(m, "") 121 122 start := time.Now() 123 gomega.Eventually(func() bool { 124 return ValidateDaemonset("", "", ociLgSec) 125 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", "", time.Since(start))) 126 127 gomega.Eventually(func() bool { 128 return ValidateConfigMap(sysLogID, defLogID) 129 }, shortWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("ConfigMap %s is not ready", fluentdName+"-config")) 130 131 }) 132 }) 133 134 t.Describe("Validate extra Volume Mounts", Label(labelValidation), func() { 135 t.It("extraVolumeMounts validation", func() { 136 m := &FluentdModifier{Component: vzapi.FluentdComponent{ 137 ExtraVolumeMounts: []vzapi.VolumeMount{{Source: "/var/log"}}, 138 }} 139 expectedError := "duplicate mount path found" 140 ValidateUpdate(m, expectedError) 141 }) 142 }) 143 144 t.Describe("Update extraVolumeMounts", Label("f:platform-lcm.fluentd-extra-volume-mounts"), func() { 145 t.It("extraVolumeMounts", func() { 146 vm := vzapi.VolumeMount{Source: "/var/log", Destination: "/home/varLog"} 147 m := &FluentdModifier{Component: vzapi.FluentdComponent{ 148 ExtraVolumeMounts: []vzapi.VolumeMount{vm}, 149 }} 150 ValidateUpdate(m, "") 151 152 start := time.Now() 153 gomega.Eventually(func() bool { 154 return ValidateDaemonset(pkg.VmiESURL, pkg.VmiESInternalSecret, "", vm) 155 }, longWait, pollingInterval).Should(gomega.BeTrue(), fmt.Sprintf("DaemonSet %s is not ready for %v", pkg.VmiESURL, time.Since(start))) 156 }) 157 }) 158 })