Skip to content

Commit

Permalink
cli/interactive_tests: complete the end-to-end test for `cockroach co…
Browse files Browse the repository at this point in the history
…nnect`

The end-to-end test for the new `connect` command was incomplete,
because of issue cockroachdb#61624 that was blocking the functionality.

Now that cockroachdb#63589 is in, we can add the missing test.

Release note: None
  • Loading branch information
knz committed Apr 19, 2021
1 parent 60dba10 commit 15bd009
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions pkg/cli/interactive_tests/test_connect.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,37 @@ eexpect "cert files generated in: certs/n1"
eexpect ":/# "
end_test

# Keep the generated certs for both nodes to the artifacts directory.
system "cp -a certs logs/"

# NB: we will be able to remove the manual generation of root certs
# some time in the future.
system "$argv cert create-client root --ca-key=certs/n1/ca-client.key --certs-dir=certs/n1"
system "$argv cert create-client root --ca-key=certs/n2/ca-client.key --certs-dir=certs/n2"

# TODO(knz): Also test multi-server start once the advertise addresses are populated.
#
# start_test "Check that we can start two servers using the newly minted certs."
# send "$argv start --listen-addr=`cat hostname.txt`:26257 --http-addr=`cat hostname.txt`:8080 --join=`cat hostname.txt`:26258 --certs-dir=certs/n1 --store=logs/db1 --vmodule='*=1'\r"
# eexpect "initial startup completed"
#
# set spawn_id $shell2_spawn_id
# send "$argv start --listen-addr=`cat hostname.txt`:26258 --http-addr=`cat hostname.txt`:8081 --join=`cat hostname.txt`:26257 --certs-dir=certs/n2 --store=logs/db2 --vmodule='*=1'\r"
# eexpect "initial startup completed"
start_test "Check that we can start two servers using the newly minted certs."
send "$argv start --listen-addr=`cat hostname.txt`:26257 --http-addr=`cat hostname.txt`:8080 --join=`cat hostname.txt`:26258 --certs-dir=certs/n1 --store=logs/db1 --pid-file=server_pid1 --vmodule='*=1'\r"
eexpect "initial startup completed"

set spawn_id $shell2_spawn_id
send "$argv start --listen-addr=`cat hostname.txt`:26258 --http-addr=`cat hostname.txt`:8081 --join=`cat hostname.txt`:26257 --certs-dir=certs/n2 --store=logs/db2 --pid-file=server_pid2 --vmodule='*=1'\r"
eexpect "initial startup completed"

# Now initialize the cluster to trigger generation of the node IDs.
system "$argv init --certs-dir=certs/n1 --host `cat hostname.txt`"

# Now expect the startup messages on both process outputs.
eexpect "CockroachDB node starting"
set spawn_id $shell1_spawn_id
eexpect "CockroachDB node starting"
end_test

start_test "Check we can connect a SQL client to the newly initialized two nodes"
system "$argv sql --certs-dir=certs/n1 --host=`cat hostname.txt`:26257 -e 'select 1'"
system "$argv sql --certs-dir=certs/n2 --host=`cat hostname.txt`:26258 -e 'select 1'"
end_test

# Stop the servers. We do not care about graceful shutdown here since we are not
# using the server files again beyond this point.
system "kill -9 `cat server_pid1 server_pid2`"

0 comments on commit 15bd009

Please sign in to comment.