@@ -18,14 +18,15 @@ import (
18
18
"database/sql"
19
19
"errors"
20
20
"fmt"
21
- "github.com/cockroachdb/cockroach-go/v2/testserver/version"
22
21
"log"
23
22
"net"
24
23
"net/url"
25
24
"os/exec"
26
25
"path/filepath"
27
26
"strconv"
28
27
"strings"
28
+
29
+ "github.com/cockroachdb/cockroach-go/v2/testserver/version"
29
30
)
30
31
31
32
func (ts * testServerImpl ) isTenant () bool {
@@ -53,11 +54,11 @@ func (ts *testServerImpl) NewTenantServer(proxy bool) (TestServer, error) {
53
54
if proxy && ! ts .serverArgs .secure {
54
55
return nil , fmt .Errorf ("%s: proxy cannot be used with insecure mode" , tenantserverMessagePrefix )
55
56
}
56
- cockroachBinary := ts .cmdArgs [ 0 ]
57
+ cockroachBinary := ts .serverArgs . cockroachBinary
57
58
tenantID , err := func () (int , error ) {
58
59
ts .mu .Lock ()
59
60
defer ts .mu .Unlock ()
60
- if ts .state != stateRunning {
61
+ if ts .nodes [ 0 ]. state != stateRunning {
61
62
return 0 , errors .New ("TestServer must be running before NewTenantServer may be called" )
62
63
}
63
64
if ts .isTenant () {
@@ -147,7 +148,7 @@ func (ts *testServerImpl) NewTenantServer(proxy bool) (TestServer, error) {
147
148
}
148
149
149
150
proxyAddr , err := func () (string , error ) {
150
- <- ts .pgURL .set
151
+ <- ts .pgURL [ 0 ] .set
151
152
152
153
ts .mu .Lock ()
153
154
defer ts .mu .Unlock ()
@@ -203,25 +204,33 @@ func (ts *testServerImpl) NewTenantServer(proxy bool) (TestServer, error) {
203
204
"--http-addr=:0" ,
204
205
}
205
206
207
+ nodes := []nodeInfo {
208
+ {
209
+ state : stateNew ,
210
+ startCmdArgs : args ,
211
+ // TODO(asubiotto): Specify listeningURLFile once we support dynamic
212
+ // ports.
213
+ listeningURLFile : "" ,
214
+ },
215
+ }
216
+
206
217
tenant := & testServerImpl {
207
- serverArgs : ts .serverArgs ,
208
- version : ts .version ,
209
- state : stateNew ,
210
- baseDir : ts .baseDir ,
211
- cmdArgs : args ,
212
- stdout : filepath .Join (ts .baseDir , logsDirName , fmt .Sprintf ("cockroach.tenant.%d.stdout" , tenantID )),
213
- stderr : filepath .Join (ts .baseDir , logsDirName , fmt .Sprintf ("cockroach.tenant.%d.stderr" , tenantID )),
214
- // TODO(asubiotto): Specify listeningURLFile once we support dynamic
215
- // ports.
216
- listeningURLFile : "" ,
218
+ serverArgs : ts .serverArgs ,
219
+ version : ts .version ,
220
+ serverState : stateNew ,
221
+ baseDir : ts .baseDir ,
222
+ stdout : filepath .Join (ts .baseDir , logsDirName , fmt .Sprintf ("cockroach.tenant.%d.stdout" , tenantID )),
223
+ stderr : filepath .Join (ts .baseDir , logsDirName , fmt .Sprintf ("cockroach.tenant.%d.stderr" , tenantID )),
224
+ nodes : nodes ,
217
225
}
218
226
219
227
// Start the tenant.
220
228
// Initialize direct connection to the tenant. We need to use `orig` instead of `pgurl` because if the test server
221
229
// is using a root password, this password does not carry over to the tenant; client certs will, though.
222
- tenantURL := ts .pgURL .orig
230
+ tenantURL := ts .pgURL [ 0 ] .orig
223
231
tenantURL .Host = sqlAddr
224
- tenant .pgURL .set = make (chan struct {})
232
+ tenant .pgURL = make ([]pgURLChan , 1 )
233
+ tenant .pgURL [0 ].set = make (chan struct {})
225
234
226
235
tenant .setPGURL (& tenantURL )
227
236
if err := tenant .Start (); err != nil {
0 commit comments