Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support of TEST_TAGS in python tests#17075

Merged
jsoriano merged 4 commits into
elastic:masterfrom
jsoriano:test-tags-python
Mar 19, 2020
Merged

Add support of TEST_TAGS in python tests#17075
jsoriano merged 4 commits into
elastic:masterfrom
jsoriano:test-tags-python

Conversation

@jsoriano
Copy link
Copy Markdown
Member

@jsoriano jsoriano commented Mar 18, 2020

What does this PR do?

Add a tag(tag) decorator that skips a test if the tag is not included
in the comma-separated list of TEST_TAGS environment variable.
This offers an initial support for the similar implementation added for
mage in #16937.

Why is it important?

#16937 was intended for cloud tests, where we only have go-based
integration tests. But we have found similar needings in some services
like oracle, where we need an image that we cannot distribute. In that
case we need a similar approach to run the test only in our Jenkins
instances, where the image is available.

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

How to test this PR locally

  • Tag a python test with @metricbeat.tag('sometag').
  • Check that the test is skipped if TEST_TAGS is not used.
  • Check that the test is executed if TEST_TAGS environment variable includes sometag (e.g: TEST_TAGS=sometag or TEST_TAGS=sometag,foo.

Related issues

Use cases

  • Run certain tests that require some application or credentials to be available only where they are.

Add a `tag(tag)` decorator that skips a test if the tag is not included
in the comma-separated list of `TEST_TAGS` environment variable.
This offers an initial support for the similar implementation added for
mage in elastic#16937.
@jsoriano jsoriano self-assigned this Mar 18, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/integrations (Team:Integrations)

Copy link
Copy Markdown
Contributor

@sayden sayden left a comment

Choose a reason for hiding this comment

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

Looks good

Comment thread metricbeat/tests/system/metricbeat.py Outdated
decorator(base_class)


def tag(tag):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is then used with @metricbeat.tag?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, you need to import metricbeat for that, but I think we do it in all metricbeat tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, you need to pass a tag as parameter, e.g:

@metricbeat.tag('oracle')
def test_something(self):
    ...

@jsoriano jsoriano requested a review from sayden March 18, 2020 19:17
@jsoriano
Copy link
Copy Markdown
Member Author

@sayden could you take another look after moving the code to libbeat? Thanks!

Copy link
Copy Markdown
Contributor

@sayden sayden left a comment

Choose a reason for hiding this comment

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

LGTM

@jsoriano jsoriano merged commit 3bf05f5 into elastic:master Mar 19, 2020
@jsoriano jsoriano deleted the test-tags-python branch March 19, 2020 17:27
jsoriano added a commit to jsoriano/beats that referenced this pull request Mar 19, 2020
Add a `tag(tag)` decorator that skips a test if the tag is not included
in the comma-separated list of `TEST_TAGS` environment variable.
This offers an initial support for the similar implementation added for
mage in elastic#16937.

(cherry picked from commit 3bf05f5)
jsoriano added a commit that referenced this pull request Mar 19, 2020
Add a `tag(tag)` decorator that skips a test if the tag is not included
in the comma-separated list of `TEST_TAGS` environment variable.
This offers an initial support for the similar implementation added for
mage in #16937.

(cherry picked from commit 3bf05f5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants