Files
scylladb/test/rest_api/test_failure_detector.py
Pavel Emelyanov 66be0fc1eb Merge 'api: failure_detector: invoke on shard 0' from Kamil Braun
These APIs may return stale or simply incorrect data on shards
other than 0. Newer versions of Scylla are better at maintaining
cross-shard consistency, but we need a simple fix that can be easily and
without risk be backported to older versions; this is the fix.

Add a simple test to check that the `failure_detector/endpoints`
API returns nonzero generation.

Fixes: scylladb/scylladb#15816

Closes scylladb/scylladb#15970

* github.com:scylladb/scylladb:
  test: rest_api: test that generation is nonzero in `failure_detector/endpoints`
  api: failure_detector: fix indentation
  api: failure_detector: invoke on shard 0

(cherry picked from commit 9443253f3d)
2023-11-07 14:50:41 +01:00

30 lines
1.0 KiB
Python

# Copyright 2023-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import re
import time
def test_failure_detector_endpoints(rest_api):
resp = rest_api.send('GET', "failure_detector/endpoints")
resp.raise_for_status()
assert len(resp.json()) == 1
addr = resp.json()[0]['addrs']
assert re.match(r'\d+\.\d+\.\d+\.\d+', addr)
def test_failure_detector_endpoint_phi_values(rest_api):
# This api currently always returns empty results
# so just check it doesn't return an error or crash
resp = rest_api.send('GET', "failure_detector/endpoint_phi_values")
resp.raise_for_status()
def test_nonzero_generation(rest_api):
# In older versions of Scylla, shards other than 0 would return generation=0.
# Call the endpoint multiple times to increase the chance of hitting nonzero shard.
for _ in range(100):
resp = rest_api.send('GET', "failure_detector/endpoints")
resp.raise_for_status()
assert len(resp.json()) == 1
gen = int(resp.json()[0]['generation'])
assert gen > 0