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
[TEST] Enforce skip headers when needed #34735
Conversation
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
Pinging @elastic/es-core-infra |
There was a problem hiding this 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 [" |
There was a problem hiding this comment.
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 ?
+ "[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 [" |
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 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@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. |
retest this please |
We now have more accurate validation of setup, teardown and test sections as for missing skip feature sections
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
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
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
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
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 #34650