Commit graph

35 commits

Author SHA1 Message Date
Nassim Kammah
e1217e41db
Doc update (#105270)
Following the migration from Jenkins to Buildkite, docs previews are now available at <repo>_bk_<PR>.

More context in https://github.com/elastic/docs/pull/2898
2024-02-13 14:48:02 +01:00
Rene Groeschke
62d5aa986c
Port gradle docs test plugin to use internal yaml rest test plugin (#86598)
Remove usage of deprecated elasticsearch.rest-test in DocsTestPlugin

we keep some files in src/test in docs projects as moving them would require more changes
in build-docs project outside this repository
2022-05-11 12:01:23 +02:00
James Rodewig
db4d1c53cf
[DOCS] Add doc preview links to docs README (#78857)
I often get asked where to find doc preview links for PRs. This adds some related
docs to docs/README.
2021-10-11 09:24:03 -04:00
James Rodewig
c5b9fdea5b
[DOCS] Update backport policy for known issues (#73489) 2021-05-27 12:23:44 -04:00
Nik Everett
75342a2a71
Add teardown support for doc tests (#70831)
This adds named `teardown` support for doc tests similar to its support
for named `setup` section. This is useful when many doc files want to
share a similar `setup` AND `teardown`. I've introduced an example of
this in the CCR docs just to prove its works. We expect we'll use it for
datastreams as well.

Closes #70830

Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2021-03-24 16:57:50 -04:00
Christoph Büscher
e729e0197a
Correct command for docs snippets test (#62182)
The command for running individual test seems outdated. Using `integTestRunner`
produces an error while `integTest` seems to work.
2020-09-09 18:58:16 +02:00
debadair
ab99a1b88c
[DOCS] Added tips for creating API ref pages. (#59482) 2020-07-14 16:06:51 -07:00
Yang Wang
bd4e94ca08
[DOCS] Fix typo and ensure asterisks render properly (#52991)
Fix a typo and rendering issue for doc test example.
2020-03-02 11:42:48 +11:00
debadair
054f37f99a
[DOCS] Clarify backport policy for important technical corrections. (#49131)
* [DOCS] Clarify backport policy for important technical corrections.

* Update docs/README.asciidoc

Co-Authored-By: James Rodewig <james.rodewig@elastic.co>
2019-11-20 10:54:09 -08:00
Alexander Reelsen
2beda55720 [DOCS] Remove unneeded // CONSOLE comments from snippets (#48763)
* Removes several unneeded `// CONSOLE` comments from snippets in the update by query docs
* Updates the docs README file to remove outdated `// CONSOLE` instructions
2019-11-01 09:02:42 -04:00
debadair
ac5eaf80b9
[DOCS] Add backport policy for doc fixes to README.asciidoc (#48417)
* [DOCS] Add backport policy for doc bug fixes and enhancements to docs README

* Fix bullet & quotes

Co-Authored-By: James Rodewig <james.rodewig@elastic.co>
2019-10-28 16:33:59 -07:00
Nik Everett
948cdab15a
Build: Enable testing without magic comments (#46180)
Previously we only turned on tests if we saw either `// CONSOLE` or
`// TEST`. These magic comments are difficult for the docs build to deal
with so it has moved away from using them where possible. We should
catch up. This adds another trigger to enable testing: marking a snippet
with the `console` language. It looks like this:

```
[source,console]
----
GET /
----
```

This saves a line which is nice, I guess. But it is more important to me
that this is consistent with the way the docs build works now.

Similarly this enables response testing when you mark a snippet with the
language `console-result`. That looks like:
```
[source,console-result]
----
{
  "result": "0.1"
}
----
```

`// TESTRESPONSE` is still available for situations like `// TEST`: when
the response isn't *in* the console-result language (like `_cat`) or
when you want to perform substitutions on the generated test.

Should unblock #46159.
2019-09-04 11:23:29 -04:00
James Rodewig
aca29b6fa4
[DOCS] Document // TEARDOWN test snippet. (#44762)
The `// TEARDOWN` test snippet was added with #34716. You can use this
snippet to end and clean up a test series started with `// TESTSETUP` or
`// TEST[setup:name]`.
2019-07-23 14:04:40 -04:00
david raistrick
cf488d0e98 Add clarification around TESTSETUP docs and error message (#43306) 2019-07-15 15:44:34 +02:00
James Rodewig
655032b07e
[DOCS] Change // TESTRESPONSE[_cat] to // TESTRESPONSE[non_json] (#43006) 2019-06-10 09:33:32 -04:00
James Rodewig
bade776be6
[DOCS] Note TESTRESPONSE can't be used immediately after TESTSETUP (#41542) 2019-04-25 13:58:48 -04:00
Adrien Grand
b57965c900
Fix command line to run doc tests in docs/README. (#40959)
It runs `gradle` instead of `gradlew` and has an extra `\`.
2019-04-10 11:15:45 +02:00
Nik Everett
dc2cf28fde
Docs: Allow skipping response assertions (#34240)
We generate tests from our documentation, including assertions about the
responses returned by a particular API. But sometimes we *can't* assert
that the response is correct because of some defficiency in our tooling.
Previously we marked the response `// NOTCONSOLE` to skip it, but this
is kind of odd because `// NOTCONSOLE` is really to mark snippets that
are json but aren't requests or responses. This introduces a new
construct to skip response assertions:
```
// TESTRESPONSE[skip:reason we skipped this]
```
2018-10-04 08:03:38 -04:00
Hendrik Muhs
fb85dd8c0c
[Docs] remove double words (#34138)
removes double wording and typo
2018-09-29 15:18:00 +02:00
Nik Everett
0522c6644d Docs: Remove duplicate test setup
The range docs had an introductory section that described how to set up
and index *and* a test setup section in `docs/build.gradle` that
duplicated that section. This is bad because these section can (and do)
drift from one another. This change removes the setup in build.gradle
and marks the introductor snippet with `// TESTSETUP` so it is used on
all the snippets.
2018-06-28 10:59:35 -04:00
Lisa Cawley
3960a7a310
[DOCS] Update readme for testing x-pack code snippets (#30696) 2018-05-31 09:32:22 -07:00
Christoph Büscher
994405a768
[Docs] Fix single page :docs:check invocation (#30725)
The docs/README shows how to run the :docs:check goal on a subset of pages,
however using the current example fails. Removing the masking character before
the first wildcard fixes the problem.
2018-05-18 23:33:41 +02:00
Nik Everett
f9dc86836d
Docs: Test examples that recreate lang analyzers (#29535)
We have a pile of documentation describing how to rebuild the built in
language analyzers and, previously, our documentation testing framework
made sure that the examples successfully built *an* analyzer but they
didn't assert that the analyzer built by the documentation matches the
built in anlayzer. Unsuprisingly, some of the examples aren't quite
right.

This adds a mechanism that tests that the analyzers built by the docs.
The mechanism is fairly simple and brutal but it seems to be working:
build a hundred random unicode sequences and send them through the
`_analyze` API with the rebuilt analyzer and then again through the
built in analyzer. Then make sure both APIs return the same results.
Each of these calls to `_anlayze` takes about 20ms on my laptop which
seems fine.
2018-05-09 09:23:10 -04:00
Lisa Cawley
1697f1521c [DOCS] Clarified readme for testing a single page 2017-08-15 15:11:12 -07:00
Nik Everett
13a86fec99 Add magic $_path stash key to docs tests (#24724)
Adds a "magic" key to the yaml testing stash mostly for use with
documentation tests. When unstashing an object, `$_path` is the
path into the current position in the object you are unstashing.
This means that in docs tests you can use
`// TESTRESPONSEs/somevalue/$body.${_path}/` to mean "replace
`somevalue` with whatever is the response in the same position."

Compare how you must carefully mock out all the numbers in the profile
response without this change:
```
// TESTRESPONSE[s/"id": "\[2aE02wS1R8q_QFnYu6vDVQ\]\[twitter\]\[1\]"/"id": $body.profile.shards.0.id/]
// TESTRESPONSE[s/"rewrite_time": 51443/"rewrite_time": $body.profile.shards.0.searches.0.rewrite_time/]
// TESTRESPONSE[s/"score": 51306/"score": $body.profile.shards.0.searches.0.query.0.breakdown.score/]
// TESTRESPONSE[s/"time_in_nanos": "1873811"/"time_in_nanos": $body.profile.shards.0.searches.0.query.0.time_in_nanos/]
// TESTRESPONSE[s/"build_scorer": 2935582/"build_scorer": $body.profile.shards.0.searches.0.query.0.breakdown.build_scorer/]
// TESTRESPONSE[s/"create_weight": 919297/"create_weight": $body.profile.shards.0.searches.0.query.0.breakdown.create_weight/]
// TESTRESPONSE[s/"next_doc": 53876/"next_doc": $body.profile.shards.0.searches.0.query.0.breakdown.next_doc/]
// TESTRESPONSE[s/"time_in_nanos": "391943"/"time_in_nanos": $body.profile.shards.0.searches.0.query.0.children.0.time_in_nanos/]
// TESTRESPONSE[s/"score": 28776/"score": $body.profile.shards.0.searches.0.query.0.children.0.breakdown.score/]
// TESTRESPONSE[s/"build_scorer": 784451/"build_scorer": $body.profile.shards.0.searches.0.query.0.children.0.breakdown.build_scorer/]
// TESTRESPONSE[s/"create_weight": 1669564/"create_weight": $body.profile.shards.0.searches.0.query.0.children.0.breakdown.create_weight/]
// TESTRESPONSE[s/"next_doc": 10111/"next_doc": $body.profile.shards.0.searches.0.query.0.children.0.breakdown.next_doc/]
// TESTRESPONSE[s/"time_in_nanos": "210682"/"time_in_nanos": $body.profile.shards.0.searches.0.query.0.children.1.time_in_nanos/]
// TESTRESPONSE[s/"score": 4552/"score": $body.profile.shards.0.searches.0.query.0.children.1.breakdown.score/]
// TESTRESPONSE[s/"build_scorer": 42602/"build_scorer": $body.profile.shards.0.searches.0.query.0.children.1.breakdown.build_scorer/]
// TESTRESPONSE[s/"create_weight": 89323/"create_weight": $body.profile.shards.0.searches.0.query.0.children.1.breakdown.create_weight/]
// TESTRESPONSE[s/"next_doc": 2852/"next_doc": $body.profile.shards.0.searches.0.query.0.children.1.breakdown.next_doc/]
// TESTRESPONSE[s/"time_in_nanos": "304311"/"time_in_nanos": $body.profile.shards.0.searches.0.collector.0.time_in_nanos/]
// TESTRESPONSE[s/"time_in_nanos": "32273"/"time_in_nanos": $body.profile.shards.0.searches.0.collector.0.children.0.time_in_nanos/]
```

To how you can cavalierly mock all the numbers at once with this change:
```
// TESTRESPONSE[s/(?<=[" ])\d+(\.\d+)?/$body.$_path/]
```
2017-05-23 15:33:48 -04:00
Nik Everett
559bec23cc Docs: rewrite the docs/README file
I originally wrote this file when we first added snippets testing
and a lot has changed. We've grown quite fond of the
`// TESTRESPONSE[s/foo/bar/]` construct, for example, but the docs
discouraged its use.

Relates to #18160
2017-05-04 17:57:25 -04:00
Nik Everett
e39b96f257 Fix confusing section in docs/README
It looked like it was telling you to add both `// TEST[continued]`
and `// TESTRESPONSE` to the same snippet which doesn't do anything.
Instead it was trying to say that you can have many snippets included
into the same test by doing:

```
request1
```
// CONSOLE

```
response1
```
// TESTRESPONSE

``
request2
```
// CONSOLE
// TEST[continued]

```
response2
```
// TESTRESPONSE
2017-02-09 16:17:14 -05:00
Daniel Mitterdorfer
8e4b89cdbe SENSE -> CONSOLE 2017-02-08 11:49:15 +01:00
Isabel Drost-Fromm
c18f032b08 Fix typo in command for checking single doc file
The recommended command line option for running the doc check on a single documentation file contained a typo.

h/t to @nik9000 for finding the typo.
2016-12-14 13:44:57 +01:00
Clinton Gormley
d822a642b0 Document how to run a single docs test 2016-10-06 21:10:49 +02:00
Nik Everett
7cfc2f126c CONSOLEify the first half of getting-started
Adds a `// TESTRESPONSE[_cat]` syntax that sets up some substitutions
useful for asserting that _cat APIs match.
2016-10-01 12:56:23 +02:00
Nik Everett
1e587406d8 Fail yaml tests and docs snippets that get unexpected warnings
Adds `warnings` syntax to the yaml test that allows you to expect
a `Warning` header that looks like:
```
    - do:
        warnings:
            - '[index] is deprecated'
            - quotes are not required because yaml
            - but this argument is always a list, never a single string
            - no matter how many warnings you expect
        get:
            index:    test
            type:    test
            id:        1
```

These are accessible from the docs with:
```
// TEST[warning:some warning]
```

This should help to force you to update the docs if you deprecate
something. You *must* add the warnings marker to the docs or the build
will fail. While you are there you *should* update the docs to add
deprecation warnings visible in the rendered results.
2016-08-04 15:23:05 -04:00
Clinton Gormley
3f594089c2 Renamed all AUTOSENSE snippets to CONSOLE (#18210) 2016-05-09 15:42:23 +02:00
Nik Everett
4b1c116461 Generate and run tests from the docs
Adds infrastructure so `gradle :docs:check` will extract tests from
snippets in the documentation and execute the tests. This is included
in `gradle check` so it should happen on CI and during a normal build.

By default each `// AUTOSENSE` snippet creates a unique REST test. These
tests are executed in a random order and the cluster is wiped between
each one. If multiple snippets chain together into a test you can annotate
all snippets after the first with `// TEST[continued]` to have the
generated tests for both snippets joined.

Snippets marked as `// TESTRESPONSE` are checked against the response
of the last action.

See docs/README.asciidoc for lots more.

Closes #12583. That issue is about catching bugs in the docs during build.
This catches *some* bugs in the docs during build which is a good start.
2016-05-05 13:58:03 -04:00
Clinton Gormley
f529eddbcd Docs: Updated docs/README.asciidoc to point to the new docs repo
Closes #10817
2015-04-27 08:54:07 +02:00
Renamed from docs/README.md (Browse further)