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

127 lines
3.2 KiB
Plaintext

> -- Error messages contain a keyspace name. Make the output stable.
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
OK
> CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
OK
>
> -- insert some values in one column
> UPDATE ks.tbl_cnt SET c1 = c1+1 WHERE pk = 1;
OK
> UPDATE ks.tbl_cnt SET c1 = c1+2 WHERE pk = 2;
OK
> UPDATE ks.tbl_cnt SET c1 = c1+3 WHERE pk = 3;
OK
> UPDATE ks.tbl_cnt SET c1 = c1+4 WHERE pk = 4;
OK
>
> -- test various filtering options on counter column
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 3 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 1 | 1 |
| 2 | 2 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 < 1 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 3 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 2 AND pk = 4 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 4 | 4 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 >= 3 and pk = 3 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 3 | 3 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > 4 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 in (-1, 2, 3) ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 2 | 2 |
| 3 | 3 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 0 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 1 | 1 |
+------+------+
>
> -- delete `c1` and make sure it doesn't appear in filtering results
> DELETE c1 from ks.tbl_cnt WHERE pk = 1;
OK
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 = 1 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 <= 1000 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 2 | 2 |
| 4 | 4 |
| 3 | 3 |
+------+------+
> SELECT pk, c1 FROM ks.tbl_cnt WHERE c1 > -1000 ALLOW FILTERING;
+------+------+
| pk | c1 |
|------+------|
| 2 | 2 |
| 4 | 4 |
| 3 | 3 |
+------+------+
> DROP KEYSPACE ks;
OK
>
> CREATE TABLE counter_bug (t int, c counter, primary key(t));
OK
> UPDATE counter_bug SET c = c + 9223372036854775807 where t = 0;
OK
> SELECT * from counter_bug;
+-----+---------------------+
| t | c |
|-----+---------------------|
| 0 | 9223372036854775807 |
+-----+---------------------+
> UPDATE counter_bug SET c = c + 1 where t = 0;
OK
> SELECT * from counter_bug;
+-----+----------------------+
| t | c |
|-----+----------------------|
| 0 | -9223372036854775808 |
+-----+----------------------+
> UPDATE counter_bug SET c = c - 1 where t = 0;
OK
> SELECT * from counter_bug;
+-----+---------------------+
| t | c |
|-----+---------------------|
| 0 | 9223372036854775807 |
+-----+---------------------+