Skip to content

Commit

Permalink
github actions: support testing with enterprise release
Browse files Browse the repository at this point in the history
Adding the needed change for geting cqlsh test
with enterprise versions
  • Loading branch information
fruch committed Sep 13, 2023
1 parent 296b76d commit 69b76be
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ jobs:
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
integration_test_scylla_enterprise:
name: Integration Tests (Scylla Enterprise)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Start Scylla
run: |
export DOCKER_ID=$(docker run -d scylladb/scylla-enterprise:latest --cluster-name test )
export CQL_TEST_HOST=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' ${DOCKER_ID})
while ! nc -z ${CQL_TEST_HOST} 9042; do
sleep 0.1 # wait for 1/10 of the second before check again
done
echo "CQL_TEST_HOST=${CQL_TEST_HOST}" >> $GITHUB_ENV
- name: pytest
run: |
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')"
Expand Down
4 changes: 2 additions & 2 deletions pylib/cqlshlib/cql3handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def __str__(self):


SYSTEM_KEYSPACES = ('system', 'system_schema', 'system_traces', 'system_auth', 'system_distributed', 'system_views',
'system_virtual_schema', 'system_distributed_everywhere')
NONALTERBALE_KEYSPACES = ('system', 'system_schema', 'system_views', 'system_virtual_schema', 'system_distributed_everywhere')
'system_virtual_schema', 'system_distributed_everywhere', 'system_replicated_keys')
NONALTERBALE_KEYSPACES = ('system', 'system_schema', 'system_views', 'system_virtual_schema', 'system_distributed_everywhere', 'system_replicated_keys')


class Cql3ParsingRuleSet(CqlParsingRuleSet):
Expand Down
30 changes: 24 additions & 6 deletions pylib/cqlshlib/test/test_cqlsh_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import locale
import os
import re

from packaging.version import Version

from .basecase import BaseTestCase
from .cassconnect import create_db, remove_db, testrun_cqlsh
from .cassconnect import create_db, remove_db, testrun_cqlsh, get_cassandra_connection
from .run_cqlsh import TimeoutError
from cqlshlib.cql3handling import CqlRuleSet

Expand All @@ -48,6 +51,11 @@ def setUpClass(cls):
output = c.cmd_and_response("SELECT * FROM system_schema.scylla_tables LIMIT 1;")
cls.is_scylla = '1 rows' in output

with get_cassandra_connection().connect() as session:
result = session.execute("SELECT version FROM system.versions WHERE key = 'local' LIMIT 1")
cls.scylla_version = Version(result.one().version.rsplit('.', 2)[0])
cls.is_scylla_enterprise = cls.scylla_version > Version('2018.1')

@classmethod
def tearDownClass(cls):
remove_db()
Expand All @@ -63,6 +71,18 @@ def setUp(self):
def tearDown(self):
self.cqlsh_runner.__exit__(None, None, None)

def _system_keyspaces(self):
tables = []

if self.is_scylla:
tables += ['system_distributed_everywhere.']
if self.is_scylla_enterprise:
tables += ['system_replicated_keys.']
else:
tables += ['system_views.', 'system_virtual_schema.']

return tables

def _get_completions(self, inputstring, split_completed_lines=True):
"""
Get results of tab completion in cqlsh. Returns a bare string if a
Expand Down Expand Up @@ -927,9 +947,8 @@ def test_complete_in_alter_table(self):
'utf8_with_special_chars',
'system_traces.', 'songs',
'system_schema.', 'system_distributed.',
self.cqlsh.keyspace + '.'] +
(['system_distributed_everywhere.'] if self.is_scylla else
['system_views.', 'system_virtual_schema.']))
self.cqlsh.keyspace + '.'] + self._system_keyspaces()
)
self.trycompletions('ALTER TABLE IF EXISTS new_table ADD ', choices=['<new_column_name>', 'IF'])
self.trycompletions('ALTER TABLE IF EXISTS new_table ADD IF NOT EXISTS ', choices=['<new_column_name>'])
self.trycompletions('ALTER TABLE new_table ADD IF NOT EXISTS ', choices=['<new_column_name>'])
Expand All @@ -943,8 +962,7 @@ def test_complete_in_alter_type(self):
'tags', 'system_traces.', 'system_distributed.',
'phone_number', 'band_info_type', 'address', 'system.', 'system_schema.',
'system_auth.', self.cqlsh.keyspace + '.'
] + (['system_distributed_everywhere.'] if self.is_scylla else
['system_views.', 'system_virtual_schema.']))
] + self._system_keyspaces())
self.trycompletions('ALTER TYPE IF EXISTS new_type ADD ', choices=['<new_field_name>', 'IF'])
self.trycompletions('ALTER TYPE IF EXISTS new_type ADD IF NOT EXISTS ', choices=['<new_field_name>'])
self.trycompletions('ALTER TYPE IF EXISTS new_type RENAME ', choices=['IF', '<quotedName>', '<identifier>'])
Expand Down
20 changes: 15 additions & 5 deletions pylib/cqlshlib/test/test_cqlsh_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ def get_cassandra_metadata(cls):
cls.is_scylla = len(output.all()) == 1
except InvalidRequest:
cls.is_scylla = False
try:
result = curs.execute("SELECT version FROM system.versions WHERE key = 'local' LIMIT 1")
cls.scylla_version = Version(result.one().version.rsplit('.', 2)[0])
cls.is_scylla_enterprise = cls.scylla_version > Version('2018.1')
except:
cls.is_scylla_enterprise = False

@property
def default_compaction_strategy(self):
return 'IncrementalCompactionStrategy' if self.is_scylla_enterprise else 'SizeTieredCompactionStrategy'

def setUp(self):
env = os.environ.copy()
Expand Down Expand Up @@ -684,7 +694,7 @@ def test_describe_columnfamily_output(self):
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';""" % quote_name(get_keyspace()))

scylla_table_desc = dedent("""
scylla_table_desc = dedent(f"""
CREATE TABLE %s.has_all_types (
num int PRIMARY KEY,
asciicol ascii,
Expand All @@ -703,10 +713,10 @@ def test_describe_columnfamily_output(self):
varcharcol text,
varintcol varint
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
AND caching = {{'keys': 'ALL', 'rows_per_partition': 'ALL'}}
AND comment = ''
AND compaction = {'class': 'SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND compaction = {{'class': '{self.default_compaction_strategy}'}}
AND compression = {{'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.0
AND default_time_to_live = 0
Expand Down Expand Up @@ -1001,7 +1011,7 @@ def test_scylla_tags(self):
) WITH bloom_filter_fp_chance = 0.01
AND caching = {{'keys': 'ALL', 'rows_per_partition': 'ALL'}}
AND comment = ''
AND compaction = {{'class': 'SizeTieredCompactionStrategy'}}
AND compaction = {{'class': '{self.default_compaction_strategy}'}}
AND compression = {{'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.0
Expand Down

0 comments on commit 69b76be

Please sign in to comment.