-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Refactor/analysis tests #3424
Conversation
…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)
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.
LGTM - much easier to compose tests for different versions 👍
|
||
protected AnalysisComponentTestBase() | ||
{ | ||
this.Client = (ElasticXunitRunner.CurrentCluster as ReadOnlyCluster)?.Client ?? TestClient.DefaultInMemoryClient; |
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.
Would ElasticXunitRunner.CurrentCluster
be a WritableCluster
at this point, to match the one requested by IntegrationTestClusterAttribute
?
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)
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 aAnalysisCrudTest
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 anAttribute
. Prior an integration test needed to implementIClusterFixture<TCluster>
and acceptTCluster
in its constructor. Which causes all subclasses needing to implement this constructor which gets super noisy.Tests can then refer to the
"active"
cluster usingElasticXunitRunner.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 ofApiIntegrationTestsBase
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.