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

Adding integration test for elasticsearch Metricbeat module, xpack code path #15975

Merged
merged 8 commits into from
Feb 1, 2020

Conversation

ycombinator
Copy link
Contributor

What does this PR do?

This PR:

  • adds an integration test for the Metricbeat elasticsearch module when xpack.enabled: true is set in the module configuration, and
  • does some minor cleanup and refactoring in the Metricbeat elasticsearch integration test code.

Why is it important?

The code path in the elasticsearch module when xpack.enabled was set to true was previously not being exercised by integration tests. Moreover, it's a critical code path as it powers the Stack Monitoring feature.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

Related issues

@ycombinator ycombinator requested a review from a team as a code owner January 30, 2020 22:28
@ycombinator ycombinator requested review from bpintea and a team and removed request for bpintea January 31, 2020 06:13
// as there are distinct shards in Elasticsearch
if metricSet.Name() == "shard" {
numShards, err := countShards(host)
if !assert.NoError(t, err) {
Copy link
Contributor

@mtojek mtojek Jan 31, 2020

Choose a reason for hiding this comment

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

require.NoError()

I believe you can use require. in multiple places in the test. require fails and stops the test if only the condition is not satisfied.

Copy link
Contributor Author

@ycombinator ycombinator Jan 31, 2020

Choose a reason for hiding this comment

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

That's awesome, TIL!

I'll update the usages of assert.* to require.* in this PR here and make a follow up PR to fix them in other tests.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow up PR: #15993.

host := service.Host()

version, err := getElasticsearchVersion(host)
if err != nil {
Copy link
Contributor

@mtojek mtojek Jan 31, 2020

Choose a reason for hiding this comment

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

I think you can also apply require here.

@ycombinator
Copy link
Contributor Author

jenkins, test this

@ycombinator ycombinator merged commit 9bca151 into elastic:master Feb 1, 2020
@ycombinator ycombinator added Metricbeat Metricbeat module needs_backport PR is waiting to be backported to other branches. Feature:Stack Monitoring Team:Integrations Label for the Integrations team v7.7.0 v8.0.0 labels Feb 1, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring (Stack monitoring)

@ycombinator ycombinator added [zube]: In Review [zube]: Done and removed [zube]: In Review needs_backport PR is waiting to be backported to other branches. labels Feb 1, 2020
@ycombinator ycombinator deleted the mb-es-xp-int-test branch February 1, 2020 04:23
ycombinator added a commit that referenced this pull request Feb 11, 2020
…de path (#15975) (#16008)

* Define x-pack metricsets for testing purposes

* Extract test setup into function

* Move test skipping to correct level

* Add integration test for xpack.enabled:true data path

* Remove debugging statement

* Replace usages of assert.* with require.*

* One more use of require.*

* Fixing method call args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants