Skip to content

Add S3 integration tests for searchable snapshots #52263

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

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Feb 12, 2020

This pull request adds REST-based integration tests that test the searchable snapshots feature on S3.

More precisely, this pull request:

  • adds a new AbstractSearchableSnapshotsRestTestCase class that provides a generic test case for searchable snapshots
  • adds a new FsSearchableSnapshotsIT that tests the previous test case using a filesystem repository. This test is added in the already existing qa:rest project
  • adds a new S3SearchableSnapshotsIT that tests the previous test case using a S3 repository. This test is added in a new qa:s3 project that takes care of setting up an S3 fixture for the test. This test can also be run against an external service if the appropriate environment variables are provided

@tlrx tlrx added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs labels Feb 12, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore)

@tlrx
Copy link
Member Author

tlrx commented Feb 12, 2020

@mark-vieira If you have time that would be great if you could have a look at Gradle and Docker files, just in case I missed something. Thanks!

preProcessFixture {
dependsOn fixture.jar
doLast {
file("${testFixturesDir}/shared").mkdirs()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me why all this is required. We seem to be effectively defining a new test fixture here. Why isn't we can't just use the existing s3-fixture like we do for other tests?

testFixtures.useFixture(':test:fixtures:s3-fixture')

Copy link
Member Author

@tlrx tlrx Feb 12, 2020

Choose a reason for hiding this comment

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

This QA test depends on repository-s3 project which already uses many S3 fixtures and the test fixtures plugin prevented me from reusing the existing one. Since I wanted to avoid any mention to searchables snapshots in open source code I added the current configuration. Do you think there's a better way to do that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would define a separate service in the s3-fixture compose file to be used here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would define a separate service in the s3-fixture compose file to be used here.

Sorry if I wasn't clear, I tried this solution and got a failure. Before doing what is coded in this PR I tried to define a separate service in the /test/fixtures/s3-fixture/docker-compose.yml file:

...
  s3-fixture-generic:
    build:
      context: .
      args:
        fixtureClass: fixture.s3.S3HttpFixture
        port: 80
        bucket: "bucket"
        basePath: "base_path"
        accessKey: "access_key"
      dockerfile: ./testfixtures_shared/shared/Dockerfile
    volumes:
      - ./testfixtures_shared/shared:/fixture/shared
    ports:
      - "80"

and tried to declare the usage of this fixture in the qa:s3 build file like this:

if (useFixture) {
  testFixtures.useFixture(':test:fixtures:s3-fixture', 's3-fixture-generic')
}

But it failed with the following error:

Build file '/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle' line: 36

* What went wrong:
A problem occurred evaluating project ':x-pack:plugin:searchable-snapshots:qa:s3'.
> Projects :plugins:repository-s3 and :x-pack:plugin:searchable-snapshots:qa:s3 both claim all services from :test:fixtures:s3-fixture. This is not supported because it breaks running in parallel. Configure specific services in docker-compose.yml for each and add the service name to `useFixture`

In order to allow parallel test execution and to try to reuse as much as possible the existing code, I went with declaring a docker-compose.yml file in this qa:s3project that reuses the existing DockerFile and code from the test fixture.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood. The problem here is that :plugins:repository-s3 declares testFixtures.useFixture(':test:fixtures:s3-fixture') which means "give me all services of the s3-fixture project. If we add a new service which that project doesn't need, we now need to be explicit say exactly which services it does need. So you'll need to modify that build script and call useFixture(':test:fixtures:s3-fixture', 's3-fixture') and so on for each service required in the compose yaml.

I apologize for the back and forth, I just want to avoid us reimplementing a bunch of logic that our test fixtures plugin does for us if possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem here is that :plugins:repository-s3 declares testFixtures.useFixture(':test:fixtures:s3-fixture')

Thanks for spotting this @mark-vieira, I should have seen it by myself. I pushed 331408a to correct the fixtures.

I apologize for the back and forth, I just want to avoid us reimplementing a bunch of logic that our test fixtures plugin does for us if possible.

Nothing to apologize, I pinged you because I was suspecting something wrong and you spotted it 👍. I'm happy to not add another docker-compose.yml file to the mix :)

@tlrx tlrx requested a review from mark-vieira February 14, 2020 10:03
Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

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

Changes LGTM 👍

@@ -15,6 +15,21 @@ services:
ports:
- "80"

s3-fixture-other:
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps s3-fixture-searchable-snapshots?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to not mention searchable snapshots in open source code, so I'll keep "other" if that's ok for you.

@tlrx
Copy link
Member Author

tlrx commented Feb 18, 2020

@DaveCTurner Can you have a look at the test itself, please? Thanks

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

The tests themselves LGTM, and I've done some basic experiments to verify that they do indeed run as part of ./gradlew :x-pack:plugin:searchable-snapshots:check. Thanks @tlrx.

@tlrx tlrx merged commit 5b115fb into elastic:feature/searchable-snapshots Feb 18, 2020
@tlrx tlrx deleted the add-searchable-snapshots-integ-tests-for-s3 branch February 18, 2020 16:32
@tlrx
Copy link
Member Author

tlrx commented Feb 18, 2020

Thanks David and Mark!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >test Issues or PRs that are addressing/adding tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants