-
Notifications
You must be signed in to change notification settings - Fork 25k
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 for regex in REST test warnings and allowed_warnings #69501
Conversation
@elasticmachine update branch |
Pinging @elastic/es-delivery (Team:Delivery) |
cc @elastic/es-clients -> this PR introduces two new features for the rest tests and ideally would be support across all of the clients tests. |
@@ -51,7 +52,7 @@ public void testWarningHeaders() { | |||
} | |||
|
|||
final String testHeader = HeaderWarning.formatWarning("test"); | |||
final String anotherHeader = HeaderWarning.formatWarning("another"); | |||
final String anotherHeader = HeaderWarning.formatWarning("another \"with quotes and \\ backslashes\""); |
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.
no actual changes here...just realized we didn't have any coverage for escaped character matching.
Thanks for the ping! Btw @jakelandis we're moving away from |
Also note there will be a followup PR to allow injecting these for transformation, near identical to #69010 |
@elasticmachine run elasticsearch-ci/1 |
In other places in the framework we use |
I considered it, but it would be sneaky feature that could break the clients testing. For example, without support from the clients test could add a |
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; | ||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; | ||
|
||
public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { |
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.
We have a number of tests in the :test:framework
project itself to exercising the test framework. Is there a reason we can't put this stuff there? It seems like a much more appropriate place than introducing a new project to test a very specific piece of functionality that lives somewhere else. It would seem to me we could write an internal cluster test for this, which would remove the need to for an explicit plugin project just to declare a mock endpoint.
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.
Looking more at what currently exists in terms of test coverage, I think just adding unit tests to the exist suite for this is sufficient. I think end-to-end testing with an external cluster is overkill here given we have no such equivalent testing for any of the other yaml rest testing functionality.
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.
I think end-to-end testing with an external cluster is overkill
Fair point especially since there little development in this area. Will remove the additional qa project. The unit tests are already included and provide pretty comprehensive coverage.
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.
done on 71f7b99
(#69501)
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.
I left a small thing. Makes sense to me.
@@ -152,6 +152,15 @@ public void validate() { | |||
"without a corresponding [\"skip\": \"features\": \"warnings\"] so runners that do not support the [warnings] " + | |||
"section can skip the test at line [" + section.getLocation().lineNumber + "]"); | |||
|
|||
errors = Stream.concat(errors, sections.stream().filter(section -> section instanceof DoSection) |
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.
I wonder if all this would become more readable if it were a for loop. Its certainly faster to copy and paste the blocks but maybe its time to redo?
* allowed_warnings: | ||
* - The non _regex version exact matches against the warning text and no need to worry about escaped quotes or backslashes | ||
* - The _regex version matches against the raw value of the warning text which may include backlashes and quotes escaped | ||
* allowed_warnings|allowed_warnings_regex: |
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.
I might break out the regex ones just to show what a regex will look like. I agree on preferring the non-regex one. Its nice not to have to think about what punctuation means.
…stic#69501) This commit adds support for two new REST test features. warnings_regex and allowed_warnings_regex. This is a near mirror of the warnings and allowed_warnings warnings feature where the test can be instructed to allow or require HTTP warnings. The difference with these new features is that is allows the match to be based on a regular expression. # Conflicts: # test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java # test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java
#69501) (#69754) This commit adds support for two new REST test features. warnings_regex and allowed_warnings_regex. This is a near mirror of the warnings and allowed_warnings warnings feature where the test can be instructed to allow or require HTTP warnings. The difference with these new features is that is allows the match to be based on a regular expression.
This commit adds support for two new REST test features.
warnings_regex
andallowed_warnings_regex
.This is a near mirror of the
warnings
andallowed_warnings
warnings feature where the test can be instructed to allow
or require HTTP warnings. The difference with these new features
is that is allows the match to be based on a regular expression.
Also included in this PR is a newqa
projectrest-test-test
which can be used to exercise and validate the features of the
rest-test themselves. A rest test for the rest tests.