Skip to content

Add ability to skip tests #221

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

Merged
merged 26 commits into from
Feb 1, 2021
Merged

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Jan 15, 2021

This PR adds the ability for package developers to skip tests.

TODO

  • Implement skipping for asset loading test runner. Depends on Asset loading test runner #168.
  • Extract common skip struct from various test runners.
  • Add some skipped tests in test packages.

Related: #218.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 15, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #221 updated

    • Start Time: 2021-01-29T19:46:49.073+0000
  • Duration: 15 min 16 sec

  • Commit: b195c06

Test stats 🧪

Test Results
Failed 0
Passed 290
Skipped 1
Total 291

@ycombinator
Copy link
Contributor Author

ycombinator commented Jan 27, 2021

I need to figure out why CI is not showing the apache/error system test as skipped.

The human formatter appears to be working as expected:

$ elastic-package test system --data-streams error
Run system tests for the package
2021/01/26 16:16:00  WARN skipping system test for apache/error: testing skip (details: )
--- Test results for package: apache - START ---
╭─────────┬─────────────┬───────────┬───────────┬─────────┬──────────────╮
│ PACKAGE │ DATA STREAM │ TEST TYPE │ TEST NAME │ RESULT  │ TIME ELAPSED │
├─────────┼─────────────┼───────────┼───────────┼─────────┼──────────────┤
│ apache  │ error       │ system    │ default   │ SKIPPED │        579ns │
╰─────────┴─────────────┴───────────┴───────────┴─────────┴──────────────╯
--- Test results for package: apache - END   ---
Done

The xUnit formatter also appears to be correct, but I will probably need to play around with the attributes/elements and their values to get skipped tests working properly in CI.

$ elastic-package test system --data-streams error --report-format xUnit
Run system tests for the package
2021/01/26 16:16:35  WARN skipping system test for apache/error: testing skip (details: )
--- Test results for package: apache - START ---
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="system" tests="1" skipped="1">
    <!--test suite for system tests-->
    <testcase name="system test: default" result="Skip" classname="apache.error" time="2.77e-07"></testcase>
  </testsuite>
</testsuites>
--- Test results for package: apache - END   ---
Done

@ycombinator ycombinator marked this pull request as ready for review January 27, 2021 22:24
@ycombinator ycombinator requested a review from mtojek January 27, 2021 22:24
@mtojek
Copy link
Contributor

mtojek commented Jan 28, 2021

The xUnit formatter also appears to be correct, but I will probably need to play around with the attributes/elements and their values to get skipped tests working properly in CI.

If you prefer to play with it in follow up (bugfix), I'm good with it!

Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Minors only and a general comment about the Skip section, but nothing blocking I believe.

@@ -107,6 +107,16 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
}
tr.Name = tc.name

if tc.config.Skip != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I have a general concern, but I'm sure if it can be solved. I'm worried that one day we'll add a new test runner, in which we'll forget to add the "Skip" config section. Maybe we should limit this to minimum. Do we need a skip check for assets tests (same for install)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. Maybe this goes well with your other suggestion of a commonTestConfig. Let me try something and update this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In 4e25215, I introduced a SkippableConfig struct that could be embedded in any test config structs that allow skipping. This doesn't necessarily address the concern you are bringing up (a future test runner forgetting to include the skip config section) but I think it can help make it a bit easier to add a skip config section to a future test runner. I think to truly address your concern a larger refactor might be needed which would allow a higher-level generic test runner of some sort to handle skipping before delegating the actual running of a test to specific types of test runners.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think to truly address your concern a larger refactor might be needed which would allow a higher-level generic test runner of some sort to handle skipping before delegating the actual running of a test to specific types of test runners.

... and we may think about such refactoring exercise soon, as we have a better clarity of what do we expect from test runners and what kind of tests we need. Definitely we can postpone it at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Added #238 to track the refactoring.

@ycombinator
Copy link
Contributor Author

@mtojek This PR is now failing CI with an unrelated error: https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Felastic-package/detail/PR-221/20/pipeline#step-122-log-693.

The same / similar error is occurring on master as well: https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Felastic-package/detail/master/22/pipeline/#step-108-log-544

I would suggest that you review this PR for the latest changes but let's not merge it even when it passes review. I think we need to take care of the error on master separately first, then we can rebase this PR on master and see if it passes CI as well.

@ycombinator
Copy link
Contributor Author

I believe the CI error I mentioned in my previous comment will be resolved once we have a new Kibana 7.11 Docker image. Related: elastic/kibana#89644.

@ycombinator ycombinator requested a review from mtojek January 29, 2021 02:40
@ycombinator
Copy link
Contributor Author

jenkins, run the tests please

@@ -107,6 +107,16 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
}
tr.Name = tc.name

if tc.config.Skip != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think to truly address your concern a larger refactor might be needed which would allow a higher-level generic test runner of some sort to handle skipping before delegating the actual running of a test to specific types of test runners.

... and we may think about such refactoring exercise soon, as we have a better clarity of what do we expect from test runners and what kind of tests we need. Definitely we can postpone it at the moment.

@@ -1,3 +1,6 @@
skip:
reason: testing skip
link: https://github.com/elastic/integrations/issues/123456789
vars: ~
data_stream:
vars:
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that this test will fail if it runs, that's why it's skipped = PASS

Copy link
Contributor Author

@ycombinator ycombinator Jan 29, 2021

Choose a reason for hiding this comment

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

This used to be a test that used to pass before I added the skip. I think you are suggesting that I should make it fail, so we have a way to know something is not working correctly if the skip logic in the test runner breaks? I like that idea, and can implement it — just want to make sure that's what you are suggesting here first. 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's point :) I think the quick way is to introduce some faulty variables? Don't have to implement anything special. But I wouldn't say it's blocking comment. For me this PR is ready to be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for confirming, I will make this change now. Should be fairly quick to test.

Copy link
Contributor Author

@ycombinator ycombinator Jan 29, 2021

Choose a reason for hiding this comment

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

I'm going to do a series of 3 commits to test this change:

  1. A commit that comments out the skip section, effectively re-enabling the apache.error system test. With this commit the test should pass: 322c835.
  2. A commit that breaks the test. With this commit the test should fail: cec86cf.
  3. A commit that adds back the skip section. With this commit the test should be skipped: 0fbf9ad.

@ycombinator ycombinator requested a review from mtojek January 29, 2021 19:29
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM!

@ycombinator ycombinator merged commit 86360ba into elastic:master Feb 1, 2021
@ycombinator ycombinator deleted the test-skip branch February 1, 2021 15:01
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.

3 participants