Skip to content

Commit

Permalink
Merge #110844
Browse files Browse the repository at this point in the history
110844: docs-issue-gen: Fix testing failures r=nickvigilante a=nickvigilante

Fixes #110682 #110704

Release note: none

Co-authored-by: Nick Vigilante <[email protected]>
  • Loading branch information
craig[bot] and Nick Vigilante committed Sep 18, 2023
2 parents b734315 + 6bee360 commit 9c42488
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion pkg/cmd/docs-issue-generation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ go_test(
embed = [":docs-issue-generation_lib"],
deps = [
"//pkg/testutils",
"//pkg/testutils/skip",
"@com_github_stretchr_testify//assert",
],
)
6 changes: 4 additions & 2 deletions pkg/cmd/docs-issue-generation/docs_issue_generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
})()
Expand Down
26 changes: 17 additions & 9 deletions pkg/cmd/docs-issue-generation/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package main
import (
"fmt"
"regexp"
"sort"
"strconv"
"strings"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c42488

Please sign in to comment.