From 0d9f01e89049c4bda264231f2ee46213c46cfd61 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 12 Jun 2024 09:52:05 +0200 Subject: [PATCH] Add log for TestGHPullRequestConcurrencyMultiplePR Try to add some debugs for the tests and more logs collected by namespaces. Related to bug #1691 Signed-off-by: Chmouel Boudjnah --- hack/gh-workflow-ci.sh | 9 +++++++++ pkg/pipelineascode/concurrency.go | 3 +++ test/github_config_maxkeepruns_test.go | 3 ++- test/github_pullrequest_concurrency_multiplepr_test.go | 6 +++++- test/github_push_retest_test.go | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hack/gh-workflow-ci.sh b/hack/gh-workflow-ci.sh index 6fe2bd56c..8f27577c7 100755 --- a/hack/gh-workflow-ci.sh +++ b/hack/gh-workflow-ci.sh @@ -117,6 +117,15 @@ collect_logs() { kubectl get repositories.pipelinesascode.tekton.dev -A -o yaml >/tmp/logs/pac-repositories.yaml kubectl get configmap -n pipelines-as-code -o yaml >/tmp/logs/pac-configmap kubectl get events -A >/tmp/logs/events + + allNamespaces=$(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}') + for ns in ${allNamespaces}; do + mkdir -p /tmp/logs/ns/${ns} + for type in pods pipelineruns repositories configmap; do + kubectl get ${type} -n ${ns} -o yaml >/tmp/logs/ns/${ns}/${type}.yaml + done + kubectl -n ${ns} get events >/tmp/logs/ns/${ns}/events + done } help() { diff --git a/pkg/pipelineascode/concurrency.go b/pkg/pipelineascode/concurrency.go index 67b41a99b..9d90e354f 100644 --- a/pkg/pipelineascode/concurrency.go +++ b/pkg/pipelineascode/concurrency.go @@ -28,6 +28,9 @@ func (c *ConcurrencyManager) AddPipelineRun(pr *v1.PipelineRun) { if !c.enabled { return } + if pr == nil { + return + } c.mutex.Lock() defer c.mutex.Unlock() diff --git a/test/github_config_maxkeepruns_test.go b/test/github_config_maxkeepruns_test.go index e96f70e64..fba1e0d70 100644 --- a/test/github_config_maxkeepruns_test.go +++ b/test/github_config_maxkeepruns_test.go @@ -24,7 +24,8 @@ func TestGithubMaxKeepRuns(t *testing.T) { YamlFiles: []string{"testdata/pipelinerun-max-keep-run-1.yaml"}, } g.RunPullRequest(ctx, t) - defer g.TearDown(ctx, t) + // TODO: ree-nable back when we figure out the #1691 issue + // defer g.TearDown(ctx, t) g.Cnx.Clients.Log.Infof("Creating /retest in PullRequest") _, _, err := g.Provider.Client.Issues.CreateComment(ctx, g.Options.Organization, g.Options.Repo, g.PRNumber, diff --git a/test/github_pullrequest_concurrency_multiplepr_test.go b/test/github_pullrequest_concurrency_multiplepr_test.go index 109b53577..cec566514 100644 --- a/test/github_pullrequest_concurrency_multiplepr_test.go +++ b/test/github_pullrequest_concurrency_multiplepr_test.go @@ -137,7 +137,11 @@ func TestGithubSecondPullRequestConcurrencyMultiplePR(t *testing.T) { prs, err := runcnx.Clients.Tekton.TektonV1().PipelineRuns(targetNS).List(ctx, metav1.ListOptions{}) assert.NilError(t, err) - assert.Equal(t, len(prs.Items), allPipelinesRunAfterCleanUp, "we should have had %d kept after cleanup, we got %d", allPipelinesRunAfterCleanUp, len(prs.Items)) + allPipelineRunsNamesAndStatus := []string{} + for _, pr := range prs.Items { + allPipelineRunsNamesAndStatus = append(allPipelineRunsNamesAndStatus, fmt.Sprintf("%s %s", pr.Name, pr.Status.GetConditions())) + } + assert.Equal(t, len(prs.Items), allPipelinesRunAfterCleanUp, "we should have had %d kept after cleanup, we got %d: %v", allPipelinesRunAfterCleanUp, len(prs.Items), allPipelineRunsNamesAndStatus) runcnx.Clients.Log.Infof("success: number of cleaned PR is %d we expected to have %d after the cleanup", len(prs.Items), allPipelinesRunAfterCleanUp) diff --git a/test/github_push_retest_test.go b/test/github_push_retest_test.go index 7ab887467..5220a6c8c 100644 --- a/test/github_push_retest_test.go +++ b/test/github_push_retest_test.go @@ -77,7 +77,8 @@ func TestGithubPushRequestGitOpsCommentCancel(t *testing.T) { SecondController: false, } g.RunPushRequest(ctx, t) - defer g.TearDown(ctx, t) + // TODO: ree-nable back when we figure out the #1691 issue + // defer g.TearDown(ctx, t) ctx, err := cctx.GetControllerCtxInfo(ctx, g.Cnx) assert.NilError(t, err)