Skip to content

Commit

Permalink
test: add support for testing cloud bundle option
Browse files Browse the repository at this point in the history
should help making sure we don't break the support again
  • Loading branch information
fruch committed Jun 15, 2023
1 parent 92bd70f commit 2254e92
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,33 @@ jobs:
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
integration_test_scylla_cloud_bundle:
name: Integration Tests (Scylla Cloud Bundle)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Start Scylla cloud bundle setup with CCM
run: |
# install python2 is needed for scylla < 5.3, cause it bundle with old cqlsh
sudo apt update -y
sudo apt install -y python2
python3 -m pip install https://github.com/scylladb/scylla-ccm/archive/master.zip
ccm create test_sni -i 127.0.1. -n 1 --scylla --version release:5.2
ccm start --sni-proxy --sni-port=8443
export CQL_TEST_BUNDLE_PATH=$(realpath ~/.ccm/test_sni/config_data.yaml)
echo "CQL_TEST_BUNDLE_PATH=${CQL_TEST_BUNDLE_PATH}" >> $GITHUB_ENV
- name: pytest
run: |
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
integration_test_cassandra:
name: Integration Tests (Cassandra)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
Expand Down
1 change: 1 addition & 0 deletions pylib/cqlshlib/test/basecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
sys.path.append(cqlsh_dir)

TEST_HOST = os.environ.get('CQL_TEST_HOST', '127.0.0.1')
TEST_BUNDLE_PATH = os.environ.get('CQL_TEST_BUNDLE_PATH')
TEST_PORT = int(os.environ.get('CQL_TEST_PORT', 9042))
TEST_USER = os.environ.get('CQL_TEST_USER', 'cassandra')
TEST_PWD = os.environ.get('CQL_TEST_PWD')
Expand Down
7 changes: 5 additions & 2 deletions pylib/cqlshlib/test/cassconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from cassandra.auth import PlainTextAuthProvider
from cqlshlib.cql3handling import CqlRuleSet

from .basecase import TEST_HOST, TEST_PORT, TEST_USER, TEST_PWD, cqlshlog, test_dir
from .basecase import TEST_HOST, TEST_PORT, TEST_USER, TEST_PWD, cqlshlog, test_dir, TEST_BUNDLE_PATH
from .run_cqlsh import run_cqlsh, call_cqlsh

test_keyspace_init = os.path.join(test_dir, 'test_keyspace_init.cql')
Expand All @@ -35,7 +35,10 @@
def get_cassandra_connection(cql_version=None):

auth_provider = PlainTextAuthProvider(username=TEST_USER, password=TEST_PWD)
conn = Cluster((TEST_HOST,), TEST_PORT, auth_provider=auth_provider, cql_version=cql_version)
if TEST_BUNDLE_PATH:
conn = Cluster(scylla_cloud=TEST_BUNDLE_PATH, auth_provider=auth_provider, cql_version=cql_version)
else:
conn = Cluster((TEST_HOST,), TEST_PORT, auth_provider=auth_provider, cql_version=cql_version)

# until the cql lib does this for us
conn.cql_version = cql_version
Expand Down
5 changes: 4 additions & 1 deletion pylib/cqlshlib/test/run_cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ def __init__(self, path=None, host=None, port=None, keyspace=None, cqlver=None,
coverage = False
if ('CQLSH_COVERAGE' in env.keys()):
coverage = True
args = tuple(args) + (host, str(port))
if basecase.TEST_BUNDLE_PATH:
args = tuple(args) + ("--cloudconf", basecase.TEST_BUNDLE_PATH)
else:
args = tuple(args) + (host, str(port))
if cqlver is not None:
args += ('--cqlversion', str(cqlver))
if keyspace is not None:
Expand Down
8 changes: 5 additions & 3 deletions pylib/cqlshlib/test/test_cqlsh_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from cassandra import InvalidRequest

from .basecase import (BaseTestCase, TEST_HOST, TEST_PORT,
at_a_time, cqlshlog, dedent)
at_a_time, cqlshlog, dedent, TEST_BUNDLE_PATH)
from .cassconnect import (cassandra_cursor, create_db, get_keyspace,
quote_name, remove_db, split_cql_commands,
testcall_cqlsh, testrun_cqlsh)
Expand Down Expand Up @@ -845,8 +845,10 @@ def test_show_output(self):

output = c.cmd_and_response('show host;')
self.assertHasColors(output)
self.assertRegex(output, '^Connected to .* at %s:%d$'
% (re.escape(TEST_HOST), TEST_PORT))
if TEST_BUNDLE_PATH:
self.assertRegex(output, r'Connected to .* at Scylla Cloud\.$')
else:
self.assertRegex(output, f'^Connected to .* at {re.escape(TEST_HOST)}:{TEST_PORT}$')

def test_eof_prints_newline(self):
with testrun_cqlsh(tty=True, env=self.default_env) as c:
Expand Down

0 comments on commit 2254e92

Please sign in to comment.