Skip to content

Commit 21c18c5

Browse files
tlasicajtgrabowski
authored andcommitted
STAR-432. Add tests for consistency level options (#18)
* STAR-432. Add tests for consistency level options Co-authored-by: Robert Stupp [email protected]
1 parent 033a492 commit 21c18c5

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

cqlsh_tests/test_cqlsh.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,52 @@ def test_connect_timeout(self):
18611861
stdout, stderr = self.run_cqlsh(node1, cmds='USE system', cqlsh_options=['--debug', '--connect-timeout=10'])
18621862
assert "Using connect timeout: 10 seconds" in stderr
18631863

1864+
@since('4.0')
1865+
def test_consistency_level_options(self):
1866+
"""
1867+
Tests for new cmdline consistency options:
1868+
- consistency-level
1869+
- serial-consistency-level
1870+
@jira_ticket STAR-432
1871+
"""
1872+
self.cluster.populate(1)
1873+
self.cluster.start()
1874+
1875+
node1, = self.cluster.nodelist()
1876+
1877+
def expect_output_no_errors(cmd, options, output):
1878+
stdout, stderr = self.run_cqlsh(node1, cmds=cmd, cqlsh_options=options)
1879+
assert output in stdout, stderr
1880+
assert stderr == ''
1881+
1882+
expect_output_no_errors('CONSISTENCY', [],
1883+
'Current consistency level is ONE.')
1884+
1885+
expect_output_no_errors('CONSISTENCY', ['--consistency-level', 'quorum'],
1886+
'Current consistency level is QUORUM.')
1887+
1888+
expect_output_no_errors('SERIAL CONSISTENCY', [],
1889+
'Current serial consistency level is SERIAL.')
1890+
1891+
expect_output_no_errors('SERIAL CONSISTENCY', ['--serial-consistency-level', 'local_serial'],
1892+
'Current serial consistency level is LOCAL_SERIAL.')
1893+
1894+
def expect_error(cmd, options, error_msg):
1895+
stdout, stderr = self.run_cqlsh(node1, cmds=cmd, cqlsh_options=options)
1896+
assert error_msg in stderr
1897+
1898+
expect_error('CONSISTENCY', ['--consistency-level', 'foop'],
1899+
'"foop" is not a valid consistency level')
1900+
1901+
expect_error('CONSISTENCY', ['--consistency-level', 'serial'],
1902+
'"serial" is not a valid consistency level')
1903+
1904+
expect_error('SERIAL CONSISTENCY', ['--serial-consistency-level', 'foop'],
1905+
'"foop" is not a valid serial consistency level')
1906+
1907+
expect_error('SERIAL CONSISTENCY', ['--serial-consistency-level', 'ONE'],
1908+
'"ONE" is not a valid serial consistency level')
1909+
18641910
@since('3.0.19')
18651911
def test_protocol_negotiation(self):
18661912
"""

0 commit comments

Comments
 (0)