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

Refactor/analysis tests #3424

Merged
merged 7 commits into from
Oct 17, 2018
Merged

Refactor/analysis tests #3424

merged 7 commits into from
Oct 17, 2018

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Sep 28, 2018

Currently we take a all or nothing approach with our analysis tests, we unit test analyzers/filter/char_filter/normalizers/tokenizers and then lift these in a AnalysisCrudTest to test that elasticsearch accepts them. Problem is when new analysis components get introduced in a minor we need to add to the list and do a [SkipVersion()] on everything. Which causes us to test these in practice only against the latest version.

This PR pulls all of these apart so that if a new analysis component gets introduced we can make it with SkipVersion in isolation.

To minimize the boilerplate this PR also updates Elastic.Xunit which now allows testclasses to declare a cluster to run against using an Attribute. Prior an integration test needed to implement IClusterFixture<TCluster> and accept TCluster in its constructor. Which causes all subclasses needing to implement this constructor which gets super noisy.

[IntegrationTestCluster(typeof(WritableCluster))]
public abstract class AnalysisComponentTestBase<TAssertion, TComponent, TContainer, TDescriptor>

Tests can then refer to the "active" cluster using ElasticXunitRunner.CurrentCluster.

There are other places where this approach will work well as well, Ingest Processors comes to mind.

This PR also pulls EndpointUsage, CallUniqueValues out of ApiIntegrationTestsBase allowing other test classes easier access to testing an client API call with the same call once guarantees.

This PR does not move ApiIntegrationTestsBase itself over.

…ses to do full blown endpoint testing

(cherry picked from commit d6f1ae5)
(cherry picked from commit f5f0c437871589b1fb90b6c4c6f09f0dfc296d7e)
(cherry picked from commit c74ed51e2c30804ffc1d50f95a17893a93bfa6ea)
(cherry picked from commit f2da9f51b43b188cc1b2d09f616fbf87ca268344)
(cherry picked from commit 7ecbee5435df02810ede7f07985e7bb13f66b6f3)
…ch implements the bulk of the setup and tests

(cherry picked from commit 8a6e99493a4174a87cc8680609afd0c482cf10d7)
Copy link
Contributor

@russcam russcam left a comment

Choose a reason for hiding this comment

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

LGTM - much easier to compose tests for different versions 👍


protected AnalysisComponentTestBase()
{
this.Client = (ElasticXunitRunner.CurrentCluster as ReadOnlyCluster)?.Client ?? TestClient.DefaultInMemoryClient;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would ElasticXunitRunner.CurrentCluster be a WritableCluster at this point, to match the one requested by IntegrationTestClusterAttribute?

@russcam russcam merged commit 6461c8f into 6.4 Oct 17, 2018
@russcam russcam deleted the refactor/analysis-tests branch October 18, 2018 09:45
russcam pushed a commit that referenced this pull request Oct 26, 2018
This commit refactors the way we do analysis tests by making it easier for test classes to do full blown endpoint testing

(cherry picked from commit d6f1ae5)

* continuing to port analysis over to more isolated chunks

(cherry picked from commit f5f0c437871589b1fb90b6c4c6f09f0dfc296d7e)

* Ported normalizers over to new test format

(cherry picked from commit c74ed51e2c30804ffc1d50f95a17893a93bfa6ea)

* clean up namespaces

(cherry picked from commit f2da9f51b43b188cc1b2d09f616fbf87ca268344)

* All analysis unit/integ tests pass again

(cherry picked from commit 7ecbee5435df02810ede7f07985e7bb13f66b6f3)

* abstracted analysis base classes even further to all share a base which implements the bulk of the setup and tests

(cherry picked from commit 8a6e99493a4174a87cc8680609afd0c482cf10d7)
(cherry picked from commit 6461c8f)
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.

None yet

2 participants