Skip to content

Commit

Permalink
Add log for TestGHPullRequestConcurrencyMultiplePR
Browse files Browse the repository at this point in the history
Try to add some debugs for the tests and more logs collected by
namespaces.

Related to bug #1691

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Jun 12, 2024
1 parent 35d7f7c commit b466ac7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions hack/gh-workflow-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions pkg/pipelineascode/concurrency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 5 additions & 1 deletion test/github_pullrequest_concurrency_multiplepr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b466ac7

Please sign in to comment.