github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/interactive_tests/test_log_flags.tcl (about) 1 #! /usr/bin/env expect -f 2 3 source [file join [file dirname $argv0] common.tcl] 4 5 spawn /bin/bash 6 send "PS1=':''/# '\r" 7 eexpect ":/# " 8 9 # Perform command-line checking for logging flags. We cannot use a 10 # regular unit test for this, because the logging flags are declared 11 # for the global `CommandLine` object of package `flag`, and any 12 # errors when parsing flags in that context cause the (test) process 13 # to exit entirely (it has errorHandling set to ExitOnError). 14 15 start_test "Check that log files are created by default in the store directory." 16 send "$argv start-single-node --insecure --store=path=logs/mystore\r" 17 eexpect "node starting" 18 interrupt 19 eexpect ":/# " 20 send "ls logs/mystore/logs\r" 21 eexpect "cockroach.log" 22 eexpect ":/# " 23 end_test 24 25 start_test "Check that an empty -log-dir disables file logging." 26 send "$argv start-single-node --insecure --store=path=logs/mystore2 --log-dir=\r" 27 eexpect "node starting" 28 interrupt 29 eexpect ":/# " 30 send "ls logs/mystore2/logs 2>/dev/null | wc -l\r" 31 eexpect "0" 32 eexpect ":/# " 33 end_test 34 35 start_test "Check that leading tildes are properly rejected." 36 send "$argv start-single-node --insecure -s=path=logs/db --log-dir=\~/blah\r" 37 eexpect "log directory cannot start with '~'" 38 eexpect ":/# " 39 end_test 40 41 start_test "Check that the user can override." 42 send "$argv start-single-node --insecure -s=path=logs/db --log-dir=logs/blah/\~/blah\r" 43 eexpect "logs: *blah/~/blah" 44 interrupt 45 eexpect ":/# " 46 end_test 47 48 start_test "Check that TRUE and FALSE are valid values for the severity flags." 49 send "$argv start-single-node --insecure -s=path=logs/db --logtostderr=false\r" 50 eexpect "node starting" 51 interrupt 52 eexpect ":/# " 53 send "$argv start-single-node --insecure -s=path=logs/db --logtostderr=true\r" 54 eexpect "node starting" 55 interrupt 56 eexpect ":/# " 57 send "$argv start-single-node --insecure -s=path=logs/db --logtostderr=2\r" 58 eexpect "node starting" 59 interrupt 60 eexpect ":/# " 61 send "$argv start-single-node --insecure -s=path=logs/db --logtostderr=cantparse\r" 62 eexpect "parsing \"cantparse\": invalid syntax" 63 eexpect ":/# " 64 end_test 65 66 send "exit 0\r" 67 eexpect eof