Skip to content

Commit d9722f0

Browse files
committed
cli/interactive_tests: use interrupt_and_wait helper everywhere
This helper was added in 799f5ab to reduce flakiness by waiting for process termination. This patch applies the same change to other tests that benefit. Release note: None
1 parent f276f1a commit d9722f0

File tree

6 files changed

+30
-62
lines changed

6 files changed

+30
-62
lines changed

pkg/cli/interactive_tests/test_encryption.tcl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ end_test
4545
start_test "Start normal node."
4646
send "$argv start-single-node --insecure --store=$storedir\r"
4747
eexpect "node starting"
48-
interrupt
49-
eexpect "shutdown completed"
48+
interrupt_and_wait
5049
send "$argv debug encryption-status $storedir\r"
5150
eexpect ""
5251
end_test
@@ -59,22 +58,19 @@ end_test
5958
start_test "Restart with plaintext."
6059
send "$argv start-single-node --insecure --store=$storedir --enterprise-encryption=path=$storedir,key=plain,old-key=plain\r"
6160
eexpect "node starting"
62-
interrupt
63-
eexpect "shutdown completed"
61+
interrupt_and_wait
6462
send "$argv debug encryption-status $storedir --enterprise-encryption=path=$storedir,key=plain,old-key=plain\r"
6563
eexpect " \"Active\": true,\r\n \"Type\": \"Plaintext\","
6664
# Try starting without the encryption flag.
6765
send "$argv start-single-node --insecure --store=$storedir\r"
6866
eexpect "node starting"
69-
interrupt
70-
eexpect "shutdown completed"
67+
interrupt_and_wait
7168
end_test
7269

7370
start_test "Restart with AES-128."
7471
send "$argv start-single-node --insecure --store=$storedir --enterprise-encryption=path=$storedir,key=$keydir/aes-128.key,old-key=plain\r"
7572
eexpect "node starting"
76-
interrupt
77-
eexpect "shutdown completed"
73+
interrupt_and_wait
7874
file_not_exists "$storedir/COCKROACHDB_REGISTRY"
7975
send "$argv debug encryption-status $storedir --enterprise-encryption=path=$storedir,key=$keydir/aes-128.key,old-key=plain\r"
8076
eexpect " \"Active\": true,\r\n \"Type\": \"AES128_CTR\","
@@ -89,14 +85,13 @@ end_test
8985
start_test "Restart with AES-256."
9086
send "$argv start-single-node --insecure --store=$storedir --enterprise-encryption=path=$storedir,key=$keydir/aes-256.key,old-key=$keydir/aes-128.key\r"
9187
eexpect "node starting"
92-
interrupt
93-
eexpect "shutdown completed"
88+
interrupt_and_wait
9489
send "$argv debug encryption-status $storedir --enterprise-encryption=path=$storedir,key=$keydir/aes-256.key,old-key=plain\r"
9590
eexpect " \"Active\": true,\r\n \"Type\": \"AES256_CTR\","
9691
# Startup again, but don't specify the old key, it's no longer in use.
9792
send "$argv start-single-node --insecure --store=$storedir --enterprise-encryption=path=$storedir,key=$keydir/aes-256.key,old-key=plain\r"
9893
eexpect "node starting"
99-
interrupt
94+
interrupt_and_wait
10095
# Try starting without the encryption flag.
10196
send "$argv start-single-node --insecure --store=$storedir\r"
10297
eexpect "encryption was used on this store before, but no encryption flags specified."
@@ -116,6 +111,5 @@ end_test
116111
start_test "Run with WAL failover path."
117112
send "$argv start-single-node --insecure --store=$storedir --wal-failover=path=$failoverdir --enterprise-encryption=path=$storedir,key=$keydir/aes-256.key,old-key=$keydir/aes-128.key --enterprise-encryption=path=$failoverdir,key=$keydir/aes-256.key,old-key=$keydir/aes-128.key\r"
118113
eexpect "node starting"
119-
interrupt
120-
eexpect "shutdown completed"
114+
interrupt_and_wait
121115
end_test

pkg/cli/interactive_tests/test_flags.tcl

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@ eexpect ":/# "
99
start_test "Check that --max-disk-temp-storage works."
1010
send "$argv start-single-node --insecure --store=path=logs/mystore --max-disk-temp-storage=10GiB\r"
1111
eexpect "node starting"
12-
interrupt
13-
eexpect ":/# "
12+
interrupt_and_wait
1413
end_test
1514

1615
start_test "Check that --max-disk-temp-storage can be expressed as a percentage."
1716
send "$argv start-single-node --insecure --store=path=logs/mystore --max-disk-temp-storage=10%\r"
1817
eexpect "node starting"
19-
interrupt
20-
eexpect ":/# "
18+
interrupt_and_wait
2119
end_test
2220

2321
start_test "Check that --max-disk-temp-storage percentage works when the store is in-memory."
2422
send "$argv start-single-node --insecure --store=type=mem,size=1GB --max-disk-temp-storage=10%\r"
2523
eexpect "node starting"
26-
interrupt
27-
eexpect ":/# "
24+
interrupt_and_wait
2825
end_test
2926

3027
start_test "Check that memory max flags do not exceed available RAM."
@@ -34,16 +31,14 @@ eexpect "is larger than"
3431
eexpect "of total RAM"
3532
eexpect "increased risk"
3633
eexpect "node starting"
37-
interrupt
38-
eexpect ":/# "
34+
interrupt_and_wait
3935
end_test
4036

4137
start_test "Check that not using --host nor --advertise causes a user warning."
4238
send "$argv start-single-node --insecure\r"
4339
eexpect "WARNING: neither --listen-addr nor --advertise-addr was specified"
4440
eexpect "node starting"
45-
interrupt
46-
eexpect ":/# "
41+
interrupt_and_wait
4742
end_test
4843

4944
start_test "Check that using --advertise-addr does not cause a user warning."
@@ -55,16 +50,14 @@ expect {
5550
}
5651
}
5752
eexpect "node starting"
58-
interrupt
59-
eexpect ":/# "
53+
interrupt_and_wait
6054
end_test
6155

6256
start_test "Check that --listening-url-file gets created with the right data"
6357
send "$argv start-single-node --insecure --listening-url-file=foourl\r"
6458
eexpect "node starting"
6559
system "grep -q 'postgresql://.*@.*:\[0-9\]\[0-9\]*' foourl"
66-
interrupt
67-
eexpect ":/# "
60+
interrupt_and_wait
6861
end_test
6962

7063
start_test {Check that the "failed running SUBCOMMAND" message does not consider a flag the subcommand}
@@ -109,8 +102,7 @@ end_test
109102
start_test "Check that locality flags without a region tier warn"
110103
send "$argv start-single-node --insecure --locality=data-center=us-east,zone=a\r"
111104
eexpect "WARNING: The --locality flag does not contain a"
112-
interrupt
113-
eexpect ":/# "
105+
interrupt_and_wait
114106
end_test
115107

116108
start_server $argv
@@ -170,8 +162,7 @@ send "export GOMEMLIMIT=1GiB;\r"
170162
eexpect ":/# "
171163
send "$argv start-single-node --insecure --store=path=logs/mystore\r"
172164
eexpect "node starting"
173-
interrupt
174-
eexpect ":/# "
165+
interrupt_and_wait
175166
stop_server $argv
176167
end_test
177168

@@ -180,8 +171,7 @@ send "export GOGC=500;\r"
180171
eexpect ":/# "
181172
send "$argv start-single-node --insecure --store=path=logs/mystore\r"
182173
eexpect "node starting"
183-
interrupt
184-
eexpect ":/# "
174+
interrupt_and_wait
185175
stop_server $argv
186176
end_test
187177

pkg/cli/interactive_tests/test_missing_log_output.tcl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ eexpect ":/# "
3333
# is has been broken, and that may be the secondary logger.
3434
send "tail -F `find logs/db/logs -type l`\r"
3535
eexpect "error: write */dev/stderr*: broken pipe"
36-
interrupt
37-
eexpect ":/# "
36+
interrupt_and_wait
3837
end_test
3938

4039
start_test "Check that a broken log file prints a message to stderr."
@@ -52,8 +51,7 @@ eexpect "CockroachDB node starting"
5251
end_test
5352

5453
# Stop it.
55-
interrupt
56-
eexpect ":/# "
54+
interrupt_and_wait
5755

5856
# Disable replication so as to avoid spurious purgatory errors.
5957
start_server $argv
@@ -68,9 +66,7 @@ eexpect "CockroachDB node starting"
6866
end_test
6967

7068
# Stop it.
71-
interrupt
72-
interrupt
73-
eexpect ":/# "
69+
interrupt_and_wait
7470
system "rm -rf logs/db"
7571

7672
start_test "Check that --logtostderr can override the threshold but no error is printed on startup"
@@ -79,9 +75,7 @@ eexpect "marker\r\nCockroachDB node starting"
7975
end_test
8076

8177
# Stop it.
82-
interrupt
83-
interrupt
84-
eexpect ":/# "
78+
interrupt_and_wait
8579
system "rm -rf logs/db"
8680

8781

pkg/cli/interactive_tests/test_socket_name.tcl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,12 @@ system "test -r .s.PGSQL.$sql_port.lock"
5050
end_test
5151

5252
# Stop the server that was started above.
53-
interrupt
54-
eexpect ":/# "
53+
interrupt_and_wait
5554
send "exit\r"
5655
eexpect eof
5756

5857
set spawn_id $shell1_spawn_id
59-
interrupt
60-
eexpect ":/# "
58+
interrupt_and_wait
6159

6260
start_test "Check that the socket-dir flag checks the length of the directory."
6361
send "$argv start-single-node --insecure --socket-dir=$longname\r"

pkg/cli/interactive_tests/test_sql_mem_monitor.tcl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ expect {
9797
timeout { handle_timeout "memory allocation error" }
9898
}
9999
# Stop the tail command.
100-
interrupt
101-
eexpect ":/# "
100+
interrupt_and_wait
102101

103102
# Check that the client got a bad connection error
104103
set spawn_id $client_spawn_id
@@ -137,8 +136,6 @@ send_eof
137136
eexpect eof
138137

139138
set spawn_id $shell_spawn_id
140-
interrupt
141-
interrupt
142-
eexpect ":/# "
139+
interrupt_and_wait
143140
send "exit\r"
144141
eexpect eof

pkg/cli/interactive_tests/test_temp_dir.tcl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ if {! [string match "$cwd/$tempdir/$tempprefix*" [gets $rfile]]} {
6262
exit 1
6363
}
6464
close $rfile
65-
interrupt
66-
eexpect "shutdown completed"
65+
interrupt_and_wait
6766
# Verify the temp directory is removed.
6867
glob_not_exists "$tempdir/$tempprefix*"
6968
# Verify temp directory path is removed from record file.
@@ -80,8 +79,7 @@ eexpect "node starting"
8079
eexpect "temp dir:*$tempdir/$tempprefix"
8180
# Verify the temp directory under first store is created.
8281
glob_exists "$tempdir/$tempprefix*"
83-
interrupt
84-
eexpect "shutdown completed"
82+
interrupt_and_wait
8583
# Verify the temp directory is removed.
8684
glob_not_exists "$tempdir/$tempprefix*"
8785
end_test
@@ -97,8 +95,7 @@ eexpect "temp dir:*$cwd/$tempdir/$tempprefix"
9795
# Verify temp1 and temp2 are removed shortly after startup.
9896
file_not_exists "$storedir/temp1"
9997
file_not_exists "$storedir/temp2"
100-
interrupt
101-
eexpect "shutdown completed"
98+
interrupt_and_wait
10299
# Verify the temp directory is removed.
103100
glob_not_exists "$tempdir/$tempprefix*"
104101
# Verify store directory still exists.
@@ -111,8 +108,7 @@ eexpect "node starting"
111108
eexpect "temp dir:*$cwd/$storedir/$tempprefix"
112109
# Verify the temp directory under first store is created.
113110
glob_exists "$storedir/$tempprefix*"
114-
interrupt
115-
eexpect "shutdown completed"
111+
interrupt_and_wait
116112
# Verify the temp directory is removed.
117113
glob_not_exists "$storedir/$tempprefix*"
118114
# Verify the store file still exists.
@@ -131,6 +127,5 @@ send "pkill -9 cockroach\r"
131127
# We should be able to start the cockroach instance again.
132128
send "$argv start-single-node --insecure --store=$storedir\r"
133129
eexpect "node starting"
134-
interrupt
135-
eexpect "shutdown completed"
130+
interrupt_and_wait
136131
end_test

0 commit comments

Comments
 (0)