Skip to content
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 synthetics configuration docs #847

Merged
merged 3 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en/observability/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ include::synthetics-visualize.asciidoc[leveloffset=+2]

include::synthetics-params-secrets.asciidoc[leveloffset=+2]

include::synthetics-configuration.asciidoc[leveloffset=+2]

// User experience
include::user-experience.asciidoc[leveloffset=+1]

Expand Down
64 changes: 64 additions & 0 deletions docs/en/observability/synthetics-configuration.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[[synthetics-configuration]]
= Synthetic tests configuration

++++
<titleabbrev>Synthetic tests configuration</titleabbrev>
++++

beta[] Synthetic tests support the configuration of dynamic parameters that can be
used in the suites. In addition to that, the Synthetics agent which is built on top
of Playwright supports configuring browser and context options that are available
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved
in Playwright specific methods, for example, `ignoreHTTPSErrors`, `viewport`.
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved

[discrete]
[[synthetics-config-file]]
== Global Synthetics Configuration

Create `synthetics.config.js` or `synthetics.config.ts` in the root of
synthetics project and specify the options
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
----
import { SyntheticsConfig } from "@elastic/synthetics"

const config: SyntheticsConfig = {
params: {
url: "https://www.elastic.co"
},
playwrightOptions: {
ignoreHTTPSErrors: true, // ignores all HTTPS errors during navigation
}
}

export default config;
----

The configuration file can return either a function or an object which will be
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved

To know more about configuring the tests based on environments, look at the
<<synthetics-dynamic-configs, dynamic configuration>> documentation.
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved

[discrete]
[[synthetics-config-device-emulation]]
=== Device emulation

Users can emulate a mobile device using the configuration file. Check
the example configuration below that runs tests in "Pixel 5" emulation mode.
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
----
import { SyntheticsConfig } from "@elastic/synthetics"
import { devices } from "playwright-chromium"

const config: SyntheticsConfig = {
playwrightOptions: {
...devices['Pixel 5']
}
}

export default config;
----


NOTE: Synthetics tests configuration can only be used along with synthetics
projects and is not available for inline suites.
10 changes: 5 additions & 5 deletions docs/en/observability/synthetics-params-secrets.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If you try to run the example above you'll notice an error because we haven't sp
Parameter values can be declared by any of the following methods:

* Declaring a default value for the parameter in a configuration file.
* Passing the `--suite-params` CLI argument.
* Passing the `--params` CLI argument.
* Specifying the parameter in the heartbeat yaml config using the `params` option.

The values in the configuration file are read first, then merged with either the CLI argument, or the Heartbeat
Expand All @@ -48,7 +48,7 @@ option, with the CLI and Heartbeat options taking precedence over the configurat
These options are discussed in detail in the sections below.

[discrete]
[[synthetics-configs]]
[[synthetics-dynamic-configs]]
== Using a config file to set params

Use a `synthetics.config.js` or `synthetics.config.ts` file to define variables your tests always need to be defined.
Expand Down Expand Up @@ -76,15 +76,15 @@ Note that we use the `env` variable in the above example, which corresponds to t
[[synthetics-cli-params]]
== Using CLI arguments to set params

To set parameters when running `elastic-synthetics` on the command line, use the `--suite-params` or `-s` arguments to the `elastic-synthetics` program. The provided map is merged over any existing variables defined in the `synthetics.config.{js,ts}` file.
To set parameters when running `elastic-synthetics` on the command line, use the `--params` or `-p` flag to the `elastic-synthetics` program. The provided map is merged over any existing variables defined in the `synthetics.config.{js,ts}` file.

To override the `url` parameter, you would run: `elastic-synthetics . --suite-params '{"url": "http://localhost:8080"}'`
To override the `url` parameter, you would run: `elastic-synthetics . --params '{"url": "http://localhost:8080"}'`

[discrete]
[[synthetics-hb-params]]
== Using Heartbeat options to set params

When running via Heartbeat use the `params` option to set additional parameters, passed through the `--suite-params` flag
When running via Heartbeat use the `params` option to set additional parameters, passed through the `--params` flag
mentioned above and have their values merged over any default values. In the example below we run the todos app, overriding the `url`
parameter.

Expand Down