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

Migrate repository-s3 YAML tests to Java REST tests #117628

Conversation

DaveCTurner
Copy link
Contributor

@DaveCTurner DaveCTurner commented Nov 27, 2024

Today these YAML tests rely on a bunch of rather complex setup organised
by Gradle, and contain lots of duplication and coincident strings,
mostly because that was the only way to achieve what we wanted before we
could orchestrate test clusters and fixtures directly from Java test
suites. We're not actually running the YAML tests in ways that take
advantage of their YAMLness (e.g. in mixed-version clusters, or from
other client libraries).

This commit replaces these tests with Java REST tests which enormously
simplifies this area of code.

Relates ES-9984

@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs auto-backport Automatically create backport pull requests when merged >tech debt v9.0.0 v8.18.0 labels Nov 27, 2024
@DaveCTurner DaveCTurner force-pushed the 2024/11/25/repository-s3-java-rest-tests branch from f727f81 to b32777e Compare November 27, 2024 17:42
Today these YAML tests rely on a bunch of rather complex setup organised
by Gradle, and contain lots of duplication and coincident strings,
mostly because that was the only way to achieve what we wanted before we
could orchestrate test clusters and fixtures directly from Java test
suites. We're not actually running the YAML tests in ways that take
advantage of their YAMLness (e.g. in mixed-version clusters, or from
other client libraries).

This commit replaces these tests with Java REST tests which enormously
simplifies this area of code.

Relates ES-9984
@DaveCTurner DaveCTurner force-pushed the 2024/11/25/repository-s3-java-rest-tests branch from b32777e to 5ff3d75 Compare November 27, 2024 17:42
@DaveCTurner DaveCTurner marked this pull request as ready for review November 27, 2024 17:43
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label Nov 27, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@DaveCTurner
Copy link
Contributor Author

In case it helps with reviews: there's quite some noise in this PR but the main change here is to drop the essentially-identical .yml tests (30/40/50/60 and most of 20) and perform the same test actions in AbstractRepositoryS3RestTestCase instead. This way, we have the test actions written down in one place, with subclasses defining all the various different ways that the repository could get the appropriate credentials to run the tests. This still leaves the YAML tests in place to run the 10_basic and the first bit of 20_repository_permanent_credentials that wasn't duplicated, but these bits only ran with simple access-key/secret-key credentials so we don't need all the junk in build.gradle to configure the other credentials mechanisms. It also renders much of the gradle.build script as unused, and hence this PR removes all the unused bits. Or at least, this stuff was already kinda unused but that wasn't clear. It's unused now for sure. It also removes a bunch of places where we had multiple instances of the same string literal in order to make the tests work: with this change most (all?) relevant strings now vary run-to-run to avoid this confusion.

There's a couple of other changes here, namely to expose the bucket name in the MinIO fixture (which was previously hard-coded as bucket, although this was not obvious from the tangle of environment vars and sysprops that did so) and fixing a small bug in S3Service which would close the client needed to obtain credentials from STS the first time a S3BlobStore shut down, which would sometimes cause these new tests to fail depending on the order in which they ran.

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

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

LGTM, nice tidy up

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

The REST version is much cleaner. One question that I have is whether the client team (or other teams) depends on the existing yaml tests. I seem to remember they are used for intergration tests. Probably not an issue since we still have 10_basic and some of the 20. The rest is mostly duplicated for different type of credentials. A heads-up ping to the client team could still be helpful.


@Before
public void skipIfFips() {
assumeFalse("doesn't work in a FIPS JVM, but that's ok", inFipsJvm());
Copy link
Member

Choose a reason for hiding this comment

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

Is this still necessary? The existing yaml tests do not seem to need it. But we can also tackle this in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right now that you've fixed the fixtures to make long enough keys in #117675. Removed.

protected abstract String getClientName();

protected static String getIdentifierPrefix(String testSuiteName) {
return testSuiteName + "-" + Integer.toString(Murmur3HashFunction.hash(testSuiteName + System.getProperty("tests.seed")), 16) + "-";
Copy link
Member

Choose a reason for hiding this comment

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

This is in a method. I think we can just use the usual randomIdentifier and friends instead of performing hash manually?

Copy link
Contributor Author

@DaveCTurner DaveCTurner Nov 29, 2024

Choose a reason for hiding this comment

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

Unfortunately not, this is called when initializing some static fields in the test suite classes, which happens too early to use randomIdentifier().

public void onBlobStoreClose() {
releaseCachedClients();
}

public void close() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: missing @Override here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ thanks

Comment on lines -26 to -27
// The AWS STS SDK requires the role and session names to be set. We can verify that they are sent to S3S in the
// S3HttpFixtureWithSTS fixture
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment no longer relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was never correct - we don't ever actually send any requests to S3 in this test suite, we're just doing some basic initialization to make sure that ES doesn't encounter any problems with e.g. the security manager.

Comment on lines -13 to +15
bucket: @permanent_bucket@
bucket: bucket
client: integration_test_permanent
base_path: "@permanent_base_path@"
base_path: base_path_integration_tests
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure I understand this: These yaml tests do not run against 3rd party services so that passing these variables from the build.gradle file was never really useful for them. So we can just hard code them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

@DaveCTurner DaveCTurner added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Nov 29, 2024
Copy link
Contributor

@arteam arteam left a comment

Choose a reason for hiding this comment

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

LGTM3

@elasticsearchmachine elasticsearchmachine merged commit c3f9e01 into elastic:main Nov 29, 2024
16 checks passed
@DaveCTurner DaveCTurner deleted the 2024/11/25/repository-s3-java-rest-tests branch November 29, 2024 09:58
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 117628

@DaveCTurner
Copy link
Contributor Author

Backport pending on backport of #117749 first.

DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Nov 29, 2024
Today these YAML tests rely on a bunch of rather complex setup organised
by Gradle, and contain lots of duplication and coincident strings,
mostly because that was the only way to achieve what we wanted before we
could orchestrate test clusters and fixtures directly from Java test
suites. We're not actually running the YAML tests in ways that take
advantage of their YAMLness (e.g. in mixed-version clusters, or from
other client libraries).

This commit replaces these tests with Java REST tests which enormously
simplifies this area of code.

Relates ES-9984

Backport of elastic#117628 to 8.x
elasticsearchmachine pushed a commit that referenced this pull request Nov 29, 2024
Today these YAML tests rely on a bunch of rather complex setup organised
by Gradle, and contain lots of duplication and coincident strings,
mostly because that was the only way to achieve what we wanted before we
could orchestrate test clusters and fixtures directly from Java test
suites. We're not actually running the YAML tests in ways that take
advantage of their YAMLness (e.g. in mixed-version clusters, or from
other client libraries).

This commit replaces these tests with Java REST tests which enormously
simplifies this area of code.

Relates ES-9984

Backport of #117628 to 8.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Coordination Meta label for Distributed Coordination team >tech debt >test Issues or PRs that are addressing/adding tests v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants