Files
scylladb/test/cql/cdc_enable_disable_test.cql
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

55 lines
1.8 KiB
SQL

-- 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};
-- create cdc enabled table
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true};
-- this write goes to the log
insert into ks.t (pk, ck, v) values (0, 1, 100);
-- disable cdc. should retain the log
alter table ks.t with cdc = {'enabled': false};
-- add more data to base - should not generate log
insert into ks.t (pk, ck, v) values (0, 2, 200);
-- 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;
-- lets add a column
alter table ks.t add v2 text;
-- add more data
insert into ks.t (pk, ck, v, v2) values (0, 3, 300, 'apa');
-- turn cdc back on
alter table ks.t with cdc = {'enabled': true};
-- more data - this should also go to log.
insert into ks.t (pk, ck, v, v2) values (0, 4, 400, 'snus');
-- 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;
-- disable cdc. should retain the log
alter table ks.t with cdc = {'enabled': false};
-- remove older column
alter table ks.t drop v;
-- add more data
insert into ks.t (pk, ck, v2) values (0, 5, 'fisk');
-- turn cdc back on
alter table ks.t with cdc = {'enabled': true};
insert into ks.t (pk, ck, v2) values (0, 6, 'aborre');
-- 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;
DROP KEYSPACE ks;