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

[TEST] Enforce skip headers when needed #34735

Merged
merged 37 commits into from Oct 31, 2018

Conversation

javanna
Copy link
Member

@javanna javanna commented Oct 23, 2018

The java yaml test runner supports sending request headers, yet not all clients support headers. This commit makes sure that we enforce adding a skip section with feature "headers" whenever headers are used in a do section as part of a test. That decreases the chance for new tests to break client builds due to the missing skip section.

Closes #34650

The java yaml test runner supports sending request headers, yet not all clients support headers. This commit makes sure that we enforce adding a skip section with feature "headers" whenever headers are used in a do section as part of a test. That decreases the chance for new tests to break client builds due to the missing skip section.

Closes elastic#34650
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@alpar-t alpar-t left a comment

Choose a reason for hiding this comment

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

LGTM just a suggestion.

if (false == doSection.getApiCallSection().getHeaders().isEmpty()
&& false == skipSection.getFeatures().contains("headers")) {
throw new IllegalArgumentException("Attempted to add a [do] with a [headers] section without a corresponding "
+ "[skip] so runners that do not support the [headers] section can skip the test at line ["
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth mentioning the feature has the same name to save people some digging ?

Suggested change
+ "[skip] so runners that do not support the [headers] section can skip the test at line ["
+ "[skip: {"feature": "headers"}] so runners that do not support the [headers] section can skip the test at line ["

@javanna
Copy link
Member Author

javanna commented Oct 23, 2018

retest this please

}
if (false == doSection.getApiCallSection().getHeaders().isEmpty()
&& false == skipSection.getFeatures().contains("headers")) {
throw new IllegalArgumentException("Attempted to add a [do] with a [headers] section without a corresponding "
Copy link
Member

Choose a reason for hiding this comment

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

👍

@javanna
Copy link
Member Author

javanna commented Oct 25, 2018

@alpar or @nik9000 can you maybe have another look? I had to move the validation code higher-up, as this change made another bug surface: we don't look at the skip section from setup or teardown in our validation, and we have quite some skip headers in our setup sections, so false positives without adapting the validation code. Let me know what you think.

@colings86 colings86 added v6.6.0 and removed v6.5.0 labels Oct 25, 2018
@javanna
Copy link
Member Author

javanna commented Oct 25, 2018

retest this please

javanna added a commit to javanna/elasticsearch that referenced this pull request Oct 29, 2018
Validation of test section and suites consists of checking that the proper skip features sections are in place depending on the features used in tests.

The validation logic was previously only performed on do sections included in each test section, and the skip needed to be present in the same test section. What happens often though is that the skip is added to the setup section, or the teardown section.

This commit improves the validation of test suites by validating setup and teardown section first, then looking at each test section while still eventually reading the skip section from setup or teardown.

We are also making SkipSection, SetupSection, TearDownSection, ClientYamlTestSection and ClientYamlTestSuite immutable. Previously it was possible to utilize constants like SetupSection.EMPTY, which were modifiable and affect every other future users by modifiying them. This has been corrected.

Also, validation has been improved to cumulate errors so that all the errors from a suite will be listed at once.

Relates to elastic#34735
javanna added a commit to javanna/elasticsearch that referenced this pull request Oct 29, 2018
Validation of test section and suites consists of checking that the proper skip features sections are in place depending on the features used in tests.

The validation logic was previously only performed on do sections included in each test section, and the skip needed to be present in the same test section. What happens often though is that the skip is added to the setup section, or the teardown section.

This commit improves the validation of test suites by validating setup and teardown section first, then looking at each test section while still eventually reading the skip section from setup or teardown.

We are also making SkipSection, SetupSection, TearDownSection, ClientYamlTestSection and ClientYamlTestSuite immutable. Previously it was possible to utilize constants like SetupSection.EMPTY, which were modifiable and affect every other future users by modifiying them. This has been corrected.

Also, validation has been improved to cumulate errors so that all the errors from a suite will be listed at once.

Relates to elastic#34735
javanna added a commit that referenced this pull request Oct 30, 2018
Validation of test sections and suites consists of checking that the proper skip features sections are in place depending on the features used in tests.

The validation logic was previously only performed on do sections included in each test section, and the skip needed to be present in the same test section. What happens often though is that the skip is added to the setup section, or the teardown section.

This commit improves the validation of test suites by validating setup and teardown section first, then looking at each test section while still eventually reading the skip section from setup or teardown.

We are also making SkipSection, SetupSection, TearDownSection, ClientYamlTestSection and ClientYamlTestSuite immutable. Previously it was possible to utilize constants like SetupSection.EMPTY, which were modifiable and affect every other future users by modifiying them. This has been corrected.

Also, validation has been improved to cumulate errors so that all the errors from a suite will be listed at once.

Relates to #34735
@javanna javanna merged commit 674225a into elastic:master Oct 31, 2018
javanna added a commit that referenced this pull request Nov 2, 2018
Validation of test sections and suites consists of checking that the proper skip features sections are in place depending on the features used in tests.

The validation logic was previously only performed on do sections included in each test section, and the skip needed to be present in the same test section. What happens often though is that the skip is added to the setup section, or the teardown section.

This commit improves the validation of test suites by validating setup and teardown section first, then looking at each test section while still eventually reading the skip section from setup or teardown.

We are also making SkipSection, SetupSection, TearDownSection, ClientYamlTestSection and ClientYamlTestSuite immutable. Previously it was possible to utilize constants like SetupSection.EMPTY, which were modifiable and affect every other future users by modifiying them. This has been corrected.

Also, validation has been improved to cumulate errors so that all the errors from a suite will be listed at once.

Relates to #34735
javanna added a commit that referenced this pull request Nov 2, 2018
The java yaml test runner supports sending request headers, yet not all clients support headers. This commit makes sure that we enforce adding a skip section with feature "headers" whenever headers are used in a do section as part of a test. That decreases the chance for new tests to break client builds due to the missing skip section.

Closes #34650
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Build Build or test infrastructure >enhancement Team:Delivery Meta label for Delivery team v6.6.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve rest-api-spec test runner to fail tests that use headers but don't list them in the skip section
6 participants