From 9a2ac8b7c498b055b8e9429c420f22af4d697d7c Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 31 Aug 2020 18:20:55 +0200 Subject: [PATCH] roachtest: deflake some tests Release justification: non-production code changes Release note: None --- pkg/cmd/roachtest/cli.go | 7 +------ pkg/cmd/roachtest/decommission.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/roachtest/cli.go b/pkg/cmd/roachtest/cli.go index 4f05a95898c7..e569a3b0bbaa 100644 --- a/pkg/cmd/roachtest/cli.go +++ b/pkg/cmd/roachtest/cli.go @@ -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 { diff --git a/pkg/cmd/roachtest/decommission.go b/pkg/cmd/roachtest/decommission.go index dd2485836e80..3617d0a4669c 100644 --- a/pkg/cmd/roachtest/decommission.go +++ b/pkg/cmd/roachtest/decommission.go @@ -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 { @@ -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()