Skip to content

Commit

Permalink
tests: remove extraneous 404-waiting helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsp committed Jun 18, 2024
1 parent 4d845d8 commit 262f00c
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 81 deletions.
46 changes: 0 additions & 46 deletions test_runner/fixtures/pageserver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,52 +430,6 @@ def enable_remote_storage_versioning(
return response


def wait_tenant_status_404(
pageserver_http: PageserverHttpClient,
tenant_id: TenantId,
iterations: int,
interval: float = 0.250,
):
def tenant_is_missing():
data = {}
try:
data = pageserver_http.tenant_status(tenant_id)
log.info(f"tenant status {data}")
except PageserverApiException as e:
log.debug(e)
if e.status_code == 404:
return

raise RuntimeError(f"Timeline exists state {data.get('state')}")

wait_until(iterations, interval=interval, func=tenant_is_missing)


def tenant_delete_wait_completed(
pageserver_http: PageserverHttpClient,
tenant_id: TenantId,
iterations: int,
ignore_errors: bool = False,
):
if not ignore_errors:
pageserver_http.tenant_delete(tenant_id=tenant_id)
else:
interval = 0.5

def delete_request_sent():
try:
pageserver_http.tenant_delete(tenant_id=tenant_id)
except PageserverApiException as e:
log.debug(e)
if e.status_code == 404:
return
except Exception as e:
log.debug(e)

wait_until(iterations, interval=interval, func=delete_request_sent)
wait_tenant_status_404(pageserver_http, tenant_id=tenant_id, iterations=iterations)


MANY_SMALL_LAYERS_TENANT_CONFIG = {
"gc_period": "0s",
"compaction_period": "0s",
Expand Down
2 changes: 0 additions & 2 deletions test_runner/performance/test_bulk_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from fixtures.benchmark_fixture import MetricReport
from fixtures.common_types import Lsn
from fixtures.compare_fixtures import NeonCompare, PgCompare
from fixtures.pageserver.utils import wait_tenant_status_404
from fixtures.pg_version import PgVersion


Expand Down Expand Up @@ -68,7 +67,6 @@ def measure_recovery_time(env: NeonCompare):
(attach_gen, _) = attach_status

client.tenant_delete(env.tenant)
wait_tenant_status_404(client, env.tenant, iterations=60, interval=0.5)
env.env.pageserver.tenant_create(tenant_id=env.tenant, generation=attach_gen)

# Measure recovery time
Expand Down
7 changes: 2 additions & 5 deletions test_runner/regress/test_pageserver_secondary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from fixtures.pageserver.common_types import parse_layer_file_name
from fixtures.pageserver.utils import (
assert_prefix_empty,
poll_for_remote_storage_iterations,
tenant_delete_wait_completed,
wait_for_upload_queue_empty,
)
from fixtures.remote_storage import LocalFsStorage, RemoteStorageKind, S3Storage, s3_storage
Expand Down Expand Up @@ -363,8 +361,7 @@ def caught_up():

# Check that deletion works properly on a tenant that was live-migrated
# (reproduce https://github.com/neondatabase/neon/issues/6802)
iterations = poll_for_remote_storage_iterations(remote_storage_kind)
tenant_delete_wait_completed(pageserver_b.http_client(), tenant_id, iterations)
pageserver_b.http_client().tenant_delete(tenant_id)


def test_heatmap_uploads(neon_env_builder: NeonEnvBuilder):
Expand Down Expand Up @@ -552,7 +549,7 @@ def test_secondary_downloads(neon_env_builder: NeonEnvBuilder):
)

log.info("Deleting tenant...")
tenant_delete_wait_completed(ps_attached.http_client(), tenant_id, 10)
ps_attached.http_client().tenant_delete(tenant_id)

assert_prefix_empty(
neon_env_builder.pageserver_remote_storage,
Expand Down
5 changes: 1 addition & 4 deletions test_runner/regress/test_s3_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
MANY_SMALL_LAYERS_TENANT_CONFIG,
assert_prefix_empty,
enable_remote_storage_versioning,
poll_for_remote_storage_iterations,
tenant_delete_wait_completed,
wait_for_upload,
)
from fixtures.remote_storage import RemoteStorageKind, s3_storage
Expand Down Expand Up @@ -83,8 +81,7 @@ def test_tenant_s3_restore(
assert (
ps_http.get_metric_value("pageserver_tenant_manager_slots", {"mode": "attached"}) == 1
), "tenant removed before we deletion was issued"
iterations = poll_for_remote_storage_iterations(remote_storage_kind)
tenant_delete_wait_completed(ps_http, tenant_id, iterations)
ps_http.tenant_delete(tenant_id)
ps_http.deletion_queue_flush(execute=True)
assert (
ps_http.get_metric_value("pageserver_tenant_manager_slots", {"mode": "attached"}) == 0
Expand Down
3 changes: 1 addition & 2 deletions test_runner/regress/test_storage_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
enable_remote_storage_versioning,
list_prefix,
remote_storage_delete_key,
tenant_delete_wait_completed,
timeline_delete_wait_completed,
)
from fixtures.pg_version import PgVersion
Expand Down Expand Up @@ -158,7 +157,7 @@ def node_evacuated(node_id: int) -> None:

# Delete all the tenants
for tid in tenant_ids:
tenant_delete_wait_completed(env.storage_controller.pageserver_api(), tid, 10)
env.storage_controller.pageserver_api().tenant_delete(tid)

env.storage_controller.consistency_check()

Expand Down
17 changes: 3 additions & 14 deletions test_runner/regress/test_tenant_delete.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import concurrent.futures
import enum
import os
import shutil
from threading import Thread

import pytest
from fixtures.common_types import Lsn, TenantId, TimelineId
from fixtures.log_helper import log
from fixtures.neon_fixtures import (
NeonEnvBuilder,
PgBin,
StorageScrubber,
last_flush_lsn_upload,
wait_for_last_flush_lsn,
)
from fixtures.pageserver.http import PageserverApiException
from fixtures.pageserver.utils import (
MANY_SMALL_LAYERS_TENANT_CONFIG,
assert_prefix_empty,
assert_prefix_not_empty,
poll_for_remote_storage_iterations,
tenant_delete_wait_completed,
wait_for_upload,
)
from fixtures.remote_storage import RemoteStorageKind, available_s3_storages, s3_storage
from fixtures.remote_storage import RemoteStorageKind, s3_storage
from fixtures.utils import run_pg_bench_small, wait_until
from requests.exceptions import ReadTimeout

Expand Down Expand Up @@ -297,9 +289,7 @@ def deletion_arrived():
# Disable the failpoint and wait for deletion to finish
ps_http.configure_failpoints((BEFORE_INITDB_UPLOAD_FAILPOINT, "off"))

iterations = poll_for_remote_storage_iterations(remote_storage_kind)

tenant_delete_wait_completed(ps_http, tenant_id, iterations, ignore_errors=True)
ps_http.tenant_delete(tenant_id)

# Physical deletion should have happened
assert_prefix_empty(
Expand Down Expand Up @@ -350,8 +340,7 @@ def test_tenant_delete_scrubber(pg_bin: PgBin, neon_env_builder: NeonEnvBuilder)

env.start()
ps_http = env.pageserver.http_client()
iterations = poll_for_remote_storage_iterations(remote_storage_kind)
tenant_delete_wait_completed(ps_http, tenant_id, iterations)
ps_http.tenant_delete(tenant_id)
env.stop()

scrubber.scan_metadata()
Expand Down
4 changes: 0 additions & 4 deletions test_runner/regress/test_tenant_relocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
assert_tenant_state,
wait_for_last_record_lsn,
wait_for_upload,
wait_tenant_status_404,
)
from fixtures.remote_storage import (
LocalFsStorage,
Expand Down Expand Up @@ -348,9 +347,6 @@ def test_tenant_relocation(
# is no longer involved, and if it is, we will see the error
origin_http.tenant_detach(tenant_id)

# Wait a little, so that the detach operation has time to finish.
wait_tenant_status_404(origin_http, tenant_id, iterations=100, interval=1)

post_migration_check(ep_main, 500500, old_local_path_main)
post_migration_check(ep_second, 1001000, old_local_path_second)

Expand Down
3 changes: 1 addition & 2 deletions test_runner/regress/test_tenant_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
)
from fixtures.pageserver.http import PageserverApiException, PageserverHttpClient
from fixtures.pageserver.utils import (
tenant_delete_wait_completed,
timeline_delete_wait_completed,
wait_until_tenant_active,
)
Expand Down Expand Up @@ -669,7 +668,7 @@ def test_synthetic_size_while_deleting(neon_env_builder: NeonEnvBuilder):
),
)

tenant_delete_wait_completed(client, env.initial_tenant, 10)
client.tenant_delete(env.initial_tenant)

client.configure_failpoints((failpoint, "off"))

Expand Down
3 changes: 1 addition & 2 deletions test_runner/regress/test_timeline_detach_ancestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
wait_for_last_flush_lsn,
)
from fixtures.pageserver.http import HistoricLayerInfo, PageserverApiException
from fixtures.pageserver.utils import wait_tenant_status_404, wait_timeline_detail_404
from fixtures.pageserver.utils import wait_timeline_detail_404
from fixtures.remote_storage import LocalFsStorage
from fixtures.utils import assert_pageserver_backups_equal

Expand Down Expand Up @@ -578,7 +578,6 @@ def test_timeline_ancestor_errors(neon_env_builder: NeonEnvBuilder):
assert info.value.status_code == 400

client.tenant_delete(env.initial_tenant)
wait_tenant_status_404(client, env.initial_tenant, 10, 1)

with pytest.raises(PageserverApiException) as e:
client.detach_ancestor(env.initial_tenant, first_branch)
Expand Down

0 comments on commit 262f00c

Please sign in to comment.