Commit Graph

35 Commits

Author SHA1 Message Date
Pavel Emelyanov
031893259a treewide: Rename sstable registry location field to be owner
This is sort of continuation of the previous patch. The partition key in
the registry is now table_id, not string, and is better called "owner",
not "location". This patch is s/location/owner/ over specific places
that include field name in the schema, argument names in registry
maintenance classes and tests accessing the selected row fields by name.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-10-11 14:11:28 +03:00
Pavel Emelyanov
3315e3a2a9 system_keyspace: Change sstables registry partition key type
Today, the system.sstables schema uses string as partition key. Callers,
in turn, use table's datadir value to reference entries in it. That's
wrong, S3-backed sstables don't have any local paths to work with. The
table's ID is better in this role.

This patch only changes the field type to be table_id and fixes the
callers to provide one. In particular, see init_table_storage() change
-- instead of generating a datadir string, it sets table.id() as the
options' location. Other fixed places are tests. Internally, this id
value is propagated via s3_storage::owner() method, that's fixed as
well.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-10-11 13:48:09 +03:00
Pavel Emelyanov
47e49e6dec test/object_store: Move format_tuples()
There will soon appear a new .py file in the suite that will want to use
this helper too

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-08-22 19:47:06 +03:00
Pavel Emelyanov
8b1a106b62 test/object_store: Use boto3.resource to list bucket
Instead of plain http request, use the power of boto3 package. The
recently added get_s3_resource() facilitates creating one

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-07-29 12:29:16 +03:00
Andrei Chekun
93b9b85c12 [test.py] Refactor alternator, nodetool, rest_api
Make alternator, nodetool and rest_api test directories as python packages.
Move scylla-gdb to scylla_gdb and make it python package.
2024-06-13 13:56:10 +02:00
Pavel Emelyanov
5e23493d25 test: Add test for how quarantined sstables registry entries are loaded
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-04-26 16:54:43 +03:00
Pavel Emelyanov
5afaa03241 test/object_store: Remove unused managed_cluster (and other stuff)
Now all test cases use pylib manager client to manipulate cluster
While at it -- drop more unused bits from suite .py files

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:40:25 +03:00
Pavel Emelyanov
95ed46e26a test/object_store: Use tmpdir fixture in flush-retry case
Now when the test case in question is not using ManagerCluster, there's
no point in using test_tempdir either and the temporary object-store
config can be generated in generic temporary directory

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:39:30 +03:00
Pavel Emelyanov
252688fe0c test/object_store: Turn flush-retry case to use ManagerClient
In the middle this test case needs to force scylla server reload its
configs. Currently manager API requires that some existing config option
is provided as an argument, but in this test case scylla.yaml remains
intact. So it satisfies the API with non-chaning option.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:32:34 +03:00
Pavel Emelyanov
e742906f1f test/object_store: Turn "misconfigured" case to use ManagerClient
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:32:34 +03:00
Pavel Emelyanov
857b48f950 test/object_store: Turn garbage-collect case to use ManagerClient
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:32:34 +03:00
Pavel Emelyanov
d27b91cfb4 test/object_store: Turn basic case to use ManagerClient
This case is a bit tricky, as it needs to know where scylla's workdir
is, so it replaces the use of test_tempdir with the call to manager to
get server's workdir.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:32:34 +03:00
Pavel Emelyanov
89d0704d9b test/object_store: Prepare to work with ManagerClient
This includes

- marking the suite as Topology
- import needed fixtures and options from topology conftest
- configuring the zero initial cluster size and anonymous auth
- marking all test cases as skipped, as they no longer work after above

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-02-22 17:02:05 +03:00
Yaniv Kaul
c658bdb150 Typos: fix typos in comments
Fixes some typos as found by codespell run on the code.
In this commit, I was hoping to fix only comments, not user-visible alerts, output, etc.
Follow-up commits will take care of them.

Refs: https://github.com/scylladb/scylladb/issues/16255
Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
2023-12-02 22:37:22 +02:00
Pavel Emelyanov
74329e5aee test: Add object_store test to validate config reloading works
The test case is

- start scylla with broken object storage endpoint config
- create and populate s3-backed keyspace
- try flushing it (API call would hang, so do it in the background)
- wait for a few seconds, then fix the config
- wait for the flush to finish and stop scylla
- start scylla again and check that the keyspace is properly populated

Nice side effect of this test is that once flush fails (due to broken
config) it tries to remove the not-yet-sealed sstables and (!) fails
again, for the same reason. So during the restart there happen to be
several sstables in "creating" state with no stored objects, so this
additionally tests one more g.c. corner case

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-11-21 16:47:50 +03:00
Pavel Emelyanov
26f8202651 test: Add config update facility to test cluster
The Cluster wrapper used by object_store test already has the ability to
access cluster via CQL and via API. Add the sugar to make the cluster
re-read its scylla.yaml and other configs

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-11-21 16:47:50 +03:00
Pavel Emelyanov
9b16c298e9 test: Add validation of misconfigured storage creation
In an attempt to create a non-local keyspace with unknown endpoint,
there should pop up the configuration exception.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-11-20 15:25:58 +03:00
Pavel Emelyanov
b31b51ae90 test/cql-pytest/test_keyspaces: Move DESCRIBE case to object store
We're going to ban creation of a keyspace with S3 type in case the
requested endpoint is not configured. The problem is that this test case
of cql-pytest needs such keyspace to be created and in order to provide
the object storage configuration we'd need to touch the generic scylla
cluster management which is an overill for generic cql-pytest case.

Simpler solution is to make object_store test suite perform all the
S3-related checks, including the way DESCRIBE for S3-backed ks works.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-11-20 14:31:08 +03:00
Pavel Emelyanov
a87b5cfbec test/object_store: Generalize test table creation
All two and the upcoming third test cases in the test create the very
same ks.cf pair with the very same sequence of steps. Generalize them.

For the basic test case also tune up the way "expected" rows are
calculated -- now they are SELECT-ed right after insertion and the size
is checked to be non zero. Not _exactly_ the same check, but it's good
enough for basic testing purposes.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes scylladb/scylladb#15986
2023-11-14 13:55:02 +02:00
Pavel Emelyanov
7e1017c7d8 test/object_store: Check that keyspace directory doesn't appear
When creating a S3-backed keyspace its storage dir shouldn't be made.
Also it shouldn't be "resurrected" by boot-time loader of existing
keyspaces.

For extra confidence check that the system keyspace's directory does
exists where the test expects keyspaces' directories to appear.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-11-08 20:23:16 +03:00
Kefu Chai
08f8796cf0 test/object_store: wrap line which is too long
to be compliant to PEP8, see
https://peps.python.org/pep-0008/#blank-lines

also easier to read with smaller screen and/or large fonts.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-11-04 21:29:31 +08:00
Kefu Chai
5c0e4df624 test/object_store: use pattern matching to capture variable in loop
instead of referencing the elements in tuple with their indexes, use
pattern matching to capture them. for better readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-11-04 21:29:31 +08:00
Kefu Chai
6208a05c40 test/object_store: remove space after and before '{' and '}'
to be compliant with PEP8, see
https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements

for better readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-11-04 21:29:31 +08:00
Kefu Chai
231938f739 test/object_store: add an empty line before nested function definition
to be compliant to PEP8, see
https://peps.python.org/pep-0008/#blank-lines

for better readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-11-04 21:29:31 +08:00
Kefu Chai
38d5e7cae2 test/object_store: use two empty lines in-between global functions
to be compliant to PEP8, see
https://peps.python.org/pep-0008/#blank-lines

for better readability.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-11-04 21:29:31 +08:00
Kefu Chai
af8bc8ba63 sstable: switch to uuid identifier for naming S3 sstable objects
before this change, we create a new UUID for a new sstable managed
by the s3_storage, and we use the string representation of UUID
defined by RFC4122 like "0aa490de-7a85-46e2-8f90-38b8f496d53b" for
naming the objects stored on s3_storage. but this representation is
not what we are using for storing sstables on local filesystem when
the option of "uuid_sstable_identifiers_enabled" is enabled. instead,
we are using a base36-based representation which is shorter.

to be consistent with the naming of the sstables created for local
filesystem, and more importantly, to simplify the interaction between
the local copy of sstables and those stored on object storage, we should
use the same string representation of the sstable identifier.

so, in this change:

1. instead of creating a new UUID, just reuse the generation of the
   sstable for the object's key.
2. do not store the uuid in the sstable_registry system table. As
   we already have the generation of the sstable for the same purpose.
3. switch the sstable identifier representation from the one defined
   by the RFC4122 (implemented by fmt::formatter<utils::UUID>) to the
   base36-based one (implemented by
   fmt::formatter<sstables::generation_type>)
4. enable the `uuid_sstable_identifers` cluster feature if it is
   enabled in the `test_env_config`, so that it the sstable manager
   can enable the uuid-based uuid when creating a new uuid for
   sstable.
5. throw if the generation of sstable is not UUID-based when
   accessing / manipulating an sstable with S3 storage backend. as
   the S3 storage backend now relies on this option. as, otherwise
   we'd have sstables with key like s3://bucket/number/basename, which
   is just unable to serve as a unique id for sstable if the bucket is
   shared across multiple tables.

Fixes #14175
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-10-23 10:08:22 +08:00
Kefu Chai
f69a44bb37 test/object_store: redirect to STDOUT and STDERR
pytest changes the test's sys.stdout and sys.stderr to the
captured fds when it captures the outputs of the test. so we
are not able to get the STDOUT_FILENO and STDERR_FILENO in C
by querying `sys.stdout.fileno()` and `sys.stderr.fileno()`.
their return values are not 1 and 2 anymore, unless pytest
is started with "-s".

so, to ensure that we always redirect the child process's
outputs to the log file. we need to use 1 and 2 for accessing
the well-known fds, which are the ones used by the child
process, when it writes to stdout and stderr.

this change should address the problem that the log file is
always empty, unless "-s" is specified.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#15560
2023-10-18 14:54:01 +03:00
Pavel Emelyanov
0eb8d1b438 test/object_store: Use REST client from pylib
Test cases kick scylla to force keyspaces flush (to have the objects on
object store) by hand. Equip the wrapped cluster object with the REST
API class instance for convenience

The assertion for 200 return status code is dropped, REST client does it
behind the scenes

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-09-28 11:33:00 +03:00
Pavel Emelyanov
9ce99a01d5 test/object_store: Wrap yielded managed cluster
Test cases use temporary cluster object which is, in fact, cql cluster.
In the future there will be the need to perform more actions on it
rather than just querying it with cql client, so wrap the cluster with
an extendable object

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-09-28 11:19:03 +03:00
Pavel Emelyanov
3d0a5f2173 test: Extend object_store test to validate GC works
The test-case creates a S3-backed ks, populates it with table and data,
then forces flush to make sstables appear on the backend. Then it
updates the registry by marking all the objects as 'removing' so that on
next boot they will be garbage-collected.

After reboot check that the table is "empty" and also validate that the
backend doesn't have the corresponding objects on board for real

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-09-12 09:56:13 +03:00
Kefu Chai
ec7fa3628c s3/client: generate config file for tests
before this change, object_store/test_basic.py create a config file
for specifying the object storage settings, and pass the path of this
file as the argument of `--object-storage-config-file` option when
running scylla. we have the same requirement when testing scylla
with minio server, where we launch a minio server and manually
create a the config file and feed it to scylla.

to ease the preparation work, let's consolidate by creating the
config file in `minio_server.py`, so it always creates the config
file and put it in its tempdir. since object_store/test_basic.py
can also run against an S3 bucket, the fixture implemented
object_store/conftest.py is updated accordingly to reuse the
helper exposed by MinioServer to create the config file when it
is not available.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-08-17 16:06:55 +08:00
Kefu Chai
ed5825ebdb s3/test: correct outdated comments
these comments or docstrings are not in-sync with the code they
are supposed to explain. so let's update them accordingly.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #14545
2023-07-17 12:03:11 +03:00
Kefu Chai
9080f8842b s3/test: do not return ip in managed_cluster()
let's just use cluster.contact_points for retrieving the IP address
of the scylla node in this single-node cluster. so the name of
managed_cluster() is less weird.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-07-05 17:07:39 +08:00
Kefu Chai
ec6410653f s3/test: verify the behavior with asserts
instead of assigning to "success", let's use assert for this purpose.
simpler this way.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-07-05 17:07:21 +08:00
Kefu Chai
471d75c6c6 s3/test: restructure object_store/run into a pytest
instead of using a single run to perform the test, restructure
it into a pytest based test suite with a single test case.
this should allow us to add more tests exercising the object-storage
and cached/tierd storage in future.

* add fixtures so they can be reused by tests
* use tmpdir fixture for managing the tmpdir, see
  https://docs.pytest.org/en/6.2.x/tmpdir.html#the-tmpdir-fixture
* perform part of the teardown in the "test_tempdir()" fixture
* change the type of test from "Run" to "Python"
* rename "run" to "test_basic.py"
* optionally start the minio server if the settings are not
  found in command line or env variables, so that the tests are
  self-contained without the fixture setup by test.py.
* instead of sys.exit(), use assert statement, as this is
  what pytest uses.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-07-05 17:05:13 +08:00