This is an automated email from the ASF dual-hosted git repository.

jlewandowski pushed a commit to branch ds-trunk-5.0--2024-07-24
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git

commit 3f68e3aa5168d79870978fa8c93e5fd94ccb7853
Author: Matt Fleming <[email protected]>
AuthorDate: Mon May 24 11:43:58 2021 +0100

    STAR-431: Add option to prevent any file-I/O from cqlsh
    
    Co-authored-by: Robert Stupp <[email protected]>
    (cherry picked from commit 33e486a19421f77f7091fc8b96a493429c34cacf)
    (cherry picked from commit 9fbd1b3b816f7bd46dd4ad42a0e5d6e3748351bb)
    (cherry picked from commit c479ab3055e5114ba01e467e3c149df9966b0f05)
    (cherry picked from commit 6c74210d247fb4147d5cf8a3953be26a845813b3)
    (cherry picked from commit ec68d4623490bc5e381628088cf93e001eaf5a91)
    (cherry picked from commit 09a1eff60a7e4407c746fe62396550746508d835)
    (cherry picked from commit de2579d14993bf2281358475da1cb8048bba5a7b)
    (cherry picked from commit e8fed18751e47e2a282fc91737e65cebf3861266)
---
 cqlsh_tests/test_cqlsh.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/cqlsh_tests/test_cqlsh.py b/cqlsh_tests/test_cqlsh.py
index b7e3a16f..e1036371 100644
--- a/cqlsh_tests/test_cqlsh.py
+++ b/cqlsh_tests/test_cqlsh.py
@@ -24,6 +24,7 @@ from cassandra import InvalidRequest
 from cassandra.concurrent import execute_concurrent_with_args
 from cassandra.query import BatchStatement, BatchType
 from ccmlib import common
+from ccmlib.node import ToolError
 
 from .cqlsh_tools import monkeypatch_driver, unmonkeypatch_driver
 from dtest import Tester, create_ks, create_cf
@@ -2815,6 +2816,33 @@ class TestCqlshSmoke(Tester, CqlshMixin):
 """
         assert stdout_lines_sorted.find(expected) >= 0
 
+    @since('4.0')
+    def test_no_file_io(self):
+        def run_cqlsh_catch_toolerror(cmd, env):
+            """
+            run_cqlsh will throw ToolError if cqlsh exits with a non-zero exit 
code.
+            """
+            try:
+                out, err, _ = self.node1.run_cqlsh(cmd, env)
+            except ToolError as e:
+                return e.stdout, e.stderr
+
+        cqlsh_stdout, cqlsh_stderr, = run_cqlsh_catch_toolerror('COPY foo.bar 
FROM \'blah\';', ['--no-file-io'])
+        assert cqlsh_stdout == ''
+        assert 'No file I/O permitted' in cqlsh_stderr
+
+        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\'', ['--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\'', ['--no-file-io'])
+        assert cqlsh_stdout == ''
+        assert 'No file I/O permitted' in cqlsh_stderr
+
 
 class TestCqlLogin(Tester, CqlshMixin):
     """


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to