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

[Uptime] Create state store at plugin setup time #66054

Closed
wants to merge 7 commits into from

Conversation

justinkambic
Copy link
Contributor

@justinkambic justinkambic commented May 11, 2020

Summary

I am hoping this change resolves elastic/uptime#179.

This patch moves the creation of our Redux store to the setup function of our plugin. We'd pass our UI alert types to the Alerting UI from our start function, wrapping the components we supply in the necessary context providers to interact with the store.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@justinkambic justinkambic added bug Fixes for quality problems that affect the customer experience v8.0.0 Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels May 11, 2020
@justinkambic justinkambic self-assigned this May 11, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@justinkambic
Copy link
Contributor Author

It would be really nice if someone from @elastic/kibana-platform could let me know if this is an anti-pattern or otherwise evil hack that violates the principles of Kibana platform design. If so, an alternative suggestion would be highly appreciated.

@justinkambic justinkambic marked this pull request as ready for review May 13, 2020 21:13
@justinkambic justinkambic requested a review from a team as a code owner May 13, 2020 21:13
@justinkambic justinkambic requested a review from a team May 14, 2020 13:43

alertTypeInitializers.forEach(init => {
const alertInitializer = init({
autocomplete: this._data!.autocomplete,
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not work correctly in a future release. We plan to lock down the setup APIs to only be callable during the setup phase. If you just need data.autocomplete.getQuerySuggestions, that is also available on start.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I guess in general, I'm not sure why these initializers are called in start rather than setup? Seems like it all depends on setup APIs?

Copy link
Contributor

@shahzad31 shahzad31 May 14, 2020

Choose a reason for hiding this comment

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

this can perhaps be moved inside component by using useKibana hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshdover can you have a look at e5a1eb3 when you've got a chance? I've moved the registration back to setup and removed instance fields for setup APIs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, that looks better 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshdover I'm actually actively working on resolving more issues with this branch, but they're related to alerting. One thing we need is core.services.application.getUrlForApp from CoreStart. I've moved this back to start, but triggers_actions_ui is available on the start plugins param, and autocomplete is available as well (like you've mentioned).

I'm not referencing anything from setup now though. Can you verify this is still ok? I think once we've ironed that out it should be the end of platform-specific concerns. bf16f6a

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should reconsider how this whole thing is designed. Why is that the Redux store needs to exist at all? Is it possible we could decouple the UI from the store to make it more portable?

@kibanamachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/plugins/uptime/public/lib/alert_types/__tests__.monitor status alert type validate doesn't throw on empty set

Link to Jenkins

Standard Out

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


Stack Trace

Error: expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: ` 1`

- Snapshot
+ Received

@@ -16,8 +16,8 @@
        }
      }
    >
      <MonitorStatusTitle />
    </Provider>,
-   "requiresAppContext": true,
+   "requiresAppContext": false,
    "validate": [Function],
  }
    at Suite.describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/uptime/public/lib/alert_types/__tests__/monitor_status.test.ts:180:7)
    at addSpecsToSuite (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/Env.js:496:51)
    at Env.describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/Env.js:466:11)
    at describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js:81:18)
    at Suite.Object.<anonymous>.describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/uptime/public/lib/alert_types/__tests__/monitor_status.test.ts:168:3)
    at addSpecsToSuite (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/Env.js:496:51)
    at Env.describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/Env.js:466:11)
    at describe (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmine/jasmineLight.js:81:18)
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/uptime/public/lib/alert_types/__tests__/monitor_status.test.ts:9:1)
    at Runtime._execModule (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runtime/build/index.js:867:68)
    at Runtime._loadModule (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runtime/build/index.js:577:12)
    at Runtime.requireModule (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runtime/build/index.js:433:10)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:202:13
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:27:24)
    at _next (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:47:9)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:52:7
    at new Promise (<anonymous>)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:44:12
    at jasmine2 (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/index.js:60:19)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:385:24
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:161:24)
    at _next (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:181:9)

Kibana Pipeline / kibana-xpack-agent / X-Pack Endpoint Functional Tests.x-pack/test/functional_endpoint/apps/endpoint/policy_list·ts.endpoint When on the Endpoint Policy List and policies exists "before all" hook for "should show policy on the list"

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 6 times on tracked branches: https://github.com/elastic/kibana/issues/66579

[00:00:00]       │
[00:00:00]         └-: endpoint
[00:00:00]           └-> "before all" hook
[00:01:20]           └-: When on the Endpoint Policy List
[00:01:20]             └-> "before all" hook
[00:01:20]             └-> "before all" hook
[00:01:20]               │ debg navigateToActualUrl http://localhost:6181/app/endpoint/policy
[00:01:20]               │ debg browser[INFO] http://localhost:6181/app/endpoint/policy?_t=1589584851358 341 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:01:20]               │
[00:01:20]               │ debg browser[INFO] http://localhost:6181/bundles/app/core/bootstrap.js 10:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:01:20]               │ debg currentUrl = http://localhost:6181/app/endpoint/policy
[00:01:20]               │          appUrl = http://localhost:6181/app/endpoint/policy
[00:01:20]               │ debg TestSubjects.find(kibanaChrome)
[00:01:20]               │ debg Find.findByCssSelector('[data-test-subj="kibanaChrome"]') with timeout=60000
[00:01:24]             └-> loads the Policy List Page
[00:01:24]               └-> "before each" hook: global before each
[00:01:24]                 │ debg browser[INFO] http://localhost:6181/33208/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js 380:106115 "INFO: 2020-05-15T23:20:54Z
[00:01:24]                 │        Adding connection to http://localhost:6181/elasticsearch
[00:01:24]                 │
[00:01:24]                 │      "
[00:01:24]               │ debg TestSubjects.exists(policyListPage)
[00:01:24]               │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="policyListPage"]') with timeout=120000
[00:01:24]               └- ✓ pass  (31ms) "endpoint When on the Endpoint Policy List loads the Policy List Page"
[00:01:24]             └-> displays page title
[00:01:24]               └-> "before each" hook: global before each
[00:01:24]               │ debg TestSubjects.getVisibleText(pageViewHeaderLeftTitle)
[00:01:24]               │ debg TestSubjects.find(pageViewHeaderLeftTitle)
[00:01:24]               │ debg Find.findByCssSelector('[data-test-subj="pageViewHeaderLeftTitle"]') with timeout=10000
[00:01:24]               └- ✓ pass  (33ms) "endpoint When on the Endpoint Policy List displays page title"
[00:01:24]             └-> shows policy count total
[00:01:24]               └-> "before each" hook: global before each
[00:01:24]               │ debg TestSubjects.getVisibleText(policyTotalCount)
[00:01:24]               │ debg TestSubjects.find(policyTotalCount)
[00:01:24]               │ debg Find.findByCssSelector('[data-test-subj="policyTotalCount"]') with timeout=10000
[00:01:24]               └- ✓ pass  (104ms) "endpoint When on the Endpoint Policy List shows policy count total"
[00:01:24]             └-> has correct table headers
[00:01:24]               └-> "before each" hook: global before each
[00:01:24]               │ debg TestSubjects.find(policyTable)
[00:01:24]               │ debg Find.findByCssSelector('[data-test-subj="policyTable"]') with timeout=10000
[00:01:24]               └- ✓ pass  (52ms) "endpoint When on the Endpoint Policy List has correct table headers"
[00:01:24]             └-> should show empty table results message
[00:01:24]               └-> "before each" hook: global before each
[00:01:24]               │ debg TestSubjects.exists(policyTable)
[00:01:24]               │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="policyTable"]') with timeout=2500
[00:01:24]               │ debg TestSubjects.find(policyTable)
[00:01:24]               │ debg Find.findByCssSelector('[data-test-subj="policyTable"]') with timeout=10000
[00:01:24]               └- ✓ pass  (57ms) "endpoint When on the Endpoint Policy List should show empty table results message"
[00:01:24]             └-: and policies exists
[00:01:24]               └-> "before all" hook
[00:01:24]               └-> "before all" hook
[00:01:24]                 │ info [o.e.x.s.a.r.TransportPutRoleAction] [kibana-ci-immutable-oraclelinux-tests-xl-1589577157722793984] added role [fleet_enroll]
[00:01:24]                 │ info [o.e.x.s.a.u.TransportPutUserAction] [kibana-ci-immutable-oraclelinux-tests-xl-1589577157722793984] added user [fleet_enroll]
[00:01:28]                 │ info Taking screenshot "/dev/shm/workspace/kibana/x-pack/test/functional/screenshots/failure/endpoint When on the Endpoint Policy List and policies exists _before all_ hook.png"
[00:01:28]                 │ proc [kibana]  error  [23:20:59.098]  Error: Internal Server Error
[00:01:28]                 │ proc [kibana]     at HapiResponseAdapter.toError (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:132:19)
[00:01:28]                 │ proc [kibana]     at HapiResponseAdapter.toHapiResponse (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:86:19)
[00:01:28]                 │ proc [kibana]     at HapiResponseAdapter.handle (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:81:17)
[00:01:28]                 │ proc [kibana]     at Router.handle (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/router.js:160:34)
[00:01:28]                 │ proc [kibana]     at process._tickCallback (internal/process/next_tick.js:68:7)
[00:01:28]                 │ info Current URL is: http://localhost:6181/app/endpoint/policy
[00:01:28]                 │ info Saving page source to: /dev/shm/workspace/kibana/x-pack/test/functional/failure_debug/html/endpoint When on the Endpoint Policy List and policies exists _before all_ hook.html
[00:01:28]                 └- ✖ fail: "endpoint When on the Endpoint Policy List and policies exists "before all" hook for "should show policy on the list""
[00:01:28]                 │

Stack Trace

Error: expected 200 "OK", got 500 "Internal Server Error"
    at Test._assertStatus (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test._assertFunction (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:131:12)
    at /dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:718:3)
    at parser (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Kibana Pipeline / kibana-xpack-agent / X-Pack Endpoint Functional Tests.x-pack/test/functional_endpoint/apps/endpoint/policy_list·ts.endpoint When on the Endpoint Policy List and policies exists "before all" hook for "should show policy on the list"

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 6 times on tracked branches: https://github.com/elastic/kibana/issues/66579

[00:00:00]       │
[00:00:00]         └-: endpoint
[00:00:00]           └-> "before all" hook
[00:01:31]           └-: When on the Endpoint Policy List
[00:01:31]             └-> "before all" hook
[00:01:31]             └-> "before all" hook
[00:01:31]               │ debg navigateToActualUrl http://localhost:6181/app/endpoint/policy
[00:01:32]               │ debg browser[INFO] http://localhost:6181/app/endpoint/policy?_t=1589582298511 341 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:01:32]               │
[00:01:32]               │ debg browser[INFO] http://localhost:6181/bundles/app/core/bootstrap.js 10:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:01:32]               │ debg currentUrl = http://localhost:6181/app/endpoint/policy
[00:01:32]               │          appUrl = http://localhost:6181/app/endpoint/policy
[00:01:32]               │ debg TestSubjects.find(kibanaChrome)
[00:01:32]               │ debg Find.findByCssSelector('[data-test-subj="kibanaChrome"]') with timeout=60000
[00:01:35]             └-> loads the Policy List Page
[00:01:35]               └-> "before each" hook: global before each
[00:01:36]                 │ debg browser[INFO] http://localhost:6181/33208/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js 380:106115 "INFO: 2020-05-15T22:38:22Z
[00:01:36]                 │        Adding connection to http://localhost:6181/elasticsearch
[00:01:36]                 │
[00:01:36]                 │      "
[00:01:36]               │ debg TestSubjects.exists(policyListPage)
[00:01:36]               │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="policyListPage"]') with timeout=120000
[00:01:36]               └- ✓ pass  (138ms) "endpoint When on the Endpoint Policy List loads the Policy List Page"
[00:01:36]             └-> displays page title
[00:01:36]               └-> "before each" hook: global before each
[00:01:36]               │ debg TestSubjects.getVisibleText(pageViewHeaderLeftTitle)
[00:01:36]               │ debg TestSubjects.find(pageViewHeaderLeftTitle)
[00:01:36]               │ debg Find.findByCssSelector('[data-test-subj="pageViewHeaderLeftTitle"]') with timeout=10000
[00:01:36]               └- ✓ pass  (51ms) "endpoint When on the Endpoint Policy List displays page title"
[00:01:36]             └-> shows policy count total
[00:01:36]               └-> "before each" hook: global before each
[00:01:36]               │ debg TestSubjects.getVisibleText(policyTotalCount)
[00:01:36]               │ debg TestSubjects.find(policyTotalCount)
[00:01:36]               │ debg Find.findByCssSelector('[data-test-subj="policyTotalCount"]') with timeout=10000
[00:01:36]               └- ✓ pass  (95ms) "endpoint When on the Endpoint Policy List shows policy count total"
[00:01:36]             └-> has correct table headers
[00:01:36]               └-> "before each" hook: global before each
[00:01:36]               │ debg TestSubjects.find(policyTable)
[00:01:36]               │ debg Find.findByCssSelector('[data-test-subj="policyTable"]') with timeout=10000
[00:01:36]               └- ✓ pass  (39ms) "endpoint When on the Endpoint Policy List has correct table headers"
[00:01:36]             └-> should show empty table results message
[00:01:36]               └-> "before each" hook: global before each
[00:01:36]               │ debg TestSubjects.exists(policyTable)
[00:01:36]               │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="policyTable"]') with timeout=2500
[00:01:36]               │ debg TestSubjects.find(policyTable)
[00:01:36]               │ debg Find.findByCssSelector('[data-test-subj="policyTable"]') with timeout=10000
[00:01:36]               └- ✓ pass  (68ms) "endpoint When on the Endpoint Policy List should show empty table results message"
[00:01:36]             └-: and policies exists
[00:01:36]               └-> "before all" hook
[00:01:36]               └-> "before all" hook
[00:01:36]                 │ info [o.e.x.s.a.r.TransportPutRoleAction] [kibana-ci-immutable-oraclelinux-tests-xl-1589577157722793984] added role [fleet_enroll]
[00:01:36]                 │ info [o.e.x.s.a.u.TransportPutUserAction] [kibana-ci-immutable-oraclelinux-tests-xl-1589577157722793984] added user [fleet_enroll]
[00:01:40]                 │ info Taking screenshot "/dev/shm/workspace/kibana/x-pack/test/functional/screenshots/failure/endpoint When on the Endpoint Policy List and policies exists _before all_ hook.png"
[00:01:40]                 │ proc [kibana]  error  [22:38:27.346]  Error: Internal Server Error
[00:01:40]                 │ proc [kibana]     at HapiResponseAdapter.toError (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:132:19)
[00:01:40]                 │ proc [kibana]     at HapiResponseAdapter.toHapiResponse (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:86:19)
[00:01:40]                 │ proc [kibana]     at HapiResponseAdapter.handle (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/response_adapter.js:81:17)
[00:01:40]                 │ proc [kibana]     at Router.handle (/dev/shm/workspace/install/kibana-8/src/core/server/http/router/router.js:160:34)
[00:01:40]                 │ proc [kibana]     at process._tickCallback (internal/process/next_tick.js:68:7)
[00:01:41]                 │ info Current URL is: http://localhost:6181/app/endpoint/policy
[00:01:41]                 │ info Saving page source to: /dev/shm/workspace/kibana/x-pack/test/functional/failure_debug/html/endpoint When on the Endpoint Policy List and policies exists _before all_ hook.html
[00:01:41]                 └- ✖ fail: "endpoint When on the Endpoint Policy List and policies exists "before all" hook for "should show policy on the list""
[00:01:41]                 │

Stack Trace

Error: expected 200 "OK", got 500 "Internal Server Error"
    at Test._assertStatus (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test._assertFunction (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:131:12)
    at /dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:718:3)
    at parser (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

History

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

@shahzad31
Copy link
Contributor

this is not needed anymore

@shahzad31 shahzad31 closed this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uptime alerts aren't editable in Alerting Management UI
5 participants