Commit Graph

3012 Commits

Author SHA1 Message Date
Paweł Dziepak
ca8d1025c0 utils/fragmented_temporary_buffer_view: add remove suffix
This patch adds fragmented_temporary_buffer_view::remove_suffix(). It is
also necessary to adjust remove_prefix() since now the total size of all
fragments may be larger than the size of the view if both those
operations are performed.
2019-03-04 10:23:45 +00:00
Avi Kivity
8f71e7ffd4 Merge "auth: Prevent disallowed roles from logging in" from Jesse
"
This series heavily refactors `auth_test` in anticipation of
the last patch, which fixes a bug and which should be backported.

Branches: branch-3.0, branch-2.3
"

Fixes #4284

* 'jhk/check_can_login/v2' of https://github.com/hakuch/scylla:
  auth: Reject logins from disallowed roles
  tests: Restrict the scope of a variable
  tests: Simplify boolean assertions in `auth_test`
  tests: Abstract out repeated assertion checking
  tests: Do not use the `auth` namespace
  tests: Validate authentication correctly
  tests: Ensure test roles are created and dropped
  tests: Use `static` variables in `auth_test`
  tests: Remove non-useful test
2019-03-02 17:13:06 +02:00
Jesse Haber-Kucharsky
a139afc30c auth: Reject logins from disallowed roles
When the `LOGIN` option for a role is set to `false`, Scylla should not
permit the role to log in.

Fixes #4284

Tests: unit (debug)
2019-02-28 15:02:53 -05:00
Jesse Haber-Kucharsky
320b4a7b99 tests: Restrict the scope of a variable 2019-02-28 15:02:53 -05:00
Jesse Haber-Kucharsky
f8764a12e6 tests: Simplify boolean assertions in auth_test 2019-02-28 15:02:53 -05:00
Jesse Haber-Kucharsky
879217ccaf tests: Abstract out repeated assertion checking 2019-02-28 15:02:53 -05:00
Jesse Haber-Kucharsky
3c8eeb0e86 tests: Do not use the auth namespace 2019-02-28 15:02:53 -05:00
Jesse Haber-Kucharsky
afed9c7bee tests: Validate authentication correctly
There are additional validation steps that the server executes in
addition to simply invoking the authenticator, so we adapt the tests to
also perform that validation.

We also eliminate lots of code duplication.
2019-02-28 15:01:14 -05:00
Jesse Haber-Kucharsky
baefde0f6c tests: Ensure test roles are created and dropped
Since the role manager and authenticator work in tandem, the test cases
should use the wrapper for `auth::service` to create and drop users
instead of just doing it through the authenticator.
2019-02-28 15:00:20 -05:00
Jesse Haber-Kucharsky
fd88d59ad9 tests: Use static variables in auth_test
This way, we avoid copies and alleviate resource-management concerns.
2019-02-28 14:59:38 -05:00
Jesse Haber-Kucharsky
f274982522 tests: Remove non-useful test
Password handling is verified in its own test suite, and this test not
only makes a number of assumptions about implementation details, but
also tries to verify a hashing scheme (bcrypt) which is not supported on
most Linux distributions.
2019-02-28 14:58:27 -05:00
Piotr Sarna
032f8e2893 tests: add view update optimization case for TTL
This test case checks whether redundant updates are omitted
and the essential ones are still generated.
2019-02-28 10:47:20 +01:00
Piotr Sarna
09b8d2e9d6 tests: port complex timestamp view test from dtest
This test was useful in discovering corner cases for TTLs of virtual
columns, so it's ported to unit test suite from dtest.

The test is also extended with a mirrored case for base regular column
that *is* included in view pk.
2019-02-28 10:47:20 +01:00
Piotr Sarna
b963543762 tests: remove update generating test case
This test case should have been based on CQL instead of creating
artificial update scenarios. It also contains invalid cases
regarding base and view row marker, so it's removed here
and replaced with CQL-based test in this same series.
2019-02-28 10:40:47 +01:00
Avi Kivity
88322086cb Merge "Add fuzzer-type unit test for range scans" from Botond
"
This series adds a fuzzer-type unit test for range scans, which
generates a semi-random dataset and executes semi-random range scans
against it, validating the result.
This test aims to cover a wide range of corner cases with the help of
randomness. Data and queries against it are generated in such a way that
various corner cases and their combinations are likely to be covered.

The infrastructure under range-scans have gone under massive changes in
the last year, growing in complexity and scope. The correctness of range
scans is critical for the correct functioning of any Scylla cluster, and
while the current unit tests served well in detecting any major problems
(mostly while developing), they are too simplistic and can only be
relied on to check the correctness of the basic functionality. This test
aims to extend coverage drastically, testing cases that the author of
the range-scan code or that of the existing unit tests didn't even think
exists, by relying on some randomness.

Fixes: #3954 (deprecates really)
"

* 'more-extensive-range-scan-unit-tests/v2' of https://github.com/denesb/scylla:
  tests/multishard_mutation_query_test: add fuzzy test
  tests/multishard_mutation_query_test: refactor read_all_partitions_with_paged_scan()
  tests/test_table: add advanced `create_test_table()` overload
  tests/test_table: make `create_test_table()` customizable
  query: add trim_clustering_row_ranges_to()
  tests/test_table: add keyspace and table name params
  tests/test_table: s/create_test_cf/create_test_table/
  tests: move create_test_cf() to tests/test_table.{hh,cc}
  tests/multishard_mutation_query_test: drop many partition test
  tests/multishard_mutation_query_test: drop range tombstone test
2019-02-27 17:26:53 +02:00
Duarte Nunes
871790a340 Merge 'Hide virtual columns write time and ttl from the user' from Piotr
"
This miniseries hides virtual columns's writetime and ttl
from the user.

Tests: unit (dev)

Fixes #4288
"

* 'hide_virtual_columns_writetime_and_ttl_2' of https://github.com/psarna/scylla:
  tests: add test for hiding virtual columns from WRITETIME
  cql3: hide virtual columns from WRITETIME() and TTL()
  schema: add column_definition::is_hidden_from_cql
2019-02-27 14:36:08 +00:00
Piotr Sarna
09eb0429ce tests: add test for hiding virtual columns from WRITETIME
Visibility checks for virtual columns' WRITETIME and TTL
are added.
2019-02-27 15:08:16 +01:00
Avi Kivity
d189e12438 tests: database_test: fix misaligned dma write
test_distributed_loader_with_pending_delete issues a dma write, but violates
the unwritten contract to temporary_buffer::aligned(), which requires that
size be a multiple of alignment. As a result the test fails spuriously.

Instead of playing with the alignment, rewrite that snippet to use the
easier-to-use make_file_output_stream().

Introduced in 1ba88b709f.
Branches: master.
Message-Id: <20190226181850.3074-1-avi@scylladb.com>
2019-02-27 09:00:31 +01:00
Avi Kivity
a0b0db7915 Merge "Fix regression in perf_fast_forward results" from Paweł
"
After adcb3ec20c ("row_cache: read is not
single-partition if inter-partition forwarding is enabled") we have
noticed a regression in the results of some perf_fast_forward tests.
This was caused by those tests not disabling partition-level
fast-forwarding even though it was not needed and the commit in question
fixed an incorrect optimisation in such cases.

However, after solving that issue it has also become apparent that
mutation_reader_merger performs worse when the fast-forwarding is
disabled. This was attributed to logic responsible for dropping readers
as soon as they have reached the end of stream (which cannot be done if
fast-forwarding is enabled). This problem was mitigated with avoiding a
scan of the list and removing readers in small batches.

Fixes #4246.
Fixes #4254.

Tests: unit(dev)
"

* tag 'perf_fast_forward-fix-regression/v1' of https://github.com/pdziepak/scylla:
  mutation_reader_merger: drop unneded readers in small batches
  mutation_reader_merger: track readers by iterators and not pointers
  tests/perf_fast_forward: disable partition-level fast-forwarding if not needed
2019-02-24 19:24:00 +02:00
Avi Kivity
a3a7bea12f Merge "Clean up preprocessor definitions" from Jesse
* 'jhk/define_debug/v1' of https://github.com/hakuch/scylla:
  build: Remove the `DEBUG_SHARED_PTR` pp variable
  build: Prefer the Seastar version of a pp variable
2019-02-23 14:04:08 +02:00
Paweł Dziepak
5d5777f85e tests/perf_fast_forward: disable partition-level fast-forwarding if not needed
Several of the test cases in perf_fast_forward do not need
partition-level fast-forwarding. However, since the defaults are used to
construct most of the readers the fast-forwarding is enabled regardless.

This showed an apparent regression in the perf_fast_forward results
after adcb3ec20c ("row_cache: read is not
single-partition if inter-partition forwarding is enabled") which
disabled an optimisation that was invalid when partition-level
fast-forwarind was requested.

This patch ensures that all single-partition reads that do not need
partition-level fast-forwarding keep it disabled.
2019-02-22 14:28:02 +00:00
Benny Halevy
1ba88b709f tests: database_test: add test_distributed_loader_with_pending_delete
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-22 11:08:22 +02:00
Jesse Haber-Kucharsky
f4883a1aea build: Prefer the Seastar version of a pp variable
Seastar defines `SEASTAR_DEFAULT_ALLOCATOR`, and everywhere else in
Scylla we use this variable too.
2019-02-21 10:41:42 -05:00
Avi Kivity
5520fc37ba Merge " Fix INSERT JSON with null values" from Piotr
"
Fixes #4256

This miniseries fixes a problem with inserting NULL values through
INSERT JSON interface.

Tests: unit (dev)
"

* 'fix_insert_json_with_null' of https://github.com/psarna/scylla:
  tests: add test for INSERT JSON with null values
  cql3: add missing value erasing to json parser
2019-02-21 12:36:09 +02:00
Piotr Sarna
4d211690f9 tests: add test for INSERT JSON with null values 2019-02-21 11:25:14 +01:00
Avi Kivity
9adfd11374 Merge "Avoid including cryptopp headers" from Rafael
"
cryptopp's config.h has the following pragma:

 #pragma GCC diagnostic ignored "-Wunused-function"

It is not wrapped in a push/pop. Because of that, including cryptopp
headers disables that warning on scylla code too.

This patch series introduces a single .cc file that has to include
cryptopp headers.
"

* 'avoid-cryptopp-v3' of https://github.com/espindola/scylla:
  Avoid including cryptopp headers
  Delete dead code
2019-02-21 10:31:20 +02:00
Rafael Ávila de Espíndola
fd5ea2df5a Avoid including cryptopp headers
cryptopp's config.h has the following pragma:

 #pragma GCC diagnostic ignored "-Wunused-function"

It is not wrapped in a push/pop. Because of that, including cryptopp
headers disables that warning on scylla code too.

The issue has been reported as
https://github.com/weidai11/cryptopp/issues/793

To work around it, this patch uses a pimpl to have a single .cc file
that has to include cryptopp headers.

While at it, it also reduces the differences and code duplication
between the md5 and sha1 hashers.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
2019-02-20 08:03:46 -08:00
Piotr Sarna
563456e3ac tests: add cases for view update generation optimizations
Test cases that cover avoiding generating view updates
when not necessary (e.g. when a column not selected by the view
is modified) are added.
2019-02-20 14:05:29 +01:00
Avi Kivity
84465c23c4 Merge "Add multi-column restrictions filtering" from Piotr
"
Fixes #3574

This series adds missing multi-column restrictions filtering to CQL.
The underlying infrastructure already allows checking multi-column
restrictions in a reasonable way, so this series consists of mostly
adding simple interfaces and parameters.
Also, unit test cases for multi-column restrictions are provided.

Tests: unit (dev)
"

* 'add_multi_column_restrictions_filtering_3' of https://github.com/psarna/scylla:
  tests: add multi-column filtering tests
  cql3: add multi-column restrictions filtering
  cql3: add specified is_satisfied_by to multi-column restriction
  cql3: rewrite raw loop in is_satisfied_by to boost::any_of
  cql3: fix is_satisfied_by for multi-column restrictions
  cql3: add missing include to multi-column restriction
2019-02-19 14:42:14 +02:00
Piotr Sarna
9432937816 tests: add multi-column filtering tests
Refs #3574
2019-02-19 13:24:25 +01:00
Avi Kivity
934ba7ccb2 Merge "tests: introduce test environment and cleanup sstable tests" from Benny
"
As part of implementing sstables manager and fixing issue related
to updating large_data_handler on all delete paths, we want to funnel
all sstable creations, loading, and deletions through a manager.

The patchset lays out test infrastructure to funnel these opeations
through class sstables::test_env.

In the process, it cleans up many numerous call sites in the existing
unit tests that evolved over time.

Refs #4198
Refs #4149

Tests: unit (dev)
"

* 'projects/test_env/v3' of https://github.com/bhalevy/scylla:
  tests: introduce sstables::test_env
  tests: perf_sstable: rename test_env
  tests: sstable_datafile_test: use useable_sst
  tests: sstable_test: add write_and_validate_sst helper
  tests: sstable_test: add test_using_reusable_sst helper
  tests: sstable_test: use reusable_sst where possible
  tests: sstable_test: add test_using_working_sst helper
  tests: sstable_3_x_test: make_test_sstable
  tests: run_sstable_resharding_test: use default parameters to make_sstable
  tests: sstables::test::make_test_sstable: reorder params
  tests: test_setup: do_with_test_directory is unused
  tests: move sstable_resharding_strategy_tests to sstable_reharding_test
  tests: move create_token_from_key helpers to test_services
  tests: move column_family_for_tests to test_services
  dht: move declaration of default_partitioner from sstable_datafile_test to i_partitioner.hh
2019-02-19 11:26:42 +02:00
Duarte Nunes
6e83457b1b Merge 'Add PER PARTITION LIMIT' from Piotr
"
This series introduces PER PARTITION LIMIT to CQL.
Protocol and storage is already capable of applying per-partition limits,
so for nonpaged queries the changes are superficial - a variable is parsed
and passed down.
For paged queries and filtering the situation is a little bit more complicated
due to corner cases: results for one partition can be split over 2 or more pages,
filtering may drop rows, etc. To solve these, another variable is added to paging
state - the number of rows already returned from last served partition.
Note that "last" partition may be stretched over any number of pages, not just the
last one, which is a case especially when considering filtering.
As a result, per-partition-limiting queries are not eligible for page generator
optimization, because they may need to have their results locally filtered
for extraneous rows (e.g. when the next page asks for  per-partition limit 5,
but we already received 4 rows from the last partition, so need just 1 more
from last partition key, but 5 from all next ones).

Tests: unit (dev)

Fixes #2202
"

* 'add_per_partition_limit_3' of https://github.com/psarna/scylla:
  tests: remove superficial ignore_order from filtering tests
  tests: add filtering with per partition key limit test
  tests: publish extract_paging_state and count_rows_fetched
  tests: fix order of parameters in with_rows_ignore_order
  cql3,grammar: add PER PARTITION LIMIT
  idl,service: add persistent last partition row count
  cql3: prevent page generator usage for per-partition limit
  cql3: add checking for previous partition count to filtering
  pager: add adjusting per-partition row limit
  cql3: obey per partition limit for filtering
  cql3: clean up unneeded limit variables
  cql3: obey per partition limit for select statement
  cql3: add get_per_partition_limit
  cql3: add per_partition_limit to CQL statement
2019-02-18 14:47:11 +00:00
Piotr Sarna
5ad5221ce1 tests: remove superficial ignore_order from filtering tests
Testing filtering with LIMIT used with_rows_ignore_order function,
while it's better to use simpler with_rows.
2019-02-18 11:06:44 +01:00
Piotr Sarna
5f67a501ec tests: add filtering with per partition key limit test 2019-02-18 11:06:44 +01:00
Piotr Sarna
a84e237177 tests: publish extract_paging_state and count_rows_fetched
These local lambda functions will be reused, so they are promoted
to static functions.
2019-02-18 11:06:44 +01:00
Piotr Sarna
824e9dc352 tests: fix order of parameters in with_rows_ignore_order
When reporting a failure, expected rows were mixed up with received
rows. Also, the message assumed it received more rows, but it can
as well be less, so now it reports a "different number" of rows.
2019-02-18 11:06:44 +01:00
Avi Kivity
a1567b0997 Merge "replace get_restricted_ranges() function with generator interface" from Gleb
"
get_restricted_ranges() is inefficient since it calculates all
vnodes that cover a requested key ranges in advance, but callers often
use only the first one.  Replace the function with generator interface
that generates requested number of vnodes on demand.
"

* 'gleb/query_ranges_to_vnodes_generator' of github.com:scylladb/seastar-dev:
  storage_proxy: limit amount of precaclulated ranges by query_ranges_to_vnodes_generator
  storage_proxy: remove old get_restricted_ranges() interface
  cql3/statements/select_statement: convert index query interface to new query_ranges_to_vnodes_generator interface
  tests: convert storage_proxy test to new query_ranges_to_vnodes_generator interface
  storage_proxy: convert range query path to new query_ranges_to_vnodes_generator interface
  storage_proxy: introduce new query_ranges_to_vnode_generator interface
2019-02-18 10:33:54 +02:00
Avi Kivity
03531c2443 fragmented_temporary_buffer: fix read_exactly() during premature end-of-stream
read_exactly(), when given a stream that does not contain the amount of data
requested, will loop endlessly, allocating more and more memory as it does, until
it fails with an exception (at which point it will release the memory).

Fix by returning an empty result, like input_stream::read_exactly() (which it
replaces). Add a test case that fails without a fix.

Affected callers are the native transport, commitlog replay, and internal
deserialization.

Fixes #4233.

Branches: master, branch-3.0
Tests: unit(dev)
Message-Id: <20190216150825.14841-1-avi@scylladb.com>
2019-02-16 17:06:19 +00:00
Rafael Ávila de Espíndola
9cd14f2602 Don't write to system.large_partition during shutdown
The included testcase used to crash because during database::stop() we
would try to update system.large_partition.

There doesn't seem to be an order we can stop the existing services in
cql_test_env that makes this possible.

This patch then adds another step when shutting down a database: first
stop updating system.large_partition.

This means that during shutdown any memtable flush, compaction or
sstable deletion will not be reflected in system.large_partition. This
is hopefully not too bad since the data in the table is TTLed.

This seems to impact only tests, since main.cc calls _exit directly.

Tests: unit (release,debug)

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
Message-Id: <20190213194851.117692-1-espindola@scylladb.com>
2019-02-15 10:49:10 +01:00
Benny Halevy
c8f239ff2b tests: introduce sstables::test_env
In preparation to adding sstables_manager we want
to establish an environment for testing sstables.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:37:41 +02:00
Benny Halevy
f9546b23b7 tests: perf_sstable: rename test_env
test_env is going to be a class in sstables namespace

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:15 +02:00
Benny Halevy
d6cfc1fae5 tests: sstable_datafile_test: use useable_sst
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
2a6b5a7622 tests: sstable_test: add write_and_validate_sst helper
In preparation for sstables::test_env

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
255f05e6c8 tests: sstable_test: add test_using_reusable_sst helper
In preparation for sstables::test_env

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
e11e29a1fc tests: sstable_test: use reusable_sst where possible
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
9d4989f2e8 tests: sstable_test: add test_using_working_sst helper
In preparation for sstables::test_env

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
55aac22b37 tests: sstable_3_x_test: make_test_sstable
Reused for making sstables for test cases.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
3bc1b8b9ff tests: run_sstable_resharding_test: use default parameters to make_sstable
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:22:14 +02:00
Benny Halevy
b0f3f8d766 tests: sstables::test::make_test_sstable: reorder params
In preparation for providing a default large_data_handler in
a test-standard way.

buffer_size parameter reordered and now has a default value
same as make_sstable()'s.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:21:36 +02:00
Benny Halevy
bcd3f36a8a tests: test_setup: do_with_test_directory is unused
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2019-02-14 22:21:32 +02:00