Commit graph

80 commits

Author SHA1 Message Date
Mark Vieira
0279c0a909
Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
Mikhail Berezovskiy
1163d2e4f9
Rename streamContent/Separator to bulkContent/Separator (#111716)
Rename `xContent.streamSeparator()` and
`RestHandler.supportsStreamContent()` to `xContent.bulkSeparator()` and
`RestHandler.supportsBulkContent()`.

I want to reserve use of "supportsStreamContent" for current work in
HTTP layer to [support incremental content
handling](https://github.com/elastic/elasticsearch/pull/111438) besides
fully aggregated byte buffers. `supportsStreamContent` would indicate
that handler can parse chunks of http content as they arrive.
2024-08-09 06:32:20 +10:00
Simon Cooper
41103562d5 Fix compile after several merges 2024-08-07 10:48:37 +01:00
Simon Cooper
ff045118e1
Skip on any instance of node or version features being present (#111268)
Update features skip behavior to skip on any node having the feature, not all nodes
2024-08-07 10:36:59 +01:00
Simon Cooper
5da4f31a4b
Skip on any node capability being present (#111585)
Update capabilities skip behavior to skip on any node having the capability, not all nodes
2024-08-07 10:36:23 +01:00
Moritz Mack
2a8a723d38
Remove support to skip by version in YAML REST tests. (#108351)
Please visit the YAML REST api spec documentation on how to skip tests
based on cluster features:
https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test#skipping-tests

For backwards compatibility, skip version is still permitted for v7 REST
compatibility tests.
2024-05-22 13:37:46 +02:00
Ryan Ernst
29d6023de8
Rename MockLogAppender to MockLog (#108803)
Now that mock logging has a single internal appender, the "appender"
suffix for MockLogAppender doesn't make sense. This commit renames the
class to MockLog. It was completely mechanical, done with IntelliJ
renames.
2024-05-20 06:22:49 -07:00
Ryan Ernst
449632c22e
Migrate remaining MockLogAppender.capturing to capture (#108781)
This commit removes the remaining tests constructing a MockLogAppender
directly and makes the constructor private.
2024-05-18 09:10:21 -07:00
Moritz Mack
befb6ff332
Add capabilities to known test runner features to fix capabilities integration in YAML tests (#108789)
🤦 Annoying oversight, this enables capabilities in YAML tests
2024-05-17 13:48:55 -04:00
Moritz Mack
fd2ba451bc
Require 'capabilities' test runner feature if using capabilities check (#108678) 2024-05-16 10:06:54 +02:00
Moritz Mack
d2d1357a33
Expose capability checks for YAML REST tests (#108425)
Co-authored-by: Simon Cooper <simon.cooper@elastic.co>
2024-05-10 12:37:54 +02:00
Ryan Ernst
e63e8dd902
Use MockLogAppender.capturing (#108114)
Many uses of MockLogAppender predate the addition of the helper method
to create a Releasable for restoring logging, which allows the use of
try-with-resource blocks. This commit converts current existing uses of
MockLogAppender to use capturing.

relates #106425
2024-05-02 06:32:54 -07:00
Moritz Mack
1c6119fa91
Introduce skipping on known_issues and awaits_fix for YAML tests (#107836)
See README on YAML REST tests for detailed instructions.
2024-04-30 08:29:34 +02:00
Alexander Spies
1e4d4da483
ESQL: Make esql version required in REST requests (#107433)
* Enable corresponding validation in EsqlQueryRequest.
* Add the ESQL version to requests to /_query in integration tests.
* In mixed cluster tests for versions prior to 8.13.3, impersonate an 8.13
   client and do not send any version.

---------

Co-authored-by: Nik Everett <nik9000@gmail.com>
2024-04-16 17:06:09 +02:00
Moritz Mack
e70e5397b7
Remove historical features for YAML REST tests in favor of synthetic version features (#107393) 2024-04-15 13:58:22 +02:00
Moritz Mack
1f5e04b721
Migrate YAML REST tests to synthetic cluster feature check (#107068)
To simplify the migration away from version based skip checks in YAML specs, 
this PR adds a synthetic version feature `gte_vX.Y.Z` for any version at or before 8.14.0.

New test specs for 8.14 or later are expected to use respective new cluster features,
or a test-only feature supplied via ESRestTestCase#createAdditionalFeatureSpecifications
if sufficient.
2024-04-11 18:22:38 +02:00
Joe Gallo
9496fa3746
Tidy up watcher logging and tests (#107175) 2024-04-08 07:24:52 -04:00
Rene Groeschke
b39b3731a7
Port krb5kdc to test container and rework hdfs handling (#106228)
This ports our krb5kdc test fixture to test container and reworks hdfs handling to also be based on test containers.
The yaml rest tests that are using hdfs required introducing variable substitution in yamlresttestparser handling.
2024-03-26 08:39:39 +01:00
Moritz Mack
12e64a1bdd
Use historical features for Yaml REST tests for cluster apis (#106587) 2024-03-22 09:11:30 +01:00
Moritz Mack
4374a385c5
Use historical features for Yaml REST tests for bulk api (#106402) 2024-03-21 09:39:22 +01:00
Moritz Mack
1c8bf79435
Use historical features for Yaml REST tests for cat apis where applicable (#106323) 2024-03-18 08:40:11 +01:00
Lorenzo Dematté
f05a66c3dd
Migrate cat YAML tests from version to cluster_features (#106167) 2024-03-11 18:14:17 +01:00
Lorenzo Dematté
1e76b18f76
YAML test framework: re-introduce requires section and cluster_features conditions (#105763) 2024-03-05 13:37:50 +01:00
Lorenzo Dematté
1c03489f46
YAML test framework: simplify version node_selector (#103954)
* Simplify version node_selector: remove ranges and allow just current/non_current
* Version match still present, but only for legacy rest compat tests
2024-03-05 10:20:22 +01:00
Armin Braun
fc8e2b7897
Introduce Predicate Utilities for always true/false use-cases (#105881)
Just a suggetion. I think this would save us a bit of memory here and
there. We have loads of places where the always true lambdas are used
with `Predicate.or/and`. Found this initially when looking into field
caps performance where we used to heavily compose these but many spots
in security and index name resolution gain from these predicates.
The better toString also helps in some cases at least when debugging.
2024-03-04 14:01:21 +01:00
Nik Everett
e390edbdf8
ESQL: Add timers to many status results (#105421)
This adds many "timers" to the profile and status results. These look
like:
```
  "profile" : {
    "drivers" : [
      {
        "took_nanos" : 57252128,
        "took_time" : "57.2ms",
        "cpu_nanos" : 56733751,
        "cpu_time" : "56.7ms",
        "operators" : [
...
            "operator" : "LuceneSourceOperator[maxPageSize=9362, remainingDocs=2147383647]",
...
              "processing_nanos" : 856914,
              "processing_time" : "856.9micros",
...
            "operator" : "ValuesSourceReaderOperator[fields = [a, b]]",
...
              "process_nanos" : 9671406,
              "process_time" : "9.6ms",
...
            "operator" : "EvalOperator[evaluator=AddLongsEvaluator[lhs=Attribute[channel=1], rhs=Attribute[channel=2]]]",
...
              "process_nanos" : 3344354,
              "process_time" : "3.3ms",
...
            "operator" : "HashAggregationOperator[blockHash=LongBlockHash{channel=1, entries=100, seenNull=false}, aggregators=[GroupingAggregator[aggregatorFunction=MaxLongGroupingAggregatorFunction[channels=[3]], mode=INITIAL], GroupingAggregator[aggregatorFunction=MinLongGroupingAggregatorFunction[channels=[3]], mode=INITIAL]]]",
...
              "hash_nanos" : 11845071,
              "hash_time" : "11.8ms",
              "aggregation_nanos" : 27910054,
              "aggregation_time" : "27.9ms",
...
```

This let's us compare the runtime of each operator in a query. You can
get the run times of a running ESQL task with the `_tasks` API or you
can use the `profile` API to run an ESQL query and get these times in
the result. The example above is from `profile`.

In the example above we can see we're spending 500 microseconds waiting
in the queue. Of the remaining 56ms a little under half of that is spent
running the aggregations - in this case a `MAX` and `MIN`. And 20% of
the time is hashing to build group keys. Similarly 20% is spent on field
loading.


Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
2024-02-27 06:53:00 -05:00
Simon Cooper
b752169ee9
Use hamcrest regex matcher rather than our own (#104457)
The difference is that our matcher uses .find() to search for a regex match anywhere in the string, whereas the hamcrest one uses .matches() to check the whole string against the regex. This leads to more specific regex checks.

I've left our own one for YAML tests, as that way we don't need to mangle the regex to add .* either side, which might be confusing in test failures.
2024-02-22 16:15:36 +00:00
Dmitry Cherniachenko
a50e58d99a
Use single-char variant of String.indexOf() where possible (#105205)
* Use single-char variant of String.indexOf() where possible

indexOf(char) is more efficient than searching for the same one-character String.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-02-12 14:14:32 -05:00
Dmitry Cherniachenko
e21a4874ab
Use String.replace() instead of replaceAll() for non-regexp replacements (#105127)
* Use String.replace() instead of replaceAll() for non-regexp replacements

When arguments do not make use of regexp features replace() is a more efficient option, especially the char-variant.
2024-02-12 13:11:15 -05:00
Lorenzo Dematté
242ef73112
Removed cluster_features, switched back to runner features under skip (#104468)
Temporarly disable new keyword until the Clients team can update their YAML runners
2024-01-29 10:46:10 +01:00
Lorenzo Dematté
be2f61a81c
Add checks for old cluster features in rolling upgrade tests (#104279)
Add the ability to test for the original/old cluster features during a rolling upgrade
* Moving ALL_FEATURES to ESRestTestCase (and make it private - only usage)
2024-01-17 14:37:16 +01:00
Lorenzo Dematté
2b175653d9
YAML test framework: separate skip and requires sections (#104140)
* Introduce Prerequisites criteria (Predicate + factory) for modular skip decisions
- Removed accessors to specific criteria from SkipSection (used only on tests), adjusted test assertions
- Moved Features check (YAML test runner features) to SkipSection build time

* Separated check for xpack/no_xpack
Check for xpack is cluster-configuration (modules installed) dependent, while Features are meant to be "static" test-runner capabilities. We separate them so checks on one (test-runner features) can be run before and separately from the other.

* Consolidate skip() methods
- Divide require and skip predicates
- Divide requires and skip parsing (distinct sections)
- Renaming SkipSection to PrerequisiteSection and related methods/fields (e.g. skip -> evaluate)

* Refactoring tests
- moving and adding VersionRange tests
- adding specific version and os skip tests
- modified parse/validate/build to make SkipSection more unit-testable

* Adding cluster feature-based skip criteria
* Updated javadoc + renaming + better skip reason message
2024-01-15 14:48:36 +01:00
Nik Everett
50ac28012d
ESQL: Run async tests more carefully (#104330)
The ESQL async tests run the ESQL yaml tests two extra time - once under
the async endpoint with the `wait_for_completion_timeout` set to a long
time and *again* with `wait_for_completion_timeout` set to a short time,
expecting to receive an `id` for the query.

That second way is tricky! Even with a `0ms` timeout sometimes the
request will complete. That's great, but the tests didn't realize that
was possible. And it's tricky to get the warnings and `catch` sections
working properly with that. This reworks how we run these commands,
breaking apart the way we run a single API and running it as two, taking
into account that the "start the query" request could also complete the
query.

Closes #104294
2024-01-12 12:48:29 -05:00
Nik Everett
c2426ce886
ESQL: Run yaml tests async (#104205)
This adds tests that run the our suite of yaml tests against the ESQL
async endpoint. That's quite nice because the yaml tests are where we
handle lots of fun error cases and this'll make sure async does sensible
things in those cases.
2024-01-10 15:58:12 -05:00
Lorenzo Dematté
47498a6d64
Refactoring YAML tests VersionRange (#103912)
* Move parsing to VersionRange
- use Predicate<Set<String>> (set of string versions)
- add special "ranges" (e.g. move "current" from node_selector)
2024-01-09 18:18:30 +01:00
Lorenzo Dematté
5a4f02670e
YAML test framework: SkipSection refactoring (#103404)
* Consolidate skip() methods by passing down Context to them
* Introduce SkipCriteria for modular skip decisions
* Refactoring tests
- moving and adding VersionRange tests
- adding specific version and os skip tests
- modified parse/validate/build to make SkipSection more unit-testable

* Moved Features check (YAML test runner features) to SkipSection build time
* Separated check for xpack/no_xpack

Check for xpack is cluster-configuration (modules installed) dependent, while Features are meant to be "static" test-runner capabilities. We separate them so checks on one (test-runner features) can be run before and separately from the other.
2024-01-04 14:13:26 +01:00
Lorenzo Dematté
cea88cbeec
Replace Version with String in YAML framework, pushing Version parsing where is actually needed (#103311)
* Pushing down node versions as strings

Deferring Version parsing to the actual places where a minimum node version/common cluster version is needed; eventually this will be completely lazy and/or replaced by other checks (e.g. features).
Combine versions, oses and features in multi-cluster YAML test contexts.
2024-01-03 09:29:40 +01:00
Lorenzo Dematté
d57b034668
Introduce new overloads for ClientYamlTestExecutionContext and deprecate old ones (#103626)
Smaller steps to introduce a signature change without breaking submodule update in serverless
2024-01-02 10:06:25 +01:00
Lorenzo Dematté
1900a99018
Refactor: move version, os, features from ClientYamlTestClient to ClientYamlTestExecutionContext (#103560)
Just moving stuff around, no change in behaviour. Moving these fields showed how we are not treating correctly in derived classes where multiple clusters are tested (ex: CCR), but this is for another time.

Co-authored-by: Moritz Mack <moritz@mackmail.net>
2023-12-20 10:05:19 +01:00
Lorenzo Dematté
040692497b
Refactoring: extract methods from ESRestTestCase#initClient (#103579)
Initialization of information about the cluster under test is factored out into 2 methods, which can be used with different admin clients (e.g. in case of multi-cluster, like CCS).
2023-12-20 09:09:58 +01:00
Armin Braun
49f1b5b787
Make sure to close XContentParser in more spots (#103504)
We're leaking quite a few of these parsers. That doesn't seem to be much
of a problem but results in some memory inefficiencies in Jackson here
and there. This PR bulk fixes a bunch of instances that I could easily
automatically fix. I'll open a follow-up for closing the parser on the
document parsing context which also suffers from this but is non-trivial
to fix.
2023-12-19 10:26:06 +01:00
Lorenzo Dematté
efeec01f3b
Passing down cluster features to YAML test framework (#102921)
- Cluster features passed down as a predicate via context
- Removing the not-needed (unused) master node version
2023-12-11 18:34:44 +01:00
Lorenzo Dematté
ddce1df4e9
Fix version check for product header check (#102929)
* Adjusting condition as 8.0.0 is affected too
2023-12-11 17:27:43 +01:00
Tim Grein
c6f7e2d868
Add new IsAfterAssertion for yaml rest tests (#103122)
Adds a new assertion "is_after", which can be used in the yaml based rest tests to check, whether one instant comes after the other.
2023-12-08 11:56:46 +01:00
David Turner
e8c3a72785
Extract constant for ?ignore pseudo-parameter (#102365)
Today `RestClient` interprets an `?ignore=` request parameter as an
indication that certain HTTP response codes should be considered
successful and not raise a `ResponseException`. This commit replaces the
magic literal `"ignore"` with a constant and adds a utility to specify
the ignored codes as `RestStatus` values.
2023-11-20 03:37:02 -05:00
Keith Massey
0178857839
No longer creating the global template as a v2 template ever (#101886) 2023-11-09 13:17:03 -06:00
Lorenzo Dematté
482cf3b676
Reapply "Making yaml tests version selector parser compatible with versions returned by Build" (#100953)
* Compatible version parsing in YAML tests
* Propagate exception in case of non-semantic version where one is expected
* Removed remove of SNAPSHOT (no longer needed)
2023-10-24 11:24:32 +02:00
Przemyslaw Gomulka
1266718e1c
Add NotExistAssertion to yml test framework (#101111)
currently to assert that a field does not exist, tests are using is_false. This has a drawback because is less readable and also would succeed when value is present and has a default value (0, false, etc)

This commit addes a NotExistAssertion to make sure that a field does not exist in a response
2023-10-19 14:46:57 +02:00
Lorenzo Dematté
a60a7890d0
Revert "Making yaml tests version selector parser compatible with versions returned by Build (#100794)" (#100889)
This reverts commit 5fe7e03248.
2023-10-16 13:28:47 +02:00
Lorenzo Dematté
5fe7e03248
Making yaml tests version selector parser compatible with versions returned by Build (#100794) 2023-10-16 09:34:16 +02:00