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

[Reporting] Download/install the browser in the setup phase #113212

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Sep 28, 2021

Summary

Problem: Something that would have made working on #112905 better, is if the browser drivers were initialized in the setup phase of the Reporting plugin, rather than the start. That would allowed dev to work through this without the need to have Elasticsearch connected.

This PR makes Reporting register its browser driver factory register in the plugin setup method, which means not waiting for Elasticsearch to start before checking the existence of the browser and validating the checksum.

@tsullivan tsullivan force-pushed the reporting/browserdriver-synchronous branch 3 times, most recently from 41219f8 to d1c71e8 Compare September 28, 2021 19:43
@elastic elastic deleted a comment from kibanamachine Sep 28, 2021
@tsullivan tsullivan force-pushed the reporting/browserdriver-synchronous branch from d1c71e8 to cbbce1b Compare September 28, 2021 19:44
paths: ChromiumArchivePaths;
}

export const initializeBrowserDriverFactory = async (core: ReportingCore, logger: LevelLogger) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

chromium.createDriverFactory is a one-liner now, so this helper function isn't helpful :)


logger.info(`Browser executable: ${binaryPath}`);

resolve(binaryPath);
Copy link
Member Author

Choose a reason for hiding this comment

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

The previous code didn't have a lot of reason for using an observable here.

@tsullivan tsullivan force-pushed the reporting/browserdriver-synchronous branch from cbbce1b to 2de3595 Compare September 28, 2021 20:09
@tsullivan tsullivan changed the title [Reporting] Make browser driver factory initialization synchronous [Reporting] Download/install the browser in the setup phase Sep 28, 2021
constructor(core: ReportingCore, binaryPath: string, logger: LevelLogger) {
this.core = core;
this.binaryPath = binaryPath;
const config = core.getConfig();
Copy link
Member Author

@tsullivan tsullivan Sep 28, 2021

Choose a reason for hiding this comment

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

There are a lot of changes in this code due to core.getConfig can only be called after the setup phase of the Reporting plugin.

In other words, the ReportingConfig object is asynchronously instantiated due to being implemented before #88981

@tsullivan tsullivan force-pushed the reporting/browserdriver-synchronous branch from 2de3595 to b12eb43 Compare September 28, 2021 20:16
@tsullivan
Copy link
Member Author

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Sep 28, 2021
@tsullivan tsullivan force-pushed the reporting/browserdriver-synchronous branch from 12f2f1c to effdecf Compare October 4, 2021 17:26
@kibanamachine
Copy link
Contributor

kibanamachine commented Oct 4, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/reporting/server/export_types/png_v2.returns content of generatePng getBuffer base64 encoded

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toEqual(expected) // deep equality

Expected: "raw string from get_screenhots"
Received: ""
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/reporting/server/export_types/png_v2/execute_job.test.ts:166:19)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/reporting/server/routes/diagnostic.POST /diagnose/screenshot returns a 200 by default

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expected 200 "OK", got 500 "Internal Server Error"
    at Test.Object.<anonymous>.Test._assertStatus (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test.Object.<anonymous>.Test._assertFunction (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.Object.<anonymous>.Test.assert (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:131:12)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Object.<anonymous>.Request.callback (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/index.js:718:3)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/index.js:906:18
    at IncomingMessage.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/reporting/server/routes/diagnostic.POST /diagnose/screenshot returns a 200 when it fails and sets success to false

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expected 200 "OK", got 500 "Internal Server Error"
    at Test.Object.<anonymous>.Test._assertStatus (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test.Object.<anonymous>.Test._assertFunction (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.Object.<anonymous>.Test.assert (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:131:12)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Object.<anonymous>.Request.callback (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/index.js:718:3)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/index.js:906:18
    at IncomingMessage.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/supertest/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

and 10 more failures, only showing the first 3.

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
reporting 134 135 +1

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
reporting 12 13 +1
Unknown metric groups

API count

id before after diff
reporting 135 136 +1

History

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

@tsullivan
Copy link
Member Author

Closing this as Mike Dokolin is working on this part of the code. I'll just keep a bookmark to this draft

@tsullivan tsullivan closed this Oct 11, 2021
@tsullivan tsullivan deleted the reporting/browserdriver-synchronous branch February 11, 2022 17:47
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.

2 participants