Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove simple build dependency from tests #1273

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion magefiles/rulesengine/repos/e2e_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func CheckCmdFilesChanged(rctx *rulesengine.RuleCtx) bool {

func ExecuteDefaultTestAction(rctx *rulesengine.RuleCtx) error {

rctx.LabelFilter = "!upgrade-create && !upgrade-verify && !upgrade-cleanup && !release-pipelines"
rctx.LabelFilter = "!upgrade-create && !upgrade-verify && !upgrade-cleanup && release-pipelines"
return ExecuteTestAction(rctx)

}
Expand Down
4 changes: 2 additions & 2 deletions pkg/clients/has/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ func (h *HasController) WaitForComponentPipelineToBeFinished(component *appservi
}

var prLogs string
if err = t.StorePipelineRun(pr); err != nil {
if err = t.StorePipelineRun(component.GetName(), pr); err != nil {
GinkgoWriter.Printf("failed to store PipelineRun %s:%s: %s\n", pr.GetNamespace(), pr.GetName(), err.Error())
}
if prLogs, err = t.GetPipelineRunLogs(pr.Name, pr.Namespace); err != nil {
if prLogs, err = t.GetPipelineRunLogs(component.GetName(), pr.Name, pr.Namespace); err != nil {
GinkgoWriter.Printf("failed to get logs for PipelineRun %s:%s: %s\n", pr.GetNamespace(), pr.GetName(), err.Error())
}

Expand Down
15 changes: 7 additions & 8 deletions pkg/clients/tekton/pipelineruns.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ func (t *TektonController) GetPipelineRun(pipelineRunName, namespace string) (*p
}

// GetPipelineRunLogs returns logs of a given pipelineRun.
func (t *TektonController) GetPipelineRunLogs(pipelineRunName, namespace string) (string, error) {
func (t *TektonController) GetPipelineRunLogs(prefix, pipelineRunName, namespace string) (string, error) {
podClient := t.KubeInterface().CoreV1().Pods(namespace)
podList, err := podClient.List(context.Background(), metav1.ListOptions{})
if err != nil {
return "", err
}
podLog := ""
for _, pod := range podList.Items {
if !strings.HasPrefix(pod.Name, pipelineRunName) {
if !strings.HasPrefix(pod.Name, prefix) {
continue
}
for _, c := range pod.Spec.InitContainers {
var err error
var cLog string
cLog, err = t.fetchContainerLog(pod.Name, c.Name, namespace)
podLog = podLog + fmt.Sprintf("\ninit container %s: \n", c.Name) + cLog
podLog = podLog + fmt.Sprintf("\n pod: %s | init container: %s\n", pod.Name, c.Name) + cLog
if err != nil {
return podLog, err
}
Expand All @@ -94,7 +94,7 @@ func (t *TektonController) GetPipelineRunLogs(pipelineRunName, namespace string)
var err error
var cLog string
cLog, err = t.fetchContainerLog(pod.Name, c.Name, namespace)
podLog = podLog + fmt.Sprintf("\ncontainer %s: \n", c.Name) + cLog
podLog = podLog + fmt.Sprintf("\npod: %s | container %s: \n", pod.Name, c.Name) + cLog
if err != nil {
return podLog, err
}
Expand Down Expand Up @@ -215,7 +215,6 @@ func (t *TektonController) DeletePipelineRunIgnoreFinalizers(ns, name string) er
return nil
}


// DeleteAllPipelineRunsInASpecificNamespace deletes all PipelineRuns in a given namespace (removing the finalizers field, first)
func (t *TektonController) DeleteAllPipelineRunsInASpecificNamespace(ns string) error {

Expand All @@ -235,9 +234,9 @@ func (t *TektonController) DeleteAllPipelineRunsInASpecificNamespace(ns string)
}

// StorePipelineRun stores a given PipelineRun as an artifact.
func (t *TektonController) StorePipelineRun(pipelineRun *pipeline.PipelineRun) error {
func (t *TektonController) StorePipelineRun(prefix string, pipelineRun *pipeline.PipelineRun) error {
artifacts := make(map[string][]byte)
pipelineRunLog, err := t.GetPipelineRunLogs(pipelineRun.Name, pipelineRun.Namespace)
pipelineRunLog, err := t.GetPipelineRunLogs(prefix, pipelineRun.Name, pipelineRun.Namespace)
if err != nil {
return err
}
Expand Down Expand Up @@ -265,7 +264,7 @@ func (t *TektonController) StoreAllPipelineRuns(namespace string) error {

for _, pipelineRun := range pipelineRuns.Items {
pipelineRun := pipelineRun
if err := t.StorePipelineRun(&pipelineRun); err != nil {
if err := t.StorePipelineRun(pipelineRun.GetName(), &pipelineRun); err != nil {
return fmt.Errorf("got error storing PR: %v\n", err.Error())
}
}
Expand Down
21 changes: 21 additions & 0 deletions pkg/utils/build/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"fmt"
"os"
"strconv"
"strings"

"github.com/konflux-ci/e2e-tests/pkg/clients/github"
"github.com/konflux-ci/e2e-tests/pkg/constants"
"github.com/konflux-ci/e2e-tests/pkg/framework"
"github.com/konflux-ci/e2e-tests/pkg/utils"
)

Expand All @@ -33,3 +35,22 @@ func ResolveGitDetails(repoUrlENV, repoRevisionENV string) (string, string, erro
}
return utils.GetEnv(repoUrlENV, defaultGitURL), utils.GetEnv(repoRevisionENV, defaultGitRevision), nil
}

func CleanupWebhooks(f *framework.Framework, repoName string) error {
hooks, err := f.AsKubeAdmin.CommonController.Github.ListRepoWebhooks(repoName)
if err != nil {
return err
}
for _, h := range hooks {
hookUrl := h.Config["url"].(string)
if strings.Contains(hookUrl, f.ClusterAppDomain) {
fmt.Printf("removing webhook URL: %s\n", hookUrl)
err = f.AsKubeAdmin.CommonController.Github.DeleteWebhook(repoName, h.GetID())
if err != nil {
return err
}
break
}
}
return nil
}
28 changes: 1 addition & 27 deletions pkg/utils/build/task_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,9 @@ type Vulnerabilities struct {
Low int `json:"low"`
}

type PipelineBuildInfo struct {
runtime string
strategy string
}

func GetPipelineBuildInfo(pr *pipeline.PipelineRun) PipelineBuildInfo {
labels := pr.GetLabels()
runtime := labels["pipelines.openshift.io/runtime"]
strategy := labels["pipelines.openshift.io/strategy"]
return PipelineBuildInfo{
runtime: runtime,
strategy: strategy,
}
}

func IsDockerBuild(pr *pipeline.PipelineRun) bool {
info := GetPipelineBuildInfo(pr)
return info.runtime == "generic" && info.strategy == "docker"
}

func IsFBCBuild(pr *pipeline.PipelineRun) bool {
info := GetPipelineBuildInfo(pr)
return info.runtime == "fbc" && info.strategy == "fbc"
}

func ValidateBuildPipelineTestResults(pipelineRun *pipeline.PipelineRun, c crclient.Client) error {
func ValidateBuildPipelineTestResults(pipelineRun *pipeline.PipelineRun, c crclient.Client, isFBCBuild bool) error {
for _, taskName := range taskNames {
// The inspect-image task is only required for FBC pipelines which we can infer by the component name
isFBCBuild := IsFBCBuild(pipelineRun)

if !isFBCBuild && taskName == "inspect-image" {
continue
Expand Down
Loading
Loading