From b592bf29a64c991eb2ec3109767ff3c61a38b861 Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Fri, 17 Feb 2023 12:19:39 +0000 Subject: [PATCH 1/8] [RHDP-513] add failed pipelinerun logs --- pkg/utils/has/controller.go | 6 +- tests/build/build.go | 29 +----- tests/e2e-demos/config/default.yaml | 125 ++++++++++++----------- tests/e2e-demos/e2e-demo.go | 6 +- tests/e2e-demos/multi-component.go | 8 +- tests/integration-service/integration.go | 3 +- tests/utils/utils.go | 20 ++++ 7 files changed, 108 insertions(+), 89 deletions(-) create mode 100644 tests/utils/utils.go diff --git a/pkg/utils/has/controller.go b/pkg/utils/has/controller.go index 2e9438831b..52afde20c7 100644 --- a/pkg/utils/has/controller.go +++ b/pkg/utils/has/controller.go @@ -10,11 +10,13 @@ import ( "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/utils" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/common" . "github.com/onsi/ginkgo/v2" routev1 "github.com/openshift/api/route/v1" appservice "github.com/redhat-appstudio/application-api/api/v1alpha1" kubeCl "github.com/redhat-appstudio/e2e-tests/pkg/apis/kubernetes" + u "github.com/redhat-appstudio/e2e-tests/tests/utils" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -417,7 +419,7 @@ func (h *SuiteController) GetComponentService(componentName string, componentNam return service, nil } -func (h *SuiteController) WaitForComponentPipelineToBeFinished(componentName string, applicationName string, componentNamespace string) error { +func (h *SuiteController) WaitForComponentPipelineToBeFinished(c *common.SuiteController, componentName string, applicationName string, componentNamespace string) error { return wait.PollImmediate(20*time.Second, 25*time.Minute, func() (done bool, err error) { pipelineRun, err := h.GetComponentPipelineRun(componentName, applicationName, componentNamespace, false, "") @@ -430,7 +432,7 @@ func (h *SuiteController) WaitForComponentPipelineToBeFinished(componentName str GinkgoWriter.Printf("PipelineRun %s reason: %s\n", pipelineRun.Name, condition.Reason) if condition.Reason == "Failed" { - return false, fmt.Errorf("component %s pipeline failed", pipelineRun.Name) + return false, fmt.Errorf(u.GetFailedPipelineRunLogs(c, pipelineRun)) } if condition.Status == corev1.ConditionTrue { diff --git a/tests/build/build.go b/tests/build/build.go index 839e7f9863..cac68a017b 100644 --- a/tests/build/build.go +++ b/tests/build/build.go @@ -16,6 +16,7 @@ import ( "github.com/google/uuid" "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/utils" + u "github.com/redhat-appstudio/e2e-tests/tests/utils" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -191,12 +192,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) - d := utils.GetFailedPipelineRunDetails(pipelineRun) - if d.FailedContainerName != "" { - logs, _ := f.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace) - failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) - } + failMessage := u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun) Fail(failMessage) } } @@ -269,12 +265,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) - d := utils.GetFailedPipelineRunDetails(pipelineRun) - if d.FailedContainerName != "" { - logs, _ := f.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace) - failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) - } + failMessage := u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun) Fail(failMessage) } } @@ -345,12 +336,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) - d := utils.GetFailedPipelineRunDetails(pipelineRun) - if d.FailedContainerName != "" { - logs, _ := f.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace) - failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) - } + failMessage := u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun) Fail(failMessage) } } @@ -480,12 +466,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) - d := utils.GetFailedPipelineRunDetails(pipelineRun) - if d.FailedContainerName != "" { - logs, _ := f.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace) - failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) - } + failMessage := u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun) Fail(failMessage) } } diff --git a/tests/e2e-demos/config/default.yaml b/tests/e2e-demos/config/default.yaml index a3a7fcd8d1..6b29485d06 100644 --- a/tests/e2e-demos/config/default.yaml +++ b/tests/e2e-demos/config/default.yaml @@ -1,62 +1,73 @@ tests: - - name: "RHDP-466: create an application with springboot component" - applicationName: "e2e-springboot" - components: - - name: "springboot-component" - type: "public" - gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-java-springboot-basic" - language: "Java" - healthz: "/" - - name: "RHDP-489: create an application with python flask" - applicationName: "e2e-python-personal" - components: - - name: "component-python-flask" - type: "public" - gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-python-basic.git" - language: "Python" - healthz: "/" - - name: "RHDP-476: create an application with DotNet component" - applicationName: "e2e-dotnet" - components: - - name: "dotnet-component" - type: "public" - gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-dotnet60-basic" - language: "dotNet" - healthz: "/" - - name: "create an nodejs application without dockerfile" + - name: "RHDP-466: create an application with nodejs component" applicationName: "e2e-nodejs" components: - - name: "nodejs-no-dockerfile" + - name: "nodejs-component" type: "public" - gitSourceUrl: "https://github.com/nodeshift-starters/nodejs-health-check.git" - language: "JavaScript" - healthz: "/live" - - name: "nodejs-priv" - type: "private" - gitSourceUrl: "https://github.com/redhat-appstudio-qe-bot/nodejs-health-check.git" - language: "JavaScript" - healthz: "/live" - - name: "create an golang application" - applicationName: "e2e-golang" - components: - - name: "golang-dockerfile" - type: "public" - gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-go-basic" - language: "Go" - healthz: "/" - - name: "create an nodejs application with dockerfile and devfile" - applicationName: "e2e-nodejs" - components: - - name: "nodejs-dockerfile" - type: "public" - gitSourceUrl: "https://github.com/nodeshift-starters/devfile-sample" - language: "JavaScript" + gitSourceUrl: "https://github.com/rsoaresd/simple-nodejs-app" + devfileSource: "https://raw.githubusercontent.com/rsoaresd/simple-nodejs-app/main/devfiles/devfile.yaml" + language: "nodejssss" healthz: "/" - - name: "create an application with quarkus component" - applicationName: "quarkus" - components: - - name: "quarkus-devfile" - type: "public" - gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git" - language: "Java" - healthz: "/hello-resteasy" + spec: + replicas: 2 + # - name: "RHDP-466: create an application with springboot component" + # applicationName: "e2e-springboot" + # components: + # - name: "springboot-component" + # type: "public" + # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-java-springboot-basic" + # language: "Java" + # healthz: "/" + # - name: "RHDP-489: create an application with python flask" + # applicationName: "e2e-python-personal" + # components: + # - name: "component-python-flask" + # type: "public" + # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-python-basic.git" + # language: "Python" + # healthz: "/" + # - name: "RHDP-476: create an application with DotNet component" + # applicationName: "e2e-dotnet" + # components: + # - name: "dotnet-component" + # type: "public" + # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-dotnet60-basic" + # language: "dotNet" + # healthz: "/" + # - name: "create an nodejs application without dockerfile" + # applicationName: "e2e-nodejs" + # components: + # - name: "nodejs-no-dockerfile" + # type: "public" + # gitSourceUrl: "https://github.com/nodeshift-starters/nodejs-health-check.git" + # language: "JavaScript" + # healthz: "/live" + # - name: "nodejs-priv" + # type: "private" + # gitSourceUrl: "https://github.com/redhat-appstudio-qe-bot/nodejs-health-check.git" + # language: "JavaScript" + # healthz: "/live" + # - name: "create an golang application" + # applicationName: "e2e-golang" + # components: + # - name: "golang-dockerfile" + # type: "public" + # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-go-basic" + # language: "Go" + # healthz: "/" + # - name: "create an nodejs application with dockerfile and devfile" + # applicationName: "e2e-nodejs" + # components: + # - name: "nodejs-dockerfile" + # type: "public" + # gitSourceUrl: "https://github.com/nodeshift-starters/devfile-sample" + # language: "JavaScript" + # healthz: "/" + # - name: "create an application with quarkus component" + # applicationName: "quarkus" + # components: + # - name: "quarkus-devfile" + # type: "public" + # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git" + # language: "Java" + # healthz: "/hello-resteasy" diff --git a/tests/e2e-demos/e2e-demo.go b/tests/e2e-demos/e2e-demo.go index 0878f2770d..baef871804 100644 --- a/tests/e2e-demos/e2e-demo.go +++ b/tests/e2e-demos/e2e-demo.go @@ -191,7 +191,11 @@ var _ = framework.E2ESuiteDescribe(Label("e2e-demo"), func() { err := fw.HasController.K8sClient.KubeRest().Update(context.Background(), component) Expect(err).ShouldNot(HaveOccurred(), "failed to update component to trigger another pipeline build: %v", err) } - Expect(fw.HasController.WaitForComponentPipelineToBeFinished(component.Name, application.Name, namespace)).To(Succeed(), "Failed component pipeline %v", err) + + err := fw.HasController.WaitForComponentPipelineToBeFinished(fw.CommonController, component.Name, application.Name, namespace) + if err != nil { + Fail(fmt.Sprint(err)) + } }) It("finds the snapshot and checks if it is marked as successful", func() { diff --git a/tests/e2e-demos/multi-component.go b/tests/e2e-demos/multi-component.go index 62240e136f..f37a573873 100644 --- a/tests/e2e-demos/multi-component.go +++ b/tests/e2e-demos/multi-component.go @@ -160,17 +160,17 @@ var _ = framework.E2ESuiteDescribe(Label("e2e-demo"), func() { // Start to watch the pipeline until is finished It("waits for all pipelines to be finished", func() { - err := fw.HasController.WaitForComponentPipelineToBeFinished(compNameGo, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) + err := fw.HasController.WaitForComponentPipelineToBeFinished(fw.CommonController, compNameGo, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) if err != nil { removeApplication = false + Fail(fmt.Sprint(err)) } - Expect(err).NotTo(HaveOccurred(), "Failed component pipeline %v", err) - err = fw.HasController.WaitForComponentPipelineToBeFinished(compNameNode, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) + err = fw.HasController.WaitForComponentPipelineToBeFinished(fw.CommonController, compNameNode, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) if err != nil { removeApplication = false + Fail(fmt.Sprint(err)) } - Expect(err).NotTo(HaveOccurred(), "Failed component pipeline %v", err) }) // Check components are deployed diff --git a/tests/integration-service/integration.go b/tests/integration-service/integration.go index 197026536f..48f923c722 100644 --- a/tests/integration-service/integration.go +++ b/tests/integration-service/integration.go @@ -9,6 +9,7 @@ import ( "github.com/google/uuid" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" + u "github.com/redhat-appstudio/e2e-tests/tests/utils" appstudioApi "github.com/redhat-appstudio/application-api/api/v1alpha1" @@ -101,7 +102,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests GinkgoWriter.Printf("PipelineRun %s Status.Conditions.Reason: %s\n", pipelineRun.Name, condition.Reason) if condition.Reason == "Failed" { - Fail(fmt.Sprintf("Pipelinerun %s has failed", pipelineRun.Name)) + Fail(u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun)) } } return pipelineRun.IsDone() diff --git a/tests/utils/utils.go b/tests/utils/utils.go new file mode 100644 index 0000000000..e11f1d087b --- /dev/null +++ b/tests/utils/utils.go @@ -0,0 +1,20 @@ +package utils + +import ( + "fmt" + + "github.com/redhat-appstudio/e2e-tests/pkg/utils" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/common" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" +) + +// GetFailedPipelineRunLogs gets the logs of the pipelinerun failed task +func GetFailedPipelineRunLogs(c *common.SuiteController, pipelineRun *v1beta1.PipelineRun) string { + failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) + d := utils.GetFailedPipelineRunDetails(pipelineRun) + if d.FailedContainerName != "" { + logs, _ := c.GetContainerLogs(d.PodName, d.FailedContainerName, pipelineRun.Namespace) + failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) + } + return failMessage +} From e3eebe9b4d1ed7c5142aca68bed8444077de455c Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Fri, 17 Feb 2023 13:38:57 +0000 Subject: [PATCH 2/8] revert --- tests/e2e-demos/config/default.yaml | 125 +++++++++++++--------------- 1 file changed, 57 insertions(+), 68 deletions(-) diff --git a/tests/e2e-demos/config/default.yaml b/tests/e2e-demos/config/default.yaml index 6b29485d06..f66a185c9e 100644 --- a/tests/e2e-demos/config/default.yaml +++ b/tests/e2e-demos/config/default.yaml @@ -1,73 +1,62 @@ tests: - - name: "RHDP-466: create an application with nodejs component" + - name: "RHDP-466: create an application with springboot component" + applicationName: "e2e-springboot" + components: + - name: "springboot-component" + type: "public" + gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-java-springboot-basic" + language: "Java" + healthz: "/" + - name: "RHDP-489: create an application with python flask" + applicationName: "e2e-python-personal" + components: + - name: "component-python-flask" + type: "public" + gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-python-basic.git" + language: "Python" + healthz: "/" + - name: "RHDP-476: create an application with DotNet component" + applicationName: "e2e-dotnet" + components: + - name: "dotnet-component" + type: "public" + gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-dotnet60-basic" + language: "dotNet" + healthz: "/" + - name: "create an nodejs application without dockerfile" applicationName: "e2e-nodejs" components: - - name: "nodejs-component" + - name: "nodejs-no-dockerfile" type: "public" - gitSourceUrl: "https://github.com/rsoaresd/simple-nodejs-app" - devfileSource: "https://raw.githubusercontent.com/rsoaresd/simple-nodejs-app/main/devfiles/devfile.yaml" - language: "nodejssss" + gitSourceUrl: "https://github.com/nodeshift-starters/nodejs-health-check.git" + language: "JavaScript" + healthz: "/live" + - name: "nodejs-priv" + type: "private" + gitSourceUrl: "https://github.com/redhat-appstudio-qe-bot/nodejs-health-check.git" + language: "JavaScript" + healthz: "/live" + - name: "create an golang application" + applicationName: "e2e-golang" + components: + - name: "golang-dockerfile" + type: "public" + gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-go-basic" + language: "Go" + healthz: "/" + - name: "create an nodejs application with dockerfile and devfile" + applicationName: "e2e-nodejs" + components: + - name: "nodejs-dockerfile" + type: "public" + gitSourceUrl: "https://github.com/nodeshift-starters/devfile-sample" + language: "JavaScript" healthz: "/" - spec: - replicas: 2 - # - name: "RHDP-466: create an application with springboot component" - # applicationName: "e2e-springboot" - # components: - # - name: "springboot-component" - # type: "public" - # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-java-springboot-basic" - # language: "Java" - # healthz: "/" - # - name: "RHDP-489: create an application with python flask" - # applicationName: "e2e-python-personal" - # components: - # - name: "component-python-flask" - # type: "public" - # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-python-basic.git" - # language: "Python" - # healthz: "/" - # - name: "RHDP-476: create an application with DotNet component" - # applicationName: "e2e-dotnet" - # components: - # - name: "dotnet-component" - # type: "public" - # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-dotnet60-basic" - # language: "dotNet" - # healthz: "/" - # - name: "create an nodejs application without dockerfile" - # applicationName: "e2e-nodejs" - # components: - # - name: "nodejs-no-dockerfile" - # type: "public" - # gitSourceUrl: "https://github.com/nodeshift-starters/nodejs-health-check.git" - # language: "JavaScript" - # healthz: "/live" - # - name: "nodejs-priv" - # type: "private" - # gitSourceUrl: "https://github.com/redhat-appstudio-qe-bot/nodejs-health-check.git" - # language: "JavaScript" - # healthz: "/live" - # - name: "create an golang application" - # applicationName: "e2e-golang" - # components: - # - name: "golang-dockerfile" - # type: "public" - # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-go-basic" - # language: "Go" - # healthz: "/" - # - name: "create an nodejs application with dockerfile and devfile" - # applicationName: "e2e-nodejs" - # components: - # - name: "nodejs-dockerfile" - # type: "public" - # gitSourceUrl: "https://github.com/nodeshift-starters/devfile-sample" - # language: "JavaScript" - # healthz: "/" - # - name: "create an application with quarkus component" - # applicationName: "quarkus" - # components: - # - name: "quarkus-devfile" - # type: "public" - # gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git" - # language: "Java" - # healthz: "/hello-resteasy" + - name: "create an application with quarkus component" + applicationName: "quarkus" + components: + - name: "quarkus-devfile" + type: "public" + gitSourceUrl: "https://github.com/devfile-samples/devfile-sample-code-with-quarkus.git" + language: "Java" + healthz: "/hello-resteasy" \ No newline at end of file From b12e1f7ddd7ba0d9299d68e12d01ccdb7c4259aa Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Mon, 20 Feb 2023 09:31:13 +0000 Subject: [PATCH 3/8] fix --- tests/e2e-demos/e2e-demo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-demos/e2e-demo.go b/tests/e2e-demos/e2e-demo.go index be94b13437..62abd9bc6f 100644 --- a/tests/e2e-demos/e2e-demo.go +++ b/tests/e2e-demos/e2e-demo.go @@ -208,7 +208,7 @@ var _ = framework.E2ESuiteDescribe(Label("e2e-demo"), func() { Expect(err).ShouldNot(HaveOccurred(), "failed to update component to trigger another pipeline build: %v", err) } - err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeDeveloper.CommonController, component.Name, application.Name, namespace) + err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, component.Name, application.Name, namespace) if err != nil { Fail(fmt.Sprint(err)) } From 71da5b63643714dc67caef18a8ed564d8c4a3d56 Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Mon, 20 Feb 2023 09:33:18 +0000 Subject: [PATCH 4/8] fix --- tests/e2e-demos/multi-component.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e-demos/multi-component.go b/tests/e2e-demos/multi-component.go index 74be4da88e..9bb2128af5 100644 --- a/tests/e2e-demos/multi-component.go +++ b/tests/e2e-demos/multi-component.go @@ -161,13 +161,13 @@ var _ = framework.E2ESuiteDescribe(Label("e2e-demo"), func() { // Start to watch the pipeline until is finished It("waits for all pipelines to be finished", func() { - err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameGo, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) + err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameGo, testSpecification.Tests[0].ApplicationName, namespace) if err != nil { removeApplication = false Fail(fmt.Sprint(err)) } - err = fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameNode, testSpecification.Tests[0].ApplicationName, AppStudioE2EApplicationsNamespace) + err = fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameNode, testSpecification.Tests[0].ApplicationName, namespace) if err != nil { removeApplication = false Fail(fmt.Sprint(err)) From d6c839af8a9444ae04eb82956e66ee21fbfc164f Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Mon, 20 Feb 2023 09:38:49 +0000 Subject: [PATCH 5/8] fix --- tests/integration-service/integration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration-service/integration.go b/tests/integration-service/integration.go index 2283d571bc..91cb8a0785 100644 --- a/tests/integration-service/integration.go +++ b/tests/integration-service/integration.go @@ -110,7 +110,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests GinkgoWriter.Printf("PipelineRun %s Status.Conditions.Reason: %s\n", pipelineRun.Name, condition.Reason) if condition.Reason == "Failed" { - Fail(u.GetFailedPipelineRunLogs(f.CommonController, pipelineRun)) + Fail(u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)) } } return pipelineRun.IsDone() From b746561489ae4b715fca1ec67e5e1ddf703c40e6 Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Mon, 20 Feb 2023 11:33:34 +0000 Subject: [PATCH 6/8] add line --- tests/build/build.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/build/build.go b/tests/build/build.go index 6ed4bec812..b8713a8bde 100644 --- a/tests/build/build.go +++ b/tests/build/build.go @@ -323,6 +323,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " return pipelineRun.HasStarted() }, timeout, interval).Should(BeTrue(), "timed out when waiting for the PipelineRun to start") }) + It("pipelineRun should eventually finish", func() { timeout = time.Minute * 50 interval = time.Second * 10 From 360259d3be69f4a546525103b0a65689080219e5 Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Wed, 22 Feb 2023 09:23:46 +0000 Subject: [PATCH 7/8] fix --- tests/mvp-demo/mvp-demo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mvp-demo/mvp-demo.go b/tests/mvp-demo/mvp-demo.go index 8ce2bf8a1b..1a66dc6c92 100644 --- a/tests/mvp-demo/mvp-demo.go +++ b/tests/mvp-demo/mvp-demo.go @@ -190,7 +190,7 @@ var _ = framework.MvpDemoSuiteDescribe("MVP Demo tests", Label("mvp-demo"), func It("sample app can be built successfully", func() { _, err = f.AsKubeAdmin.HasController.CreateComponent(appName, componentName, userNamespace, sampleRepoURL, componentNewBaseBranch, "", constants.DefaultImagePushRepo, "", true) Expect(err).ShouldNot(HaveOccurred()) - Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(componentName, appName, userNamespace, "")).To(Succeed()) + Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(f.AsKubeAdmin.CommonController, componentName, appName, userNamespace, "")).To(Succeed()) }) It("sample app is successfully deployed to dev environment", func() { @@ -310,7 +310,7 @@ var _ = framework.MvpDemoSuiteDescribe("MVP Demo tests", Label("mvp-demo"), func }) It("SLSA level 3 customizable pipeline completes successfully", func() { - Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(componentName, appName, userNamespace, mergeResultSha)).To(Succeed()) + Expect(f.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(f.AsKubeAdmin.CommonController, componentName, appName, userNamespace, mergeResultSha)).To(Succeed()) }) It("resulting SBOM file can be downloaded", func() { From 0e807a3343ad888fb97cb6b038a878f91cc66633 Mon Sep 17 00:00:00 2001 From: Rafaela Soares Date: Wed, 22 Feb 2023 10:12:55 +0000 Subject: [PATCH 8/8] requested changes --- go.sum | 1 - pkg/utils/has/controller.go | 4 ++-- pkg/utils/tekton/pipelines.go | 13 +++++++++++++ tests/build/build.go | 10 +++++----- tests/integration-service/integration.go | 4 ++-- tests/utils/utils.go | 20 -------------------- 6 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 tests/utils/utils.go diff --git a/go.sum b/go.sum index b0c4211837..99db8b8048 100644 --- a/go.sum +++ b/go.sum @@ -711,7 +711,6 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= diff --git a/pkg/utils/has/controller.go b/pkg/utils/has/controller.go index 9bd7301033..de1e59742e 100644 --- a/pkg/utils/has/controller.go +++ b/pkg/utils/has/controller.go @@ -16,7 +16,7 @@ import ( routev1 "github.com/openshift/api/route/v1" appservice "github.com/redhat-appstudio/application-api/api/v1alpha1" kubeCl "github.com/redhat-appstudio/e2e-tests/pkg/apis/kubernetes" - u "github.com/redhat-appstudio/e2e-tests/tests/utils" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -431,7 +431,7 @@ func (h *SuiteController) WaitForComponentPipelineToBeFinished(c *common.SuiteCo GinkgoWriter.Printf("PipelineRun %s reason: %s\n", pipelineRun.Name, condition.Reason) if condition.Reason == "Failed" { - return false, fmt.Errorf(u.GetFailedPipelineRunLogs(c, pipelineRun)) + return false, fmt.Errorf(tekton.GetFailedPipelineRunLogs(c, pipelineRun)) } if condition.Status == corev1.ConditionTrue { diff --git a/pkg/utils/tekton/pipelines.go b/pkg/utils/tekton/pipelines.go index 00e41b6e63..b22b2b9d38 100644 --- a/pkg/utils/tekton/pipelines.go +++ b/pkg/utils/tekton/pipelines.go @@ -5,6 +5,8 @@ import ( "strconv" "strings" + "github.com/redhat-appstudio/e2e-tests/pkg/utils" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/common" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -143,3 +145,14 @@ func (p VerifyEnterpriseContract) Generate() *v1beta1.PipelineRun { }, } } + +// GetFailedPipelineRunLogs gets the logs of the pipelinerun failed task +func GetFailedPipelineRunLogs(c *common.SuiteController, pipelineRun *v1beta1.PipelineRun) string { + failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) + d := utils.GetFailedPipelineRunDetails(pipelineRun) + if d.FailedContainerName != "" { + logs, _ := c.GetContainerLogs(d.PodName, d.FailedContainerName, pipelineRun.Namespace) + failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) + } + return failMessage +} diff --git a/tests/build/build.go b/tests/build/build.go index 01a039aab1..060a0c6ef1 100644 --- a/tests/build/build.go +++ b/tests/build/build.go @@ -11,12 +11,12 @@ import ( "github.com/google/go-github/v44/github" "github.com/redhat-appstudio/e2e-tests/pkg/utils/build" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" "github.com/devfile/library/pkg/util" "github.com/google/uuid" "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/utils" - u "github.com/redhat-appstudio/e2e-tests/tests/utils" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -195,7 +195,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) + failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) Fail(failMessage) } } @@ -268,7 +268,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) + failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) Fail(failMessage) } } @@ -340,7 +340,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) + failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) Fail(failMessage) } } @@ -470,7 +470,7 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", " } if !pipelineRun.GetStatusCondition().GetCondition(apis.ConditionSucceeded).IsTrue() { - failMessage := u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) + failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun) Fail(failMessage) } } diff --git a/tests/integration-service/integration.go b/tests/integration-service/integration.go index 522ec51e84..96fd4d1671 100644 --- a/tests/integration-service/integration.go +++ b/tests/integration-service/integration.go @@ -9,7 +9,7 @@ import ( "github.com/google/uuid" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" - u "github.com/redhat-appstudio/e2e-tests/tests/utils" + "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" appstudioApi "github.com/redhat-appstudio/application-api/api/v1alpha1" @@ -112,7 +112,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests GinkgoWriter.Printf("PipelineRun %s Status.Conditions.Reason: %s\n", pipelineRun.Name, condition.Reason) if condition.Reason == "Failed" { - Fail(u.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)) + Fail(tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)) } } return pipelineRun.IsDone() diff --git a/tests/utils/utils.go b/tests/utils/utils.go deleted file mode 100644 index e11f1d087b..0000000000 --- a/tests/utils/utils.go +++ /dev/null @@ -1,20 +0,0 @@ -package utils - -import ( - "fmt" - - "github.com/redhat-appstudio/e2e-tests/pkg/utils" - "github.com/redhat-appstudio/e2e-tests/pkg/utils/common" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" -) - -// GetFailedPipelineRunLogs gets the logs of the pipelinerun failed task -func GetFailedPipelineRunLogs(c *common.SuiteController, pipelineRun *v1beta1.PipelineRun) string { - failMessage := fmt.Sprintf("Pipelinerun '%s' didn't succeed\n", pipelineRun.Name) - d := utils.GetFailedPipelineRunDetails(pipelineRun) - if d.FailedContainerName != "" { - logs, _ := c.GetContainerLogs(d.PodName, d.FailedContainerName, pipelineRun.Namespace) - failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs) - } - return failMessage -}