Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require AWS access keys for S3 pytests #6556

Merged
merged 7 commits into from
Feb 1, 2024

Conversation

arpad-m
Copy link
Member

@arpad-m arpad-m commented Jan 31, 2024

Don't require AWS access keys (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) for S3 usage in the pytests, and also allow AWS_PROFILE to be passed.

One of the two methods is required however.

This allows local development like:

aws sso login --profile dev
export ENABLE_REAL_S3_REMOTE_STORAGE=nonempty REMOTE_STORAGE_S3_REGION=eu-central-1 REMOTE_STORAGE_S3_BUCKET=neon-github-ci-tests AWS_PROFILE=dev
cargo build_testing && RUST_BACKTRACE=1 ./scripts/pytest -k debug-pg16 test_runner/regress/test_tenant_delete.py::test_tenant_delete_smoke

related earlier PR for the cargo unit tests of the remote_storage crate: #6202

Also allow AWS_PROFILE to be passed.

One of the two methods is required however.
@arpad-m arpad-m requested a review from bayandin January 31, 2024 16:51
@arpad-m
Copy link
Member Author

arpad-m commented Jan 31, 2024

sadly it doesn't work however, the test fails and the pageserver log says it's an authentication issue:

2024-01-31T16:51:13.730780Z  INFO Using s3 bucket 'neon-github-ci-tests' in region 'eu-central-1' as a remote storage, prefix in bucket: 'Some("929215e1-150a-4671-a5f0-fa8511a54bc0/test-tenant-delete-smoke-debug-pg16-/pageserver")', bucket endpoint: 'None', profile: Some("dev"), access_key_id: None
[...]
2024-01-31T16:51:16.558695Z  INFO attach_preload{tenant_id=354d6017ac6faba459d228e056d30cd1 shard_id=0000}: list timelines for 354d6017ac6faba459d228e056d30cd1 failed, will retry (attempt 1): Failed to download a remote file: Failed to list S3 prefixes

Caused by:
    0: dispatch failure
    1: other
    2: the credential provider was not enabled
    3: no providers in chain provided credentials

Apparently the key does get picked up by the pageserver but for some reason it still doesn't pick up the auth information...

@arpad-m arpad-m marked this pull request as ready for review January 31, 2024 17:18
@arpad-m arpad-m requested review from a team as code owners January 31, 2024 17:18
@arpad-m arpad-m requested review from problame and knizhnik and removed request for a team January 31, 2024 17:18
@arpad-m
Copy link
Member Author

arpad-m commented Jan 31, 2024

found the issue, had to also import the HOME env variable. See the new commit.

It works now locally, although i had to increase the iteration number, probably due to higher latencies from my box to S3:

diff --git a/test_runner/regress/test_tenant_delete.py b/test_runner/regress/test_tenant_delete.py
index b4e5a550f..392b8add6 100644
--- a/test_runner/regress/test_tenant_delete.py
+++ b/test_runner/regress/test_tenant_delete.py
@@ -89,7 +89,7 @@ def test_tenant_delete_smoke(
     iterations = poll_for_remote_storage_iterations(remote_storage_kind)
 
     assert ps_http.get_metric_value("pageserver_tenant_manager_slots") == 2
-    tenant_delete_wait_completed(ps_http, tenant_id, iterations)
+    tenant_delete_wait_completed(ps_http, tenant_id, iterations * 10)
     assert ps_http.get_metric_value("pageserver_tenant_manager_slots") == 1
 
     tenant_path = env.pageserver.tenant_dir(tenant_id)

Copy link

github-actions bot commented Jan 31, 2024

2376 tests run: 2263 passed, 0 failed, 113 skipped (full report)


Flaky tests (8)

Postgres 16

Postgres 15

  • test_gc_cutoff: debug
  • test_emergency_mode: debug
  • test_location_conf_churn[3]: debug

Postgres 14

  • test_gc_cutoff: debug
  • test_timeline_deletion_with_files_stuck_in_upload_queue: debug
  • test_timeline_size_quota_on_startup: release

Code coverage (full report)

  • functions: 54.5% (11228 of 20610 functions)
  • lines: 81.5% (63274 of 77650 lines)

The comment gets automatically updated with the latest test results
d2e1d44 at 2024-02-01T18:35:15.038Z :recycle:

Copy link
Member

@bayandin bayandin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It's going to be much more convenient to use it locally

test_runner/fixtures/remote_storage.py Outdated Show resolved Hide resolved
control_plane/src/background_process.rs Outdated Show resolved Hide resolved
arpad-m and others added 2 commits February 1, 2024 15:04
Co-authored-by: Alexander Bayandin <alexander@neon.tech>
Co-authored-by: Alexander Bayandin <alexander@neon.tech>
@arpad-m arpad-m enabled auto-merge (squash) February 1, 2024 14:17
@arpad-m arpad-m merged commit 527cdbc into main Feb 1, 2024
47 checks passed
@arpad-m arpad-m deleted the arpad/dont_require_access_key branch February 1, 2024 20:18
arpad-m added a commit that referenced this pull request Aug 10, 2024
Noticed this while debugging a test failure in #8673 which only occurs
with real S3 instead of mock S3: if you authenticate to S3 via
`AWS_PROFILE`, then it requires the `HOME` env var to be set so that it
can read inside the `~/.aws` directory.

The scrubber abstraction `StorageScrubber::scrubber_cli` in
`neon_fixtures.py` would otherwise not work. My earlier PR #6556 has
done similar things for the `neon_local` wrapper.

You can try:

```
aws sso login --profile dev
export ENABLE_REAL_S3_REMOTE_STORAGE=y REMOTE_STORAGE_S3_BUCKET=neon-github-ci-tests REMOTE_STORAGE_S3_REGION=eu-central-1 AWS_PROFILE=dev
RUST_BACKTRACE=1 BUILD_TYPE=debug DEFAULT_PG_VERSION=16 ./scripts/pytest -vv --tb=short -k test_scrubber_tenant_snapshot
```

before and after this patch: this patch fixes it.
jcsp pushed a commit that referenced this pull request Aug 12, 2024
Noticed this while debugging a test failure in #8673 which only occurs
with real S3 instead of mock S3: if you authenticate to S3 via
`AWS_PROFILE`, then it requires the `HOME` env var to be set so that it
can read inside the `~/.aws` directory.

The scrubber abstraction `StorageScrubber::scrubber_cli` in
`neon_fixtures.py` would otherwise not work. My earlier PR #6556 has
done similar things for the `neon_local` wrapper.

You can try:

```
aws sso login --profile dev
export ENABLE_REAL_S3_REMOTE_STORAGE=y REMOTE_STORAGE_S3_BUCKET=neon-github-ci-tests REMOTE_STORAGE_S3_REGION=eu-central-1 AWS_PROFILE=dev
RUST_BACKTRACE=1 BUILD_TYPE=debug DEFAULT_PG_VERSION=16 ./scripts/pytest -vv --tb=short -k test_scrubber_tenant_snapshot
```

before and after this patch: this patch fixes it.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants