Skip to content

Commit

Permalink
STAR-431: Add more tests to make sure commands work without --no-file…
Browse files Browse the repository at this point in the history
…-io too

(cherry picked from commit 033a492)
(cherry picked from commit 72eedea)
  • Loading branch information
mfleming authored and jacek-lewandowski committed Jun 25, 2021
1 parent c479ab3 commit cf7be8c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cqlsh_tests/test_cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2463,23 +2463,40 @@ def run_cqlsh_catch_toolerror(cmd, env):
"""
run_cqlsh will throw ToolError if cqlsh exits with a non-zero exit code.
"""
out = ""
err = ""
try:
out, err, _ = self.node1.run_cqlsh(cmd, env)
except ToolError as e:
return e.stdout, e.stderr
return out, err

cqlsh_stdout, cqlsh_stderr, = run_cqlsh_catch_toolerror('COPY foo.bar FROM \'blah\';', ['--no-file-io'])
create_ks(self.session, 'foo', rf=1)
create_cf(self.session, 'bar', key_type='int', columns={'name': 'text'})

cqlsh_stdout, cqlsh_stderr, _ = self.node1.run_cqlsh('COPY foo.bar TO \'/dev/null\';', [])
assert '0 rows exported to 1 files' in cqlsh_stdout
assert cqlsh_stderr == ''
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('COPY foo.bar TO \'/dev/null\';', ['--no-file-io'])
assert cqlsh_stdout == ''
assert 'No file I/O permitted' in cqlsh_stderr

cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('DEBUG', [])
assert '(Pdb)' in cqlsh_stdout
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('DEBUG', ['--no-file-io'])
assert cqlsh_stdout == ''
assert 'No file I/O permitted' in cqlsh_stderr

cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('CAPTURE \'nah\'', [])
assert cqlsh_stdout == 'Now capturing query output to \'nah\'.\n'
assert cqlsh_stderr == ''
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('CAPTURE \'nah\'', ['--no-file-io'])
assert cqlsh_stdout == ''
assert 'No file I/O permitted' in cqlsh_stderr

cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('SOURCE \'nah\'', [])
assert cqlsh_stdout == ''
assert cqlsh_stderr == ''
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('SOURCE \'nah\'', ['--no-file-io'])
assert cqlsh_stdout == ''
assert 'No file I/O permitted' in cqlsh_stderr
Expand Down

0 comments on commit cf7be8c

Please sign in to comment.