Skip to content

Commit ec68d46

Browse files
mflemingsnazy
authored andcommitted
STAR-431: Add option to prevent any file-I/O from cqlsh
Co-authored-by: Robert Stupp <[email protected]> (cherry picked from commit 33e486a) (cherry picked from commit 9fbd1b3) (cherry picked from commit c479ab3) (cherry picked from commit 6c74210)
1 parent c32760d commit ec68d46

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

cqlsh_tests/test_cqlsh.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from cassandra.concurrent import execute_concurrent_with_args
2525
from cassandra.query import BatchStatement, BatchType
2626
from ccmlib import common
27+
from ccmlib.node import ToolError
2728

2829
from .cqlsh_tools import monkeypatch_driver, unmonkeypatch_driver
2930
from dtest import Tester, create_ks, create_cf
@@ -2589,6 +2590,33 @@ def test_cjk_output(self):
25892590
"""
25902591
assert stdout_lines_sorted.find(expected) >= 0
25912592

2593+
@since('4.0')
2594+
def test_no_file_io(self):
2595+
def run_cqlsh_catch_toolerror(cmd, env):
2596+
"""
2597+
run_cqlsh will throw ToolError if cqlsh exits with a non-zero exit code.
2598+
"""
2599+
try:
2600+
out, err, _ = self.node1.run_cqlsh(cmd, env)
2601+
except ToolError as e:
2602+
return e.stdout, e.stderr
2603+
2604+
cqlsh_stdout, cqlsh_stderr, = run_cqlsh_catch_toolerror('COPY foo.bar FROM \'blah\';', ['--no-file-io'])
2605+
assert cqlsh_stdout == ''
2606+
assert 'No file I/O permitted' in cqlsh_stderr
2607+
2608+
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('DEBUG', ['--no-file-io'])
2609+
assert cqlsh_stdout == ''
2610+
assert 'No file I/O permitted' in cqlsh_stderr
2611+
2612+
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('CAPTURE \'nah\'', ['--no-file-io'])
2613+
assert cqlsh_stdout == ''
2614+
assert 'No file I/O permitted' in cqlsh_stderr
2615+
2616+
cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('SOURCE \'nah\'', ['--no-file-io'])
2617+
assert cqlsh_stdout == ''
2618+
assert 'No file I/O permitted' in cqlsh_stderr
2619+
25922620

25932621
class TestCqlLogin(Tester, CqlshMixin):
25942622
"""

0 commit comments

Comments
 (0)