-
Notifications
You must be signed in to change notification settings - Fork 79
Add yaml test runner project #98
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
Conversation
WIP This commit is the start of the yaml test runner binary. - Download yaml tests from GitHub to local filesystem - Read yaml tests
This commit changes the api_generator package to expose it as a library to yaml_test_runner, whilst also still compiling it as a runnable binary. This allows the generator modules to be used in the yaml_test_runner where they will be needed to generate tests, by inspecting the ASTs produced by the generator. Move last_downloaded_version marker file into rest_specs directory so that the yaml_test_runner can use/reuse downloaded rest specs when running locally, by easily inspecting the downloaded version. Renamed api_generator module in api_generator to simply generator.
This commit simplifies some functions by changing return types to Result<(), failure::Error>
This commit starts generating tests from the steps read from yaml so far.
run cargo fmt indent accumulated errors
Generated file
Just noticed I am finally getting the time to migrate my project over to this crate and so I will have more time to dig into things; I figure PRs like that will help me get re-familiarized with the code... |
Had a look at
Awesome! 😃 |
Ok! I will open a PR for |
@mwilliammyers I've brought in About to merge this in and release a new client package |
This commit adds a new package to the repository, yaml_test_runner, that 1. download yaml tests from Elasticsearch repository for a given branch 2. uses yaml test files in conjunction with rest specs to generate integration tests for each test defined in yaml. 3. runs tests Having a yaml test runner for the client brings it in line with the other official Elasticsearch clients. Tests are generated in a tests directory in the yaml_test_runner package so that they can be invoked with cargo test. The api_generator package is now exposed as a library to yaml_test_runner package, whilst also still compiling it as a runnable binary to generate the client. This allows the generator modules to be used in the yaml_test_runner where they are used to generate tests, by inspecting the ASTs produced by the api_generator. The typical flow to generate and run tests is 1. Define ELASTICSEARCH_VERSION environment variable export ELASTICSEARCH_VERSION=elasticsearch-oss:7.7.0-SNAPSHOT This is used to determine which test suite to generate, based on whether the version uses the default distribution (xpack suite), or the oss distribution (oss suite). 2. Run yaml_test_runner cargo run -p yaml_test_runner -- \ --branch <elasticsearch branch> \ --token <token> \ --path "<path to rest specs>" where - --branch is the elasticsearch branch to target to download yaml tests - --token is a GitHub access token to use to download the yaml tests using the content API - --path is the path to download rest specs to 3. Run the generated tests cargo test -p yaml_test_runner -- --test-threads=1 The tests must be run synchronously, so a single thread must be used. Other pertinent changes in this commit: * impl From<> for TrackTotalHits for i64 and bool * Define expand_wildcards param as a collection * Handle url serialization of enum collections Updates serialize_coll_qs to handle serializing a collection of types that implement Serialize to a comma separated query string value. This is only needed for enums and strings, but (mis)uses serde_json serialize to achieve this, since serde_urlencoded does not support such a format. We could probably implement a serde Serializer for this later on. * Credentials set before setting any other headers in transport to allow headers to overwrite values. * Update TypeKind::None to TypeKind::Unknown(String) Better handle new types when introduced Closes #19 (cherry picked from commit 27b8ac9)
This commit adds a new package to the repository, yaml_test_runner, that 1. download yaml tests from Elasticsearch repository for a given branch 2. uses yaml test files in conjunction with rest specs to generate integration tests for each test defined in yaml. 3. runs tests Having a yaml test runner for the client brings it in line with the other official Elasticsearch clients. Tests are generated in a tests directory in the yaml_test_runner package so that they can be invoked with cargo test. The api_generator package is now exposed as a library to yaml_test_runner package, whilst also still compiling it as a runnable binary to generate the client. This allows the generator modules to be used in the yaml_test_runner where they are used to generate tests, by inspecting the ASTs produced by the api_generator. The typical flow to generate and run tests is 1. Define ELASTICSEARCH_VERSION environment variable export ELASTICSEARCH_VERSION=elasticsearch-oss:7.7.0-SNAPSHOT This is used to determine which test suite to generate, based on whether the version uses the default distribution (xpack suite), or the oss distribution (oss suite). 2. Run yaml_test_runner cargo run -p yaml_test_runner -- \ --branch <elasticsearch branch> \ --token <token> \ --path "<path to rest specs>" where - --branch is the elasticsearch branch to target to download yaml tests - --token is a GitHub access token to use to download the yaml tests using the content API - --path is the path to download rest specs to 3. Run the generated tests cargo test -p yaml_test_runner -- --test-threads=1 The tests must be run synchronously, so a single thread must be used. Other pertinent changes in this commit: * impl From<> for TrackTotalHits for i64 and bool * Define expand_wildcards param as a collection * Handle url serialization of enum collections Updates serialize_coll_qs to handle serializing a collection of types that implement Serialize to a comma separated query string value. This is only needed for enums and strings, but (mis)uses serde_json serialize to achieve this, since serde_urlencoded does not support such a format. We could probably implement a serde Serializer for this later on. * Credentials set before setting any other headers in transport to allow headers to overwrite values. * Update TypeKind::None to TypeKind::Unknown(String) Better handle new types when introduced Closes #19 (cherry picked from commit 27b8ac9)
This PR adds a yaml_test_runner package to the repository. This package produces a binary that can be invoked to
As an example, the following cat.aliases test
generates the following test (use directives omitted for brevity)
Tests are generated in a tests directory in the yaml_test_runner package so that they can be invoked with
cargo test
.The yaml_test_runner package takes dependencies on both api_generator and elasticsearch packages. It uses the Api model from the former to ascertain how to generate client calls from the values defined in yaml, and uses the latter in executing tests.
The typical flow to generate and run tests is
Define
ELASTICSEARCH_VERSION
environment variableexport ELASTICSEARCH_VERSION=elasticsearch-oss:7.7.0-SNAPSHOT
This is used to determine which test suite to generate, based on whether the version uses the default distribution (xpack suite), or the oss distribution (oss suite).
Run yaml_test_runner
where
-
--branch
is the elasticsearch branch to target to download yaml tests-
--token
is a GitHub access token to use to download the yaml tests using the content API-
--path
is the path to download rest specs toRun the generated tests
cargo test -p yaml_test_runner -- --test-threads=1
The tests must be run synchronously, so a single thread must be used.
Closes #19