mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 19:10:42 +00:00
Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
51 lines
2.3 KiB
Python
51 lines
2.3 KiB
Python
# Copyright 2020-present ScyllaDB
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# Tests for accessing alternator-only system tables (from Scylla).
|
|
|
|
import pytest
|
|
from botocore.exceptions import ClientError
|
|
from boto3.dynamodb.conditions import Key
|
|
|
|
internal_prefix = '.scylla.alternator.'
|
|
|
|
# Test that fetching key columns from system tables works
|
|
def test_fetch_from_system_tables(scylla_only, dynamodb):
|
|
client = dynamodb.meta.client
|
|
tables_response = client.scan(TableName=internal_prefix+'system_schema.tables',
|
|
AttributesToGet=['keyspace_name','table_name'])
|
|
|
|
for item in tables_response['Items']:
|
|
ks_name = item['keyspace_name']
|
|
table_name = item['table_name']
|
|
|
|
if not 'system' in ks_name:
|
|
continue
|
|
|
|
col_response = client.query(TableName=internal_prefix+'system_schema.columns',
|
|
KeyConditionExpression=Key('keyspace_name').eq(ks_name) & Key('table_name').eq(table_name))
|
|
|
|
key_columns = [item['column_name'] for item in col_response['Items'] if item['kind'] == 'clustering' or item['kind'] == 'partition_key']
|
|
qualified_name = "{}{}.{}".format(internal_prefix, ks_name, table_name)
|
|
import time
|
|
start = time.time()
|
|
response = client.scan(TableName=qualified_name, AttributesToGet=key_columns, Limit=50)
|
|
print(ks_name, table_name, len(str(response)), time.time()-start)
|
|
|
|
def test_block_access_to_non_system_tables_with_virtual_interface(scylla_only, test_table_s, dynamodb):
|
|
client = dynamodb.meta.client
|
|
with pytest.raises(ClientError, match='ResourceNotFoundException.*{}'.format(internal_prefix)):
|
|
tables_response = client.scan(TableName="{}alternator_{}.{}".format(internal_prefix, test_table_s.name, test_table_s.name))
|
|
|
|
def test_block_creating_tables_with_reserved_prefix(scylla_only, dynamodb):
|
|
client = dynamodb.meta.client
|
|
for wrong_name_postfix in ['', 'a', 'xxx', 'system_auth.roles', 'table_name']:
|
|
with pytest.raises(ClientError, match=internal_prefix):
|
|
dynamodb.create_table(TableName=internal_prefix+wrong_name_postfix,
|
|
BillingMode='PAY_PER_REQUEST',
|
|
KeySchema=[{'AttributeName':'p', 'KeyType':'HASH'}],
|
|
AttributeDefinitions=[{'AttributeName':'p', 'AttributeType': 'S'}]
|
|
)
|
|
|