From 6bee36077a01a56f7eb016e88f58cc81fa5c3340 Mon Sep 17 00:00:00 2001 From: Nick Vigilante Date: Mon, 18 Sep 2023 13:31:30 -0400 Subject: [PATCH] docs-issue-gen: Fix testing failures Fixes #110682 #110704 Release note: none --- pkg/cmd/docs-issue-generation/BUILD.bazel | 1 - .../docs_issue_generation_test.go | 6 +++-- pkg/cmd/docs-issue-generation/extract.go | 26 ++++++++++++------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/docs-issue-generation/BUILD.bazel b/pkg/cmd/docs-issue-generation/BUILD.bazel index cf59af720b2a..7d98593aabd1 100644 --- a/pkg/cmd/docs-issue-generation/BUILD.bazel +++ b/pkg/cmd/docs-issue-generation/BUILD.bazel @@ -35,7 +35,6 @@ go_test( embed = [":docs-issue-generation_lib"], deps = [ "//pkg/testutils", - "//pkg/testutils/skip", "@com_github_stretchr_testify//assert", ], ) diff --git a/pkg/cmd/docs-issue-generation/docs_issue_generation_test.go b/pkg/cmd/docs-issue-generation/docs_issue_generation_test.go index 9cd8961f5d85..eef667288de9 100644 --- a/pkg/cmd/docs-issue-generation/docs_issue_generation_test.go +++ b/pkg/cmd/docs-issue-generation/docs_issue_generation_test.go @@ -16,7 +16,6 @@ import ( "testing" "github.com/cockroachdb/cockroach/pkg/testutils" - "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/stretchr/testify/assert" ) @@ -3021,7 +3020,6 @@ Release note (sql change): Something something something...`, } func TestExtractEpicIDs(t *testing.T) { - skip.WithIssue(t, 110682, "Flakes when run under stressful conditions") testCases := []struct { message string expected map[string]int @@ -3073,6 +3071,10 @@ Release note (sql change): Import now checks readability...`, IsEpic: false, EpicKey: "CRDB-18955", }, + "CRDB-18955": { + IsEpic: true, + EpicKey: "CRDB-18955", + }, } return epicMap[issueKey].IsEpic, epicMap[issueKey].EpicKey, nil })() diff --git a/pkg/cmd/docs-issue-generation/extract.go b/pkg/cmd/docs-issue-generation/extract.go index 03e94938896d..95a781a0ee21 100644 --- a/pkg/cmd/docs-issue-generation/extract.go +++ b/pkg/cmd/docs-issue-generation/extract.go @@ -13,6 +13,7 @@ package main import ( "fmt" "regexp" + "sort" "strconv" "strings" ) @@ -90,33 +91,40 @@ func extractInformIssueIDs(message string) map[string]int { func extractEpicIDs(message string) map[string]int { result := extractStringsFromMessage(message, epicRefRE, jiraIssueRefRE) - for issueKey, count := range result { + keys := make([]string, 0, len(result)) + for key := range result { + keys = append(keys, key) + } + sort.Strings(keys) + for _, key := range keys { + count := result[key] var isEpic bool - epicKey, ok := invalidEpicRefs[issueKey] + epicKey, ok := invalidEpicRefs[key] if ok { - isEpic = epicKey == issueKey + isEpic = epicKey == key } else { var err error - isEpic, epicKey, err = getValidEpicRef(issueKey) + isEpic, epicKey, err = getValidEpicRef(key) if err != nil { // if the supplied issueKey is bad or there's a problem with the Jira REST API, simply print out // the error message, but don't return it. Instead, remove the epic from the list, since we were // unable to validate whether it was an epic, and we strictly need a valid epic key. - fmt.Printf("error: Unable to determine whether %s is a valid epic. Caused by:\n%s\n", issueKey, err) - delete(result, issueKey) + fmt.Printf("error: Unable to determine whether %s is a valid epic. Caused by:\n%s\n", key, err) + delete(result, key) continue } if epicKey != "" { - invalidEpicRefs[issueKey] = epicKey + invalidEpicRefs[key] = epicKey + invalidEpicRefs[epicKey] = epicKey } } if isEpic { continue - } else if issueKey != epicKey { + } else if key != epicKey { if epicKey != "" { result[epicKey] = count } - delete(result, issueKey) + delete(result, key) } } return result