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

feat: add browser and context options support #317

Merged
merged 5 commits into from
Jun 29, 2021

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Jun 23, 2021

Usage

synthetics.config.ts

import type { SyntheticsConfig } from '@elastic/synthetics';

const config: SyntheticsConfig = {
  playwrightOptions: {
    ignoreHTTPSErrors: true,
    extraHTTPHeaders: {
      "foo": "bar"
    },
    ...devices['Galaxy S9+'],
  },
}
export default config;

@apmmachine
Copy link

apmmachine commented Jun 23, 2021

💔 Tests Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #317 updated

  • Start Time: 2021-06-28T17:15:46.072+0000

  • Duration: 9 min 0 sec

  • Commit: b04f6e2

Test stats 🧪

Test Results
Failed 1
Passed 112
Skipped 0
Total 113

Trends 🧪

Image of Build Times

Image of Tests

Test errors 1

Expand to view the tests failures

Test / CLI pass playwright options to runner – CLI pass playwright options to runner
  • no error details
  • Expand to view the stacktrace

     Error: error: unknown option '--json'
    
        at Socket.<anonymous> (/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/src/github.com/elastic/synthetics/__tests__/cli.test.ts:236:50)
        at Socket.emit (events.js:375:28)
        at addChunk (internal/streams/readable.js:290:12)
        at readableAddChunk (internal/streams/readable.js:265:9)
        at Socket.Readable.push (internal/streams/readable.js:204:10)
        at Pipe.onStreamRead (internal/stream_base_commons.js:188:23) 
    

Steps errors 1

Expand to view the steps failures

Runs the tests
  • Took 1 min 44 sec . View more details on here
  • Description: ./node_modules/.bin/jest --ci --reporters=default --reporters=jest-junit

Log output

Expand to view the last 100 lines of log output

[2021-06-28T17:23:30.693Z] Now using node v14.17.1 (npm v6.14.13)
[2021-06-28T17:23:30.737Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/src/github.com/elastic/synthetics
[2021-06-28T17:23:31.030Z] + npm run build
[2021-06-28T17:23:31.030Z] 
[2021-06-28T17:23:31.030Z] > @elastic/synthetics@1.0.0-beta.3 build /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/src/github.com/elastic/synthetics
[2021-06-28T17:23:31.030Z] > tsc
[2021-06-28T17:23:31.030Z] 
[2021-06-28T17:23:34.589Z] Timeout set to expire in 5 min 0 sec
[2021-06-28T17:23:35.516Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/src/github.com/elastic/synthetics
[2021-06-28T17:23:50.328Z] + set +x
[2021-06-28T17:23:50.328Z] => nvm is already installed in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/.nvm, trying to update using git
[2021-06-28T17:23:50.899Z] 
=> => Compressing and cleaning up git repository
[2021-06-28T17:23:50.899Z] 
[2021-06-28T17:23:50.899Z] => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
[2021-06-28T17:23:50.899Z] => Create one of them and run this script again
[2021-06-28T17:23:50.899Z]    OR
[2021-06-28T17:23:50.899Z] => Append the following lines to the correct file yourself:
[2021-06-28T17:23:50.899Z] 
[2021-06-28T17:23:50.899Z] export NVM_DIR="$HOME/.nvm"
[2021-06-28T17:23:50.899Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-06-28T17:23:50.899Z] 
[2021-06-28T17:23:52.809Z] => Close and reopen your terminal to start using nvm or run the following to use it now:
[2021-06-28T17:23:52.809Z] 
[2021-06-28T17:23:52.809Z] export NVM_DIR="$HOME/.nvm"
[2021-06-28T17:23:52.809Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-06-28T17:23:52.809Z] Installing latest LTS version.
[2021-06-28T17:23:52.809Z] v14.17.1 is already installed.
[2021-06-28T17:23:53.068Z] Now using node v14.17.1 (npm v6.14.13)
[2021-06-28T17:23:53.118Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317/src/github.com/elastic/synthetics
[2021-06-28T17:23:53.414Z] + npm add --dev jest-junit
[2021-06-28T17:23:53.675Z] npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.
[2021-06-28T17:23:58.960Z] npm WARN @elastic/synthetics@1.0.0-beta.3 No repository field.
[2021-06-28T17:23:58.960Z] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
[2021-06-28T17:23:58.960Z] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[2021-06-28T17:23:58.960Z] 
[2021-06-28T17:23:58.960Z] + jest-junit@12.2.0
[2021-06-28T17:23:58.960Z] added 4 packages from 9 contributors and audited 769 packages in 5.376s
[2021-06-28T17:23:59.530Z] 
[2021-06-28T17:23:59.530Z] 66 packages are looking for funding
[2021-06-28T17:23:59.530Z]   run `npm fund` for details
[2021-06-28T17:23:59.530Z] 
[2021-06-28T17:23:59.530Z] found 10 moderate severity vulnerabilities
[2021-06-28T17:23:59.530Z]   run `npm audit fix` to fix them, or `npm audit` for details
[2021-06-28T17:23:59.831Z] + ./node_modules/.bin/jest --ci --reporters=default --reporters=jest-junit
[2021-06-28T17:24:04.028Z] 
[2021-06-28T17:24:04.028Z] Running without BrowserService
[2021-06-28T17:24:18.978Z] PASS __tests__/reporters/json.test.ts (13.847 s)
[2021-06-28T17:24:18.978Z] PASS __tests__/plugins/network.test.ts (14.545 s)
[2021-06-28T17:24:19.924Z] PASS __tests__/sdk/trace-metrics.test.ts
[2021-06-28T17:24:20.881Z] PASS __tests__/helper.test.ts
[2021-06-28T17:24:22.805Z] PASS __tests__/reporters/junit.test.ts
[2021-06-28T17:24:24.201Z] PASS __tests__/reporters/base.test.ts
[2021-06-28T17:24:25.587Z] PASS __tests__/core/index.test.ts
[2021-06-28T17:24:25.587Z] PASS __tests__/core/runner.test.ts (21.845 s)
[2021-06-28T17:24:27.520Z] PASS __tests__/plugins/browser-console.test.ts
[2021-06-28T17:24:28.089Z] PASS __tests__/index.test.ts
[2021-06-28T17:24:29.479Z] PASS __tests__/plugins/tracing.test.ts
[2021-06-28T17:24:31.399Z] PASS __tests__/core/gatherer.test.ts
[2021-06-28T17:24:31.659Z] PASS __tests__/plugins/performance.test.ts
[2021-06-28T17:24:33.045Z] PASS __tests__/config.test.ts
[2021-06-28T17:24:33.045Z] PASS __tests__/plugins/plugin-manager.test.ts
[2021-06-28T17:24:33.991Z] PASS __tests__/core/logger.test.ts
[2021-06-28T17:24:34.937Z] PASS __tests__/sdk/trace-processor.test.ts
[2021-06-28T17:24:34.937Z] PASS __tests__/core/browser-service.test.ts
[2021-06-28T17:24:35.878Z] PASS __tests__/dsl/journey.test.ts
[2021-06-28T17:24:44.006Z] FAIL __tests__/cli.test.ts (25.515 s)
[2021-06-28T17:24:44.006Z]   ● CLI › pass playwright options to runner
[2021-06-28T17:24:44.006Z] 
[2021-06-28T17:24:44.006Z]     error: unknown option '--json'
[2021-06-28T17:24:44.006Z] 
[2021-06-28T17:24:44.006Z]       234 | 
[2021-06-28T17:24:44.006Z]       235 |     this.exitCode = new Promise((res, rej) => {
[2021-06-28T17:24:44.006Z]     > 236 |       this.process.stderr.on('data', data => rej(new Error(data)));
[2021-06-28T17:24:44.006Z]           |                                                  ^
[2021-06-28T17:24:44.006Z]       237 |       this.process.on('exit', code => res(code));
[2021-06-28T17:24:44.006Z]       238 |     });
[2021-06-28T17:24:44.006Z]       239 |   }
[2021-06-28T17:24:44.006Z] 
[2021-06-28T17:24:44.006Z]       at Socket.<anonymous> (__tests__/cli.test.ts:236:50)
[2021-06-28T17:24:44.006Z] 
[2021-06-28T17:24:44.006Z] Test Suites: 1 failed, 19 passed, 20 total
[2021-06-28T17:24:44.006Z] Tests:       1 failed, 98 passed, 99 total
[2021-06-28T17:24:44.006Z] Snapshots:   11 passed, 11 total
[2021-06-28T17:24:44.006Z] Time:        39.851 s
[2021-06-28T17:24:44.006Z] Ran all test suites.
[2021-06-28T17:24:44.975Z] Post stage
[2021-06-28T17:24:44.999Z] Recording test results
[2021-06-28T17:24:45.053Z] [Checks API] No suitable checks publisher found.
[2021-06-28T17:24:45.113Z] Stage "E2e Test" skipped due to earlier failure(s)
[2021-06-28T17:24:45.149Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-28T17:24:45.166Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-28T17:24:45.201Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-28T17:24:45.483Z] Running on worker-1095690 in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-317
[2021-06-28T17:24:45.524Z] [INFO] getVaultSecret: Getting secrets
[2021-06-28T17:24:45.572Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-06-28T17:24:47.577Z] + chmod 755 generate-build-data.sh
[2021-06-28T17:24:47.577Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-317/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-317/runs/7 FAILURE 540108
[2021-06-28T17:24:47.577Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-317/runs/7/steps/?limit=10000 -o steps-info.json
[2021-06-28T17:24:49.840Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-317/runs/7/tests/?status=FAILED -o tests-errors.json
[2021-06-28T17:24:49.840Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-317/runs/7/log/ -o pipeline-log.txt

@andrewvc
Copy link
Contributor

/test

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks good, but I think there may be a bug present. I tried to modify the todos example (pushed to your branch, hope that's not a problem), and don't see the added options in effect.

One other note, you must invoke elastic-synthetics from inside the todos folder, not via elastic-synthetics examples/todos for the synthetics.config.ts to be applied (I'll open a separate issue for that).

// Just expanded for illustration
userAgent:
'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
viewport: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see these options reflected with --no-headless, are we sure they're applied correctly? Could be an error on my part.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work properly for me, can you pass me the command used to invoke these?

@vigneshshanmugam
Copy link
Member Author

One other note, you must invoke elastic-synthetics from inside the todos folder, not via elastic-synthetics examples/todos for the synthetics.config.ts to be applied (I'll open a separate issue for that).

This is intended, we traverse up the root and not down the root path. This is keeping in mind how heartbeat invokes the underlying suites test and matches the behaviour of finding package.json files.

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vigneshshanmugam vigneshshanmugam merged commit 038f58e into elastic:master Jun 29, 2021
@vigneshshanmugam vigneshshanmugam deleted the playwright-options branch June 29, 2021 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants