-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR: * Implements the rule that archived timelines require all of their children to be archived as well, as specified in the RFC. There is no fancy locking mechanism though, so the precondition can still be broken. As a TODO for later, we still allow unarchiving timelines with archived parents. * Adds an `is_archived` flag to `TimelineInfo` * Adds timeline_archival_config to `PageserverHttpClient` * Adds a new `test_timeline_archive` test, loosely based on `test_timeline_delete` Part of #8088
- Loading branch information
Showing
6 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import pytest | ||
from fixtures.common_types import TenantId, TimelineArchivalState, TimelineId | ||
from fixtures.neon_fixtures import ( | ||
NeonEnv, | ||
) | ||
from fixtures.pageserver.http import PageserverApiException | ||
|
||
|
||
def test_timeline_archive(neon_simple_env: NeonEnv): | ||
env = neon_simple_env | ||
|
||
env.pageserver.allowed_errors.extend( | ||
[ | ||
".*Timeline .* was not found.*", | ||
".*timeline not found.*", | ||
".*Cannot archive timeline which has unarchived child timelines.*", | ||
".*Precondition failed: Requested tenant is missing.*", | ||
] | ||
) | ||
|
||
ps_http = env.pageserver.http_client() | ||
|
||
# first try to archive non existing timeline | ||
# for existing tenant: | ||
invalid_timeline_id = TimelineId.generate() | ||
with pytest.raises(PageserverApiException, match="timeline not found") as exc: | ||
ps_http.timeline_archival_config( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=invalid_timeline_id, | ||
state=TimelineArchivalState.ARCHIVED, | ||
) | ||
|
||
assert exc.value.status_code == 404 | ||
|
||
# for non existing tenant: | ||
invalid_tenant_id = TenantId.generate() | ||
with pytest.raises( | ||
PageserverApiException, | ||
match=f"NotFound: tenant {invalid_tenant_id}", | ||
) as exc: | ||
ps_http.timeline_archival_config( | ||
tenant_id=invalid_tenant_id, | ||
timeline_id=invalid_timeline_id, | ||
state=TimelineArchivalState.ARCHIVED, | ||
) | ||
|
||
assert exc.value.status_code == 404 | ||
|
||
# construct pair of branches to validate that pageserver prohibits | ||
# archival of ancestor timelines when they have non-archived child branches | ||
parent_timeline_id = env.neon_cli.create_branch("test_ancestor_branch_archive_parent", "empty") | ||
|
||
leaf_timeline_id = env.neon_cli.create_branch( | ||
"test_ancestor_branch_archive_branch1", "test_ancestor_branch_archive_parent" | ||
) | ||
|
||
timeline_path = env.pageserver.timeline_dir(env.initial_tenant, parent_timeline_id) | ||
|
||
with pytest.raises( | ||
PageserverApiException, | ||
match="Cannot archive timeline which has non-archived child timelines", | ||
) as exc: | ||
assert timeline_path.exists() | ||
|
||
ps_http.timeline_archival_config( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=parent_timeline_id, | ||
state=TimelineArchivalState.ARCHIVED, | ||
) | ||
|
||
assert exc.value.status_code == 412 | ||
|
||
# Test timeline_detail | ||
leaf_detail = ps_http.timeline_detail( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=leaf_timeline_id, | ||
) | ||
assert leaf_detail["is_archived"] is False | ||
|
||
# Test that archiving the leaf timeline and then the parent works | ||
ps_http.timeline_archival_config( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=leaf_timeline_id, | ||
state=TimelineArchivalState.ARCHIVED, | ||
) | ||
leaf_detail = ps_http.timeline_detail( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=leaf_timeline_id, | ||
) | ||
assert leaf_detail["is_archived"] is True | ||
|
||
ps_http.timeline_archival_config( | ||
tenant_id=env.initial_tenant, | ||
timeline_id=parent_timeline_id, | ||
state=TimelineArchivalState.ARCHIVED, | ||
) |
2dd53e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3861 tests run: 3745 passed, 0 failed, 116 skipped (full report)
Flaky tests (2)
Postgres 14
test_wal_restore_initdb
: release-arm64test_wal_restore
: release-arm64Code coverage* (full report)
functions
:32.1% (7256 of 22571 functions)
lines
:50.3% (58806 of 116980 lines)
* collected from Rust tests only
2dd53e7 at 2024-08-26T17:21:00.008Z :recycle: