Skip to content
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 4 additions & 2 deletions pkg/utils/has/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"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"
Expand Down Expand Up @@ -416,7 +418,7 @@ func (h *SuiteController) GetComponentService(componentName string, componentNam
return service, nil
}

func (h *SuiteController) WaitForComponentPipelineToBeFinished(componentName string, applicationName string, componentNamespace string, sha string) error {
func (h *SuiteController) WaitForComponentPipelineToBeFinished(c *common.SuiteController, componentName, applicationName, componentNamespace, sha string) error {
return wait.PollImmediate(20*time.Second, 25*time.Minute, func() (done bool, err error) {
pipelineRun, err := h.GetComponentPipelineRun(componentName, applicationName, componentNamespace, sha)

Expand All @@ -429,7 +431,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(tekton.GetFailedPipelineRunLogs(c, pipelineRun))
}

if condition.Status == corev1.ConditionTrue {
Expand Down
13 changes: 13 additions & 0 deletions pkg/utils/tekton/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
30 changes: 6 additions & 24 deletions tests/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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"
Expand Down Expand Up @@ -194,12 +195,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.AsKubeAdmin.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace)
failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs)
}
failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)
Fail(failMessage)
}
}
Expand Down Expand Up @@ -272,12 +268,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.AsKubeAdmin.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace)
failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs)
}
failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)
Fail(failMessage)
}
}
Expand Down Expand Up @@ -332,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
Expand All @@ -348,12 +340,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.AsKubeAdmin.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace)
failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs)
}
failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)
Fail(failMessage)
}
}
Expand Down Expand Up @@ -483,12 +470,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.AsKubeAdmin.CommonController.GetContainerLogs(d.PodName, d.FailedContainerName, testNamespace)
failMessage += fmt.Sprintf("Logs from failed container '%s': \n%s", d.FailedContainerName, logs)
}
failMessage := tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun)
Fail(failMessage)
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e-demos/e2e-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ var _ = framework.E2ESuiteDescribe(Label("e2e-demo"), func() {
err = fw.AsKubeDeveloper.HasController.KubeRest().Update(context.Background(), component)
Expect(err).ShouldNot(HaveOccurred(), "failed to update component to trigger another pipeline build: %v", err)
}
Expect(fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(component.Name, application.Name, namespace, "")).To(Succeed(), "Failed component pipeline %v", err)

err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.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() {
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e-demos/multi-component.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,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.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(compNameGo, testSpecification.Tests[0].ApplicationName, namespace, "")
err := fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameGo, testSpecification.Tests[0].ApplicationName, namespace, "")
if err != nil {
removeApplication = false
Fail(fmt.Sprint(err))
}
Expect(err).NotTo(HaveOccurred(), "Failed component pipeline %v", err)

err = fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(compNameNode, testSpecification.Tests[0].ApplicationName, namespace, "")
err = fw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(fw.AsKubeAdmin.CommonController, compNameNode, testSpecification.Tests[0].ApplicationName, namespace, "")
if err != nil {
removeApplication = false
Fail(fmt.Sprint(err))
}
Expect(err).NotTo(HaveOccurred(), "Failed component pipeline %v", err)
})

It("finds the snapshot and checks if it is marked as successful for golang component", func() {
Expand Down
3 changes: 2 additions & 1 deletion tests/integration-service/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton"

appstudioApi "github.com/redhat-appstudio/application-api/api/v1alpha1"

Expand Down Expand Up @@ -111,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(fmt.Sprintf("Pipelinerun %s has failed", pipelineRun.Name))
Fail(tekton.GetFailedPipelineRunLogs(f.AsKubeAdmin.CommonController, pipelineRun))
}
}
return pipelineRun.IsDone()
Expand Down
4 changes: 2 additions & 2 deletions tests/mvp-demo/mvp-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down