Files
scylladb/test/rest_api/test_gossiper.py
Botond Dénes ca8723a6fd Merge 'gossiper: add get_unreachable_members_synchronized and use over api' from Benny Halevy
Modeled after get_live_members_synchronized,
get_unreachable_members_synchronized calls
replicate_live_endpoints_on_change to synchronize
the state of unreachable_members on all shards.

Fixes #12261
Fixes #15088

Also, add rest_api unit test for those apis

Closes #15093

* github.com:scylladb/scylladb:
  test: rest_api: add test_gossiper
  gossiper: add get_unreachable_members_synchronized

(cherry picked from commit 57deeb5d39)

Backport note: `gossiper::lock_endpoint_update_semaphore` helper
function was missing, replaced with
`get_units(g._endpoint_update_semaphore, 1)`
2023-09-27 15:09:32 +02:00

43 lines
1.4 KiB
Python

# Copyright 2023-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import pytest
import sys
import requests
import threading
import time
# Use the util.py library from ../cql-pytest:
sys.path.insert(1, sys.path[0] + '/../cql-pytest')
def test_gossiper_live_endpoints(cql, rest_api):
resp = rest_api.send("GET", f"gossiper/endpoint/live")
resp.raise_for_status()
live_endpoints = set(resp.json())
all_hosts_endpoints = set([host.address for host in cql.cluster.metadata.all_hosts()])
assert live_endpoints == all_hosts_endpoints
def test_gossiper_unreachable_endpoints(cql, rest_api):
resp = rest_api.send("GET", f"gossiper/endpoint/down")
resp.raise_for_status()
unreachable_endpoints = set(resp.json())
assert not unreachable_endpoints
def test_gossiper_unreachable_endpoints(cql, rest_api):
resp = rest_api.send("GET", f"gossiper/endpoint/down")
resp.raise_for_status()
unreachable_endpoints = set(resp.json())
for ep in unreachable_endpoints:
resp = rest_api.send("GET", f"gossiper/downtime/{ep}")
resp.raise_for_status()
assert int(resp.json()) > 0
resp = rest_api.send("GET", f"gossiper/endpoint/live")
resp.raise_for_status()
live_endpoints = set(resp.json())
for ep in live_endpoints:
resp = rest_api.send("GET", f"gossiper/downtime/{ep}")
resp.raise_for_status()
assert int(resp.json()) == 0