Files
scylladb/test/cql/cdc_enable_disable_test.result
Jan Ciolek d2ef55b12c test: use NetworkTopologyStrategy in all unit tests
As described in https://github.com/scylladb/scylladb/issues/8638,
we're moving away from `SimpleStrategy`, in the future
it will become deprecated.

We should remove all uses of it and replace them
with `NetworkTopologyStrategy`.

This change replaces `SimpleStrategy` with
`NetworkTopologyStrategy` in all unit tests,
or at least in the ones where it was reasonable to do so.
Some of the tests were written explicitly to test the
`SimpleStrategy` strategy, or changing the keyspace from
`SimpleStrategy` to `NetworkTopologyStrategy`.
These tests were left intact.
It's still a feature that is supported,
even if it's slowly getting deprecated.

The typical way to use `NetworkTopologyStrategy` is
to specify a replication factor for each datacenter.
This could be a bit cumbersome, we would have to fetch
the list of datacenters, set the repfactors, etc.

Luckily there is another way - we can just specify
a replication factor to use for or each existing
datacenter, like this:
```cql
CREATE KEYSPACE {} WITH REPLICATION =
{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1};
```

This makes the change rather straightforward - just replace all
instances of `'SimpleStrategy'', with `'NetworkTopologyStrategy'`.

Refs: https://github.com/scylladb/scylladb/issues/8638

Signed-off-by: Jan Ciolek <jan.ciolek@scylladb.com>

Closes #13990
2023-05-23 08:52:56 +03:00

88 lines
3.3 KiB
Plaintext

> -- Important: using the same partition key for each row so the results of select from log table
> -- do not depend on how stream IDs are assigned to partition keys.
>
> -- Error messages contain a keyspace name. Make the output stable.
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
OK
>
> -- create cdc enabled table
> create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true};
OK
>
> -- this write goes to the log
> insert into ks.t (pk, ck, v) values (0, 1, 100);
OK
>
> -- disable cdc. should retain the log
> alter table ks.t with cdc = {'enabled': false};
OK
>
> -- add more data to base - should not generate log
> insert into ks.t (pk, ck, v) values (0, 2, 200);
OK
>
> -- should still work, and give one row (0, 1, 100)
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from ks.t_scylla_cdc_log;
+--------------------+-----------------+-----------+------+------+-----+
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v |
|--------------------+-----------------+-----------+------+------+-----|
| 0 | 2 | null | 0 | 1 | 100 |
+--------------------+-----------------+-----------+------+------+-----+
>
> -- lets add a column
> alter table ks.t add v2 text;
OK
>
> -- add more data
> insert into ks.t (pk, ck, v, v2) values (0, 3, 300, 'apa');
OK
>
> -- turn cdc back on
> alter table ks.t with cdc = {'enabled': true};
OK
>
> -- more data - this should also go to log.
> insert into ks.t (pk, ck, v, v2) values (0, 4, 400, 'snus');
OK
>
> -- gives two rows (0, 1, 100)+(0, 4, 400, 'snus')
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v, v2 from ks.t_scylla_cdc_log;
+--------------------+-----------------+-----------+------+------+-----+------+
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v | v2 |
|--------------------+-----------------+-----------+------+------+-----+------|
| 0 | 2 | null | 0 | 1 | 100 | null |
| 0 | 2 | null | 0 | 4 | 400 | snus |
+--------------------+-----------------+-----------+------+------+-----+------+
>
> -- disable cdc. should retain the log
> alter table ks.t with cdc = {'enabled': false};
OK
>
> -- remove older column
> alter table ks.t drop v;
OK
>
> -- add more data
> insert into ks.t (pk, ck, v2) values (0, 5, 'fisk');
OK
>
> -- turn cdc back on
> alter table ks.t with cdc = {'enabled': true};
OK
>
> insert into ks.t (pk, ck, v2) values (0, 6, 'aborre');
OK
>
> -- gives three rows (0, 1)+(0, 4, 'snus')+(0, 6, 'aborre')
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v2 from ks.t_scylla_cdc_log;
+--------------------+-----------------+-----------+------+------+--------+
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v2 |
|--------------------+-----------------+-----------+------+------+--------|
| 0 | 2 | null | 0 | 1 | null |
| 0 | 2 | null | 0 | 4 | snus |
| 0 | 2 | null | 0 | 6 | aborre |
+--------------------+-----------------+-----------+------+------+--------+
>
> DROP KEYSPACE ks;
OK