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 synthetics script generator #375

Merged

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Sep 14, 2021

  • Paves the way for consuming IR in the future and allows recorder to use the module directly from here instead of keeping the code at various places.
  • Synthetics generator is based on the code generator interface implementation of Playwright JavaScript formatter. Kept mostly in sync to make sure we can switch to PW format in the future.
  • Handles both inline and scripted journeys based on a simple flag.

Note: Only exception is the use of assertion IR which is different from PW actions which does not have the capability yet.

@apmmachine
Copy link

apmmachine commented Sep 14, 2021

❕ Build Aborted

Either there was a build timeout or someone aborted the build.'}

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

  • Start Time: 2021-09-15T20:21:14.047+0000

  • Duration: 28 min 31 sec

  • Commit: f5606bc

Test stats 🧪

Test Results
Failed 0
Passed 127
Skipped 0
Total 127

Trends 🧪

Image of Build Times

Image of Tests

Log output

Expand to view the last 100 lines of log output

[2021-09-15T20:30:52.677Z]  > git checkout -f fc9614e7f9155a83c7ad9b153db581d60837d7b0 # timeout=15
[2021-09-15T20:30:57.128Z] Commit message: "Merge commit '7cbca0a666978ad46e963d2d711ecb00a042167f' into HEAD"
[2021-09-15T20:30:57.134Z]  > git rev-list --no-walk 05e49b59de11f610a3852d55f23aedc43ea9ef86 # timeout=10
[2021-09-15T20:30:57.224Z] Cleaning workspace
[2021-09-15T20:30:57.226Z]  > git rev-parse --verify HEAD # timeout=10
[2021-09-15T20:30:57.233Z] Resetting working tree
[2021-09-15T20:30:57.233Z]  > git reset --hard # timeout=10
[2021-09-15T20:30:57.249Z]  > git clean -fdx # timeout=10
[2021-09-15T20:30:59.229Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics
[2021-09-15T20:31:14.318Z] + set +x
[2021-09-15T20:31:14.318Z] => Downloading nvm from git to '/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/.nvm'
[2021-09-15T20:31:14.318Z] 
=> Initialized empty Git repository in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/.nvm/.git/
[2021-09-15T20:31:14.894Z] From https://github.com/nvm-sh/nvm
[2021-09-15T20:31:14.894Z]  * [new tag]         v0.37.1    -> v0.37.1
[2021-09-15T20:31:14.894Z] => Compressing and cleaning up git repository
[2021-09-15T20:31:14.894Z] 
[2021-09-15T20:31:14.894Z] => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
[2021-09-15T20:31:14.894Z] => Create one of them and run this script again
[2021-09-15T20:31:14.894Z]    OR
[2021-09-15T20:31:14.894Z] => Append the following lines to the correct file yourself:
[2021-09-15T20:31:14.894Z] 
[2021-09-15T20:31:14.894Z] export NVM_DIR="$HOME/.nvm"
[2021-09-15T20:31:14.894Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-09-15T20:31:14.894Z] 
[2021-09-15T20:31:16.802Z] => Close and reopen your terminal to start using nvm or run the following to use it now:
[2021-09-15T20:31:16.802Z] 
[2021-09-15T20:31:16.802Z] export NVM_DIR="$HOME/.nvm"
[2021-09-15T20:31:16.802Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-09-15T20:31:16.802Z] Found '/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics/.nvmrc' with version <14.17.5>
[2021-09-15T20:31:17.062Z] v14.17.5 is already installed.
[2021-09-15T20:31:17.322Z] Now using node v14.17.5 (npm v6.14.14)
[2021-09-15T20:31:17.322Z] /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375
[2021-09-15T20:31:17.436Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics
[2021-09-15T20:31:17.726Z] + chmod -R ugo+rw examples
[2021-09-15T20:31:17.744Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T20:31:18.034Z] + npm run test
[2021-09-15T20:31:18.034Z] 
[2021-09-15T20:31:18.034Z] > e2e-synthetics@ test /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T20:31:18.034Z] > npm i && npm run setup &&  bash scripts/test.sh
[2021-09-15T20:31:18.034Z] 
[2021-09-15T20:31:21.330Z] added 3 packages from 4 contributors and audited 184 packages in 2.418s
[2021-09-15T20:31:23.240Z] 
[2021-09-15T20:31:23.240Z] 69 packages are looking for funding
[2021-09-15T20:31:23.240Z]   run `npm fund` for details
[2021-09-15T20:31:23.240Z] 
[2021-09-15T20:31:23.240Z] found 0 vulnerabilities
[2021-09-15T20:31:23.240Z] 
[2021-09-15T20:31:23.500Z] 
[2021-09-15T20:31:23.501Z] > e2e-synthetics@ setup /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T20:31:23.501Z] > bash scripts/setup.sh
[2021-09-15T20:31:23.501Z] 
[2021-09-15T20:31:23.501Z] 
[2021-09-15T20:31:23.501Z] Temporary folder
[2021-09-15T20:31:23.501Z] Temporary files will be stored in: ./tmp
[2021-09-15T20:31:23.501Z] 
[2021-09-15T20:31:23.501Z] Starting elasticsearch , kibana and synthetics docker
[2021-09-15T20:31:23.501Z] 
[2021-09-15T20:31:23.501Z] 
[2021-09-15T20:31:23.501Z] Waiting for synthetics docker to start...
[2021-09-15T20:31:23.501Z] Error: No such object: synthetics
[2021-09-15T20:31:35.723Z] Error: No such object: synthetics
[2021-09-15T20:31:43.846Z] Error: No such object: synthetics
[2021-09-15T20:31:53.835Z] Error: No such object: synthetics
[2021-09-15T20:32:03.821Z] Error: No such object: synthetics
[2021-09-15T20:32:13.810Z] Error: No such object: synthetics
[2021-09-15T20:32:26.023Z] Error: No such object: synthetics
[2021-09-15T20:32:34.152Z] Error: No such object: synthetics
[2021-09-15T20:32:44.177Z] ✅ Setup completed successfully. Running e2e tests...
[2021-09-15T20:32:45.607Z] Waiting for Elastic Search  to start
[2021-09-15T20:33:24.525Z] Waiting for Synthetics to send data to ES for test monitor
[2021-09-15T20:34:32.357Z] Waiting for kibana server to start
[2021-09-15T20:48:34.702Z] Cancelling nested steps due to timeout
[2021-09-15T20:48:34.706Z] Sending interrupt signal to process
[2021-09-15T20:48:39.989Z] scripts/test.sh: line 26:  6309 Terminated              SYNTHETICS_JUNIT_FILE='junit.xml' npx @elastic/synthetics uptime.journey.ts --reporter junit
[2021-09-15T20:48:39.989Z] npm ERR! code ELIFECYCLE
[2021-09-15T20:48:39.989Z] npm ERR! errno 143
[2021-09-15T20:48:39.989Z] npm ERR! e2e-synthetics@ test: `npm i && npm run setup &&  bash scripts/test.sh`
[2021-09-15T20:48:39.989Z] npm ERR! Exit status 143
[2021-09-15T20:48:39.989Z] npm ERR! 
[2021-09-15T20:48:39.989Z] npm ERR! Failed at the e2e-synthetics@ test script.
[2021-09-15T20:48:39.990Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[2021-09-15T20:48:39.990Z] 
[2021-09-15T20:48:39.990Z] npm ERR! A complete log of this run can be found in:
[2021-09-15T20:48:39.990Z] npm ERR!     /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375/.npm/_logs/2021-09-15T20_48_34_962Z-debug.log
[2021-09-15T20:48:39.996Z] script returned exit code 143
[2021-09-15T20:48:42.724Z] Post stage
[2021-09-15T20:48:42.777Z] Archiving artifacts
[2021-09-15T20:48:43.169Z] Recording test results
[2021-09-15T20:48:43.521Z] None of the test reports contained any result
[2021-09-15T20:48:43.535Z] [Checks API] No suitable checks publisher found.
[2021-09-15T20:48:43.754Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T20:48:43.783Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T20:48:43.850Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T20:48:44.132Z] Running on Jenkins in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-375
[2021-09-15T20:48:44.172Z] [INFO] getVaultSecret: Getting secrets
[2021-09-15T20:48:44.208Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-09-15T20:48:44.852Z] + chmod 755 generate-build-data.sh
[2021-09-15T20:48:44.852Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-375/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-375/runs/2 ABORTED 1650544
[2021-09-15T20:48:44.852Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-375/runs/2/steps/?limit=10000 -o steps-info.json
[2021-09-15T20:48:44.852Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-375/runs/2/tests/?status=FAILED -o tests-errors.json

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

Just had a few questions and some nit typo corrections. I've walked through this and based on the test outputs and the code itself I haven't found any major concerns.

LGTM

src/formatter/javascript.ts Show resolved Hide resolved
src/formatter/javascript.ts Outdated Show resolved Hide resolved
src/formatter/javascript.ts Outdated Show resolved Hide resolved
formatter.add(`
const { journey, step, expect } = require('@elastic/synthetics');

journey('Recorded journey', async ({ page, context }) => {`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it ever be useful to take a param for the journey name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not for the current iteration. We dont have any option of passing down params from recording, but definitely in future.

@vigneshshanmugam vigneshshanmugam merged commit b61cc89 into elastic:master Sep 15, 2021
@vigneshshanmugam vigneshshanmugam deleted the synthetics-formatter branch September 15, 2021 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants