-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] cypress setup #113106
[Fleet] cypress setup #113106
Conversation
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@joshdover @jen-huang this is the draft pr that I've done during ON week to add cypress setup to Fleet, do we want to merge it or wait until it is presented to the team? The caveat is that this task adds 2 minutes to build time, I don't know yet if these test tasks are parallelised on CI. |
If no one on the team is opposed to moving forward with Cypress, I'm +1 on moving this into review. |
@elasticmachine merge upstream |
navigateTo(INTEGRATIONS); | ||
cy.get(INTEGRATIONS_CARD).contains(integration).click(); | ||
addIntegration(); | ||
cy.get(INTEGRATION_NAME_LINK).contains('apache-'); | ||
} | ||
|
||
it('[Mocked requests] should display Apache integration in the Policies list once installed ', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is the duplication of the one above, but with mocked requests to showcase network stubbing.
Pros: quicker test, isolation of UI testing
Cons: lot of extra setup needed (fixture files, intercept each api call)
I think for critical testcases real e2e test would be better, mocked requests are useful when the goal is to test complex UI logic without relying on real backend.
See https://docs.cypress.io/guides/guides/network-requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think real request will make sense here. But maybe we should do the same things as we do with our API integration tests where we have a docker package registry locally otherwise I think we can have some flakiness here. (This should be done in a following PR already a lot of good stuff here)
Pinging @elastic/fleet (Team:Fleet) |
'--env', | ||
'FLEET_SERVER_ENABLE=true', | ||
'--env', | ||
`FLEET_SERVER_ELASTICSEARCH_HOST=http://host.docker.internal:${this.esConfig.port}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was working locally, though it is not on CI, trying to figure out why, not able to connect to ES
2021-10-28T17:56:55.723Z INFO cmd/enroll_cmd.go:760 Fleet Server - Starting
--
| 2021-10-28T17:56:56.527Z ERROR status/reporter.go:236 Elastic Agent status changed to: 'error'
| 2021-10-28T17:56:56.528Z ERROR log/reporter.go:36 2021-10-28T17:56:56Z - message: Application: fleet-server--8.0.0-SNAPSHOT[]: State changed to FAILED: Error - dial tcp 172.17.0.1:6102: connect: connection refused - type: 'ERROR' - sub_type: 'FAILED'
| 2021-10-28T17:56:57.726Z INFO cmd/enroll_cmd.go:760 Fleet Server - Error - dial tcp 172.17.0.1:6102: connect: connection refused
@elasticmachine merge upstream |
// define custom es server here | ||
// API Keys is enabled at the top level | ||
'xpack.security.enabled=true', | ||
'http.host=0.0.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally, fleet_server with docker works by adding http.host
to make es accessible from the docker container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, tested locally and was able to follow the flow of how things are linked together pretty well. I see no reason to hold on merging this and iterating as we go. Thank you for doing this, it's going to be very helpful for us going forward.
elastic-agent-* | ||
fleet-server-* | ||
elastic-agent.yml | ||
fleet-server.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: new line
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we make this a ts file?
x-pack/test/fleet_cypress/agent.ts
Outdated
// this.log.info('Updating the default agent output'); | ||
// const { | ||
// data: { | ||
// items: [defaultOutput], | ||
// }, | ||
// } = await axios.get(this.params.kibanaUrl + '/api/fleet/outputs', this.requestOptions); | ||
|
||
// await axios.put( | ||
// `${this.params.kibanaUrl}/api/fleet/outputs/${defaultOutput.id}`, | ||
// { hosts: [this.params.esHost] }, | ||
// this.requestOptions | ||
// ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
module.exports = (_on, _config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this a ts file?
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
* added cypress setup for fleet * updated readme * fixed types * fix unused * starting up fleet server in cypress * added more fleet tests * added package update test * updated readme * trying jenkins run * trying jenkins run * trying jenkins run * fix types, cypress config * example of mocked requests * added getBySel * fix test after refactor * removed duplication * fix tests * added to buildkite * updated tests * starting agent with docker * trying to fix ip address * ifconfig * ip address * ip address * ip address * type fix * remove extra logging * fixed test * fix buildkite * cleanup * cleanup * using docker for fleet_server * fix * fix * trying to fix * update config * test * test * test * test * revert changes * test * test * static ip on linux * docker version * try again * fixed review comments * fixed types Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Patryk Kopycinski <[email protected]>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
* [Fleet] cypress setup (#113106) * added cypress setup for fleet * updated readme * fixed types * fix unused * starting up fleet server in cypress * added more fleet tests * added package update test * updated readme * trying jenkins run * trying jenkins run * trying jenkins run * fix types, cypress config * example of mocked requests * added getBySel * fix test after refactor * removed duplication * fix tests * added to buildkite * updated tests * starting agent with docker * trying to fix ip address * ifconfig * ip address * ip address * ip address * type fix * remove extra logging * fixed test * fix buildkite * cleanup * cleanup * using docker for fleet_server * fix * fix * trying to fix * update config * test * test * test * test * revert changes * test * test * static ip on linux * docker version * try again * fixed review comments * fixed types Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Patryk Kopycinski <[email protected]> * using 8.0.0 docker image for backport Co-authored-by: Julia Bardi <[email protected]> Co-authored-by: Patryk Kopycinski <[email protected]> Co-authored-by: Julia Bardi <[email protected]>
Summary
Cypress setup for Fleet. ON week work.
Setup for Fleet Server and Agent is from Bryan Clement's pr here: #108759
To run locally:
cd x-pack/plugins/fleet
yarn cypress:open-as-ci
Make sure to stop any agent instances before starting, otherwise you might get this grpc port conflict: elastic/beats#28118
Added cypress to ci run:
https://github.com/elastic/kibana/pull/113106/checks?check_run_id=3744593878
Cypress major upgrade just happened with this: #104301
Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers