Skip to content

Commit

Permalink
roachtest: deflake some tests
Browse files Browse the repository at this point in the history
Release justification: non-production code changes

Release note: None
  • Loading branch information
knz committed Aug 31, 2020
1 parent ce1ef2a commit 9a2ac8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions pkg/cmd/roachtest/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ func runCLINodeStatus(ctx context.Context, t *test, c *cluster) {

lastWords := func(s string) []string {
var result []string
s = elideInsecureDeprecationNotice(s)
lines := strings.Split(s, "\n")
// v20.1 introduces a deprecation notice for --insecure. Skip over it.
// TODO(knz): Remove this when --insecure is dropped.
// See: https://github.com/cockroachdb/cockroach/issues/53404
if len(lines) > 0 && strings.HasPrefix(lines[0], "Flag --insecure has been deprecated") {
lines = lines[2:]
}
for _, line := range lines {
words := strings.Fields(line)
if n := len(words); n > 0 {
Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/roachtest/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,20 @@ func (h *decommTestHelper) recommission(
return execCLI(ctx, h.t, h.c, runNode, args...)
}

func elideInsecureDeprecationNotice(csvStr string) string {
// v20.1 introduces a deprecation notice for --insecure. Skip over it.
// TODO(knz): Remove this when --insecure is dropped.
// See: https://github.com/cockroachdb/cockroach/issues/53404
lines := strings.SplitN(csvStr, "\n", 3)
if len(lines) > 0 && strings.HasPrefix(lines[0], "Flag --insecure has been deprecated") {
csvStr = lines[2]
}
return csvStr
}

// getCsvNumCols returns the number of columns in the given csv string.
func (h *decommTestHelper) getCsvNumCols(csvStr string) (cols int) {
csvStr = elideInsecureDeprecationNotice(csvStr)
reader := csv.NewReader(strings.NewReader(csvStr))
records, err := reader.Read()
if err != nil {
Expand All @@ -922,6 +934,7 @@ func (h *decommTestHelper) matchCSV(csvStr string, matchColRow [][]string) (err
}
}()

csvStr = elideInsecureDeprecationNotice(csvStr)
reader := csv.NewReader(strings.NewReader(csvStr))
reader.FieldsPerRecord = -1
records, err := reader.ReadAll()
Expand Down

0 comments on commit 9a2ac8b

Please sign in to comment.