Skip to content

Commit

Permalink
roachtest: fix drain check in decommission/drains
Browse files Browse the repository at this point in the history
Fixes cockroachdb#75774.

This patch fixes the drain check in the test, which was previously
done incorrectly.

Release note: None
  • Loading branch information
cameronnunez committed Feb 2, 2022
1 parent 577e9b0 commit 817b12d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/cmd/roachtest/tests/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"math/rand"
"reflect"
"strconv"
"strings"
"time"

"github.com/cockroachdb/cockroach/pkg/cli"
Expand Down Expand Up @@ -1082,14 +1083,15 @@ func runDecommissionDrains(ctx context.Context, t test.Test, c cluster.Cluster)
}

// Check to see if the node has been drained.
// If not, send a query and verify that the query does not fail.
if decommNodeDB.Ping() != nil { // not drained
err = run(decommNodeDB, `SHOW DATABASES`)
require.NoError(t, err)
return errors.New("not drained")
// If not, queries should not fail.
if err = run(decommNodeDB, `SHOW DATABASES`); err != nil {
if strings.Contains(err.Error(), "not accepting clients") { // drained
return nil
}
t.Fatal(err)
}

return nil
return errors.New("not drained")
})
require.NoError(t, e)

Expand Down

0 comments on commit 817b12d

Please sign in to comment.