github.com/redhat-appstudio/e2e-tests@v0.0.0-20230619105049-9a422b2094d7/tests/o11y/o11y-pipelinerun.go (about) 1 package o11y 2 3 import ( 4 "fmt" 5 6 . "github.com/onsi/ginkgo/v2" 7 . "github.com/onsi/gomega" 8 9 "github.com/redhat-appstudio/e2e-tests/pkg/framework" 10 "github.com/redhat-appstudio/e2e-tests/pkg/utils" 11 "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" 12 ) 13 14 var _ = framework.O11ySuiteDescribe("O11Y E2E tests for Pipelinerun", Label("o11y", "HACBS"), Pending, func() { 15 16 defer GinkgoRecover() 17 var f *framework.Framework 18 var kc tekton.KubeController 19 var err error 20 21 Describe("O11y test", func() { 22 var testNamespace string 23 24 BeforeAll(func() { 25 26 f, err = framework.NewFramework(O11yUserPipelineruns) 27 Expect(err).NotTo(HaveOccurred()) 28 testNamespace = f.UserNamespace 29 kc = tekton.KubeController{ 30 Commonctrl: *f.AsKubeAdmin.CommonController, 31 Tektonctrl: *f.AsKubeAdmin.TektonController, 32 Namespace: testNamespace, 33 } 34 35 // Get Quay Token from ENV 36 quayToken := utils.GetEnv("QUAY_TOKEN", "") 37 Expect(quayToken).ToNot(BeEmpty()) 38 39 _, err := f.AsKubeAdmin.CommonController.CreateRegistryAuthSecret(o11yUserSecret, testNamespace, quayToken) 40 Expect(err).ToNot(HaveOccurred()) 41 42 err = f.AsKubeAdmin.CommonController.LinkSecretToServiceAccount(testNamespace, o11yUserSecret, O11ySA, true) 43 Expect(err).ToNot(HaveOccurred()) 44 45 }) 46 AfterAll(func() { 47 if !CurrentSpecReport().Failed() { 48 Expect(f.SandboxController.DeleteUserSignup(f.UserName)).NotTo(BeFalse()) 49 } 50 }) 51 52 It("E2E test to measure Egress pod by pushing images to quay - PipelineRun", func() { 53 54 // Get Quay Organization from ENV 55 quayOrg := utils.GetEnv("QUAY_E2E_ORGANIZATION", "") 56 Expect(quayOrg).ToNot(BeEmpty()) 57 58 pipelineRun, err := f.AsKubeAdmin.O11yController.QuayImagePushPipelineRun(quayOrg, o11yUserSecret, testNamespace) 59 Expect(err).NotTo(HaveOccurred()) 60 61 // Wait for the pipeline run to succeed 62 Expect(kc.WatchPipelineRunSucceeded(pipelineRun.Name, pipelineRunTimeout)).To(Succeed()) 63 64 podNameRegex := ".*-buildah-quay-pod" 65 query := fmt.Sprintf("last_over_time(container_network_transmit_bytes_total{namespace='%s', pod=~'%s'}[1h])", testNamespace, podNameRegex) 66 result, err := f.AsKubeAdmin.O11yController.GetMetrics(query) 67 Expect(err).NotTo(HaveOccurred()) 68 69 podNamesWithResult, err := f.AsKubeAdmin.O11yController.GetRegexPodNameWithResult(podNameRegex, result) 70 Expect(err).NotTo(HaveOccurred()) 71 72 podNameWithMB, err := f.AsKubeAdmin.O11yController.ConvertValuesToMB(podNamesWithResult) 73 Expect(err).NotTo(HaveOccurred()) 74 75 for podName, podSize := range podNameWithMB { 76 // Range limits are measured as part of STONEO11Y-15 77 Expect(podSize).To(And( 78 BeNumerically(">=", 106), 79 BeNumerically("<=", 109), 80 ), fmt.Sprintf("%s: %d MB is not within the expected range.\n", podName, podSize)) 81 } 82 }) 83 84 It("E2E test to measure vCPU Minutes - PipelineRun", func() { 85 86 pipelineRun, err := f.AsKubeAdmin.O11yController.VCPUMinutesPipelineRun(testNamespace) 87 Expect(err).NotTo(HaveOccurred()) 88 89 // Wait for the pipeline run to succeed 90 Expect(kc.WatchPipelineRunSucceeded(pipelineRun.Name, pipelineRunTimeout)).To(Succeed()) 91 92 podNameRegex := "pipelinerun-vcpu-.*" 93 query := fmt.Sprintf("{__name__=~'kube_pod_container_resource_limits', namespace='%s', resource='cpu', pod=~'%s', container!='None'}", testNamespace, podNameRegex) 94 metricsResult, err := f.AsKubeAdmin.O11yController.GetMetrics(query) 95 Expect(err).NotTo(HaveOccurred()) 96 97 podNamesWithResult, err := f.AsKubeAdmin.O11yController.GetRegexPodNameWithResult(podNameRegex, metricsResult) 98 Expect(err).NotTo(HaveOccurred()) 99 100 for podName, result := range podNamesWithResult { 101 // CPU Limits of 200 millicores set within deployments 102 Expect(result).To(Equal("0.2"), fmt.Sprintf("%s: %s millicores is not within the expected range.\n", podName, result)) 103 } 104 }) 105 }) 106 })