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

Add support of TEST_TAGS in python tests #17075

Merged
merged 4 commits into from
Mar 19, 2020

Conversation

jsoriano
Copy link
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
Collaborator

Pinging @elastic/integrations (Team:Integrations)

Copy link
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

@@ -139,3 +140,26 @@ def parameterized_with_supported_versions(base_class):
variants = supported_versions(versions_path)
decorator = parameterized_class(['COMPOSE_ENV'], variants)
decorator(base_class)


def tag(tag):
Copy link
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
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
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
Member Author

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

Copy link
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