Skip to content

Commit

Permalink
logictest: fix user cmd to respect nodeidx for cockroach-go testserver
Browse files Browse the repository at this point in the history
This patch fixes the client creation for logic tests that use the
cockroach-go testserver to use the specified nodeidx when connecting.

Release note: None
  • Loading branch information
andyyang890 committed Feb 2, 2023
1 parent f99717d commit 62315f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,9 @@ func (t *logicTest) setUser(user string, nodeIdx int) func() {
var cleanupFunc func()
pgUser = strings.TrimPrefix(user, "host-cluster-")
if t.cfg.UseCockroachGoTestserver {
pgURL = *t.testserverCluster.PGURL()
pgURL = *t.testserverCluster.PGURLForNode(nodeIdx)
pgURL.User = url.User(pgUser)
pgURL.Path = "test"
cleanupFunc = func() {}
} else {
addr = t.cluster.Server(nodeIdx).ServingSQLAddr()
Expand Down
23 changes: 23 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/testserver_upgrade_node
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ SELECT crdb_internal.node_executable_version()
----
22.2

# start of test that user cmd nodeidx opt works when used for a previously used user

user root nodeidx=2

query T
SELECT crdb_internal.node_executable_version()
----
22.2

query B
SELECT crdb_internal.node_executable_version() SIMILAR TO '1000022.2-%'
----
false

user root nodeidx=0

query B
SELECT crdb_internal.node_executable_version() SIMILAR TO '1000022.2-%'
----
true

# end of test that user cmd nodeidx opt works when used for a previously used user

upgrade 2

query B
Expand Down

0 comments on commit 62315f7

Please sign in to comment.