Skip to content

Commit

Permalink
fix: filter unexpected pruns in e2e MultiplePR
Browse files Browse the repository at this point in the history
Test was failing due to counting unrelated PipelineRuns. Fixed by
filtering
results to only count PipelineRuns matching the test's naming pattern.

error:

```
github_pullrequest_concurrency_multiplepr_test.go:144: assertion failed:
10 (int) != 9 (allPipelinesRunAfterCleanUp int): we should have had 9
kept after cleanup, we got 10: [no-match-ng84l [{Succeeded False
{2025-03-05 13:41:06 +0000 UTC} Cancelled PipelineRun "no-match-ng84l"
was cancelled}] prlongrunnning-fqmf-1-eyle-9tv54 [{Succeeded True
{2025-03-05 13:41:41 +0000 UTC} Succeeded Tasks Completed: 1 (Failed: 0,
Cancelled 0), Skipped: 0}] prlongrunnning-fqmf-2-smfw-xmc6j [{Succeeded
True  {2025-03-05 13:41:56 +0000 UTC} Succeeded Tasks Completed: 1
(Failed: 0, Cancelled 0), Skipped: 0}] prlongrunnning-fqmf-3-oowj-5tk8v
[{Succeeded True  {2025-03-05 13:42:11 +0000 UTC} Succeeded Tasks
Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0}]
prlongrunnning-piwd-1-kpby-fhz29 [{Succeeded True  {2025-03-05 13:40:57
+0000 UTC} Succeeded Tasks Completed: 1 (Failed: 0, Cancelled 0),
Skipped: 0}] prlongrunnning-piwd-2-zmdb-587lp [{Succeeded True
{2025-03-05 13:41:11 +0000 UTC} Succeeded Tasks Completed: 1 (Failed: 0,
Cancelled 0), Skipped: 0}] prlongrunnning-piwd-3-zdht-7p4f6 [{Succeeded
True  {2025-03-05 13:41:26 +0000 UTC} Succeeded Tasks Completed: 1
(Failed: 0, Cancelled 0), Skipped: 0}] prlongrunnning-zunz-1-gctg-gxh4q
[{Succeeded True  {2025-03-05 13:40:12 +0000 UTC} Succeeded Tasks
Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0}]
prlongrunnning-zunz-2-bpsb-sfvr5 [{Succeeded True  {2025-03-05 13:40:26
+0000 UTC} Succeeded Tasks Completed: 1 (Failed: 0, Cancelled 0),
Skipped: 0}] prlongrunnning-zunz-3-hdth-gn9gw [{Succeeded True
{2025-03-05 13:40:41 +0000 UTC} Succeeded Tasks Completed: 1 (Failed: 0,
Cancelled 0), Skipped: 0}]]
```

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Mar 5, 2025
1 parent cc30250 commit 8e14a3a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/github_pullrequest_concurrency_multiplepr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,16 @@ func TestGithubSecondPullRequestConcurrencyMultiplePR(t *testing.T) {
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)
// Filter out PipelineRuns that don't match our pattern
matchingPRs := []tektonv1.PipelineRun{}
for _, pr := range prs.Items {
if strings.HasPrefix(pr.Name, "prlongrunnning-") {
matchingPRs = append(matchingPRs, pr)
}
}
assert.Equal(t, len(matchingPRs), 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)
runcnx.Clients.Log.Infof("success: number of cleaned PR is %d we expected to have %d after the cleanup", len(matchingPRs), allPipelinesRunAfterCleanUp)

if os.Getenv("TEST_NOCLEANUP") != "true" {
repository.NSTearDown(ctx, t, runcnx, targetNS)
Expand Down

0 comments on commit 8e14a3a

Please sign in to comment.