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

[APM] E2E: Zero config for running e2e locally #59152

Merged
merged 9 commits into from
Mar 24, 2020

Conversation

sorenlouv
Copy link
Member

@sorenlouv sorenlouv commented Mar 3, 2020

Changes

  • Use env vars for cypress (instead of importing kibana.dev.yml)
  • Use --config to load kibana.e2e.yml instead of the user's kibana.dev.yml.
  • Added run-e2e.sh script to automatically setup environment and run tests

TODO:

apm 2e2

Helpful error messages
image

image

@sorenlouv sorenlouv requested a review from a team as a code owner March 3, 2020 15:01
@sorenlouv sorenlouv requested a review from v1v March 3, 2020 15:02
@sorenlouv sorenlouv added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Mar 3, 2020
@@ -7,7 +7,7 @@
```shell
$ git clone https://github.com/elastic/apm-integration-testing.git
$ cd apm-integration-testing
./scripts/compose.py start master --no-kibana --no-xpack-secure
./scripts/compose.py start master --no-kibana --elasticsearch-port 9201 --apm-server-port 8201
Copy link
Member Author

Choose a reason for hiding this comment

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

Enabling Security and ES and APM Server on non-default ports to avoid clashing with local development


4. Start Kibana

```shell
$ yarn kbn bootstrap
$ yarn start --no-base-path --csp.strict=false
$ yarn start --no-base-path --config x-pack/legacy/plugins/apm/e2e/ci/kibana.e2e.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

Refer to e2e specific config file (instead of moving it around)

```

> Content Security Policy (CSP) Settings: Your Kibana instance must have the `csp.strict: false`.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now specified in kibana.e2e.yml. Not something the user has to worry about.

@@ -0,0 +1,31 @@
# Kibana
server.port: 5701
Copy link
Member Author

Choose a reason for hiding this comment

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

Running kibana on a non-default port to avoid clashing with local development

xpack.apm.autocreateApmIndexPattern: true
xpack.apm.ui.enabled: true
xpack.apm.ui.transactionGroupBucketSize: 100
xpack.apm.ui.maxTraceItems: 1000
Copy link
Member Author

Choose a reason for hiding this comment

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

Added all apm configurations to ensure they don't break without us noticing

"env": {
"elasticsearch_username": "admin",
"elasticsearch_password": "changeme"
}
Copy link
Member Author

@sorenlouv sorenlouv Mar 3, 2020

Choose a reason for hiding this comment

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

Provide credentials to Cypress via environment vars

@sorenlouv
Copy link
Member Author

retest

# Started via apm-integration-testing
# ./scripts/compose.py start master --no-kibana --elasticsearch-port 9201 --apm-server-port 8201
elasticsearch.hosts: http://localhost:9201
elasticsearch.username: 'kibana_system_user'
Copy link
Member

Choose a reason for hiding this comment

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

kibana_system_user didn't work when I tried, so maybe admin could be a good one, what do you think?

Suggested change
elasticsearch.username: 'kibana_system_user'
elasticsearch.username: 'admin'

Copy link
Member Author

Choose a reason for hiding this comment

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

Kibana shouldn't connect to ES with superuser privileges. According to the docs kibana_system_user should exist.

I can confirm that kibana_system_user can access ES like:

curl --user kibana_system_user:changeme -X GET "localhost:9201/_security/user/_has_privileges?pretty" -H 'Content-Type: application/json' -d'{ "cluster": [ "monitor", "manage" ] }'

which returns:

{
  "username" : "kibana_system_user",
  "has_all_requested" : false,
  "cluster" : {
    "monitor" : true,
    "manage" : false
  },
  "index" : { },
  "application" : { }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you try running that and LMK if it works?

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

👍 once conflicts resolved and up to date and tests pass.

@sorenlouv sorenlouv changed the title [APM] E2E: Use env vars over kibana.yml [APM] E2E: Improve local DX by running all with single command Mar 20, 2020
@sorenlouv sorenlouv changed the title [APM] E2E: Improve local DX by running all with single command [APM] E2E: Zero config for running e2e locally Mar 20, 2020
v1v added a commit to v1v/kibana that referenced this pull request Mar 21, 2020
v1v added a commit to v1v/kibana that referenced this pull request Mar 21, 2020
v1v added a commit to v1v/kibana that referenced this pull request Mar 21, 2020
v1v added a commit to v1v/kibana that referenced this pull request Mar 22, 2020
@cachedout
Copy link
Contributor

Hi @sqren

I'm helping to triage high-priority issues for @elastic/observablt-robots . Just so I understand, are the TODO items listed above part of this PR or is the intention to address them in follow-up PRs?

@sorenlouv
Copy link
Member Author

Hey @cachedout,

I've just pushed a commit that fixes most of the issues. Only remaining issue is that apm-integration-testing does not return a non-zero exit code upon error. This should be fixed in https://github.com/elastic/apm-integration-testing but not something that should block this PR.

I'll merge this as soon as CI is green

@kuisathaverat
Copy link
Contributor

@sqren Do exist an issue for that on the https://github.com/elastic/apm-integration-testing? I do not see any. Would you mind fill one with the details of what happens?

@sorenlouv
Copy link
Member Author

@kuisathaverat elastic/apm-integration-testing#800

@sorenlouv
Copy link
Member Author

retest


echo "3/3 Start Kibana ..."
popd
## Might help to avoid FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
export NODE_OPTIONS="--max-old-space-size=4096"
nohup node scripts/kibana --no-base-path --csp.strict=false --optimize.watch=false> kibana.log 2>&1 &
nohup node scripts/kibana --config "${E2E_DIR}/ci/kibana.e2e.yml" --no-base-path --optimize.watch=false> kibana.log 2>&1 &
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference with https://github.com/elastic/kibana/pull/59152/files#diff-ccfe59ee0ec66fe86f6596aaf1fce60cR24? Are those flags also required in the CI?

Copy link
Member Author

@sorenlouv sorenlouv Mar 24, 2020

Choose a reason for hiding this comment

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

This starts in dev mode

node ./scripts/kibana --no-base-path --dev --no-dev-config --config x-pack/legacy/plugins/apm/e2e/ci/kibana.e2e.yml

This starts in prod mode

node scripts/kibana --no-base-path --optimize.watch=false --config "${E2E_DIR}/ci/kibana.e2e.yml" 

I think we should choose whatever is faster on CI. I guess we can test by running it 100 times or so on the CI in each mode.
I imagine dev compiles faster (because it doesn't need to compress resources) but prod has faster browser load times because assets are smaller. So could go both ways.

The reason I opted for using dev mode locally is because this is what developers is normally running, and I saw some issues when running prod mode without cleaning up after having run dev mode.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clarification, I'd say to use the same as the local one to avoid any misleading, then it will be easy to reproduce it anyway. Thanks again

v1v added a commit to v1v/kibana that referenced this pull request Mar 24, 2020
@sorenlouv
Copy link
Member Author

@elasticmachine merge upstream

v1v added a commit to v1v/kibana that referenced this pull request Mar 24, 2020
then we don't need to trap the errorlevel
@sorenlouv sorenlouv merged commit 0fc0440 into elastic:master Mar 24, 2020
@sorenlouv sorenlouv deleted the use-env-variables-e2e branch March 24, 2020 19:28
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@v1v v1v mentioned this pull request Mar 30, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants