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

Upgrade Assistant to New Platform Ready #50163

Merged
merged 16 commits into from
Nov 20, 2019

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Nov 11, 2019

Summary

Part of the refactoring of ES settings plugins to NP ready, this contribution updates Upgrade Assistant by:

Public

  • Moving to NP folder
  • Refactoring all ui/... dependency away and replacing with React Context where needed

Server

  • Moving to NP folder
  • Refactoring of Server to ServerShim and Request to RequestShim.
  • Refactor to use NP router!

@jloleysens jloleysens requested a review from rudolf November 11, 2019 15:24
@jloleysens jloleysens requested a review from a team as a code owner November 11, 2019 15:24
@jloleysens jloleysens added Feature:Upgrade Assistant release_note:roadmap roadmap Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.6.0 v8.0.0 labels Nov 11, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

SCSS review: Mostly file moves and removing ./ from paths. I did find one inherited problem that would be nice to fix in this PR. But otherwise, LGTM

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

…skip ci]

* upstream/master:
  Move table-list-view to kibana-react (elastic#50046)
  [ML] Stats bar for data frame analytics (elastic#49464)
  [ML] Make navigation in tests more stable (elastic#50132)
  Migrate authorization subsystem to the new platform.  (elastic#46145)
  Bugfix: Interpreter conversion of string to number should throw on NaN elastic#27788 (elastic#50063)
  Update dependency @elastic/charts to v14 (elastic#49947)
  [ML] Adding cloud specific ML node warning (elastic#50139)
  Fixing bugs in the Shareable Runtime (elastic#49965)
  Revert router base name for Uptime plugin to use hash in default path. (elastic#50095)
  Ability to have telemetry always opted in (elastic#49798)
  Add "Get Help" and "Kibana Feedback" links to the help popover (elastic#49797)
  Removes references to Elasticsearch mapping types (elastic#47610)
  [skip-ci] Replace coordinate map in Kibana getting started docs with Maps (elastic#50167)
  [ML] Indicate missing required privileges for import in File Data Viz (elastic#50147)
  [SIEM][Detection Engine] Removes technical debt and minor bug fixes (elastic#50111)
@elasticmachine
Copy link
Contributor

💔 Build Failed

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

merge conflict between base and head

* upstream/master:
  Remove internal platform types exports (elastic#50427)
  [APM] Document `apm_oss.metricsIndices` and `apm_oss.sourcemap… (elastic#50312)
  [Telemetry] Server side fetcher (elastic#50015)
  [SIEM] Detection engine placeholders (elastic#50220)
  [Uptime] Donut chart loader position centered vertically  (elastic#50219)
  update telemetry banner notice text (elastic#50403)
  Fix aborting when searching without batching (elastic#49966)
  [Telemetry] Remove telemetry splash page and add conditional messaging (elastic#50189)
  Revert chromedriver update (elastic#50324)
  Remove deprecated argument include_type_name from ES calls (elastic#50285)
  [Maps] add settings to maps telemetry (elastic#50161)
  remove visualize loader (elastic#46910)
  Fix misuse of react-router and react-router-dom (elastic#50120)
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

* 'master' of github.com:elastic/kibana: (27 commits)
  [Rollup] Fix for clone job workflow (elastic#50501)
  Empty message "No data available" for Labels and User metadata sections missing (elastic#49846)
  [APM] Duration by Country map doesn't take `transactionName` into account (elastic#50315)
  Remove react references from core `Notifications` apis (elastic#49573)
  Updated APM Indices endpoints to use the SavedObjectsClient from the legacy request context, and set the apm-indices schema object to be namspace-agnostic
  [Metrics UI] Calculate interval based on the dataset's period (elastic#50194)
  chore(NA): add new platform discovered plugins as entry points to check for dependencies on clean dll tasks (elastic#50610)
  [Telemetry] change of optin status telemetry (elastic#50158)
  [SIEM][Detection Engine] REST API Additions (elastic#50514)
  [DOCS] Removes dashboard-only mode doc (elastic#50441)
  [Filters] Fix operator overflowing out popover (elastic#50030)
  Change telemetry optIn to default to true (elastic#50490)
  [Maps] make grid rectangles the default symbolization for geo grid source (elastic#50169)
  Allow registered applications to hide Kibana chrome (elastic#49795)
  Upgrade EUI to v14.9.0 (elastic#49678)
  [Metrics UI] Convert layouts to use React components (elastic#49134)
  [Search service] Add support for ES request preference (elastic#49424)
  [Newsfeed/Lint] fix chained fn lint (elastic#50515)
  [Monitoring] Fix logstash pipelines page in multi-cluster environment (elastic#50166)
  [SIEM] Events viewer fixes (elastic#50175)
  ...
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

Left a couple of comments but overall looks good. Switching out the axios client and consuming more NP API's on the server-side could definitely be done as a separate PR.

@jloleysens jloleysens requested a review from rudolf November 20, 2019 09:42
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

Like we discussed, I think core should make it easier to test your controllers in an isolated way, but they way you've set it up here gets us really far in terms of testing the controller's glue logic.

method: 'GET',
options: {
pre: [EsVersionPrecheck],
server.router.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Because this mixes NP and legacy dependencies and the parameter/type is called server it's non-obvious from reading the code if you're using legacy, a shimmed facade or NP API's here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that was partly the objective here 😅 . Ultimately this code shouldn't have to change much down the line.

Comment on lines -111 to -121
it('returns a 426 if EsVersionCheck throws', async () => {
(EsVersionPrecheck.method as jest.Mock).mockRejectedValue(
new Boom(`blah`, { statusCode: 426 })
);

const resp = await server.inject({
method: 'GET',
url: '/api/upgrade_assistant/status',
});
const resp = await serverShim.router.getHandler({
method: 'get',
pathPattern: '/api/upgrade_assistant/status',
})(ctxMock, createRequestMock(), kibanaResponseFactory);

expect(resp.statusCode).toEqual(426);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it worth keeping this, otherwise you're not testing if your versionCheckHandlerWrapper was applied, seems like you should be able to keep this test with your "test harness".

Copy link
Contributor Author

@jloleysens jloleysens Nov 20, 2019

Choose a reason for hiding this comment

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

So I'm specifically opting out of the wrapper using the jest mock above like:

jest.mock('../lib/es_version_precheck', () => ({
  versionCheckHandlerWrapper: (a: any) => a,
}));

The bulk of the wrapper logic should be covered by es_version_precheck.test.ts. But I hear what you're saying it would be nice to test them in concert but I think since the wrapper is so thin it didn't merit a full mock out.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@rudolf
Copy link
Contributor

rudolf commented Nov 20, 2019

I've created #51150 for enabling testing of controller logic.

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jloleysens jloleysens merged commit d035539 into elastic:master Nov 20, 2019
@jloleysens jloleysens deleted the np-migration/ua branch November 20, 2019 12:17
@Bamieh
Copy link
Member

Bamieh commented Nov 27, 2019

@jloleysens This PR should be backported to 7.x correct? My backport had merge conflicts in the upgrade_assistant directory so i've checked out my changes on top of master: #51787

Can you double check if those changes are correct please?

jloleysens added a commit to jloleysens/kibana that referenced this pull request Nov 27, 2019
* - Public NP Shim done
- Reviving app + tests wip

* Update components to consume via context and props instead of imports (tests working again)

* Moved server files to np_ready dir, updated paths and introduced ServerShim and RequestShim

* Removed unused comments
Fixed use of legacy server components

* Fix typings and add app context where needed

* getSavedObjectsClient may be null, specifically during tests

* Move styles for _index.scss file -> more specific file

* Fix typings issue [skip ci]

* Migrate to NP router
@jloleysens
Copy link
Contributor Author

jloleysens commented Nov 27, 2019

@Bamieh and I discussed offline what approach we would take for the UA backport.

His PR for the backport is here: #51787
The backport for this PR is here: #51810

jloleysens added a commit that referenced this pull request Dec 4, 2019
* Upgrade Assistant to New Platform Ready (#50163)

* - Public NP Shim done
- Reviving app + tests wip

* Update components to consume via context and props instead of imports (tests working again)

* Moved server files to np_ready dir, updated paths and introduced ServerShim and RequestShim

* Removed unused comments
Fixed use of legacy server components

* Fix typings and add app context where needed

* getSavedObjectsClient may be null, specifically during tests

* Move styles for _index.scss file -> more specific file

* Fix typings issue [skip ci]

* Migrate to NP router

* Removed legacy app.tsx

* APM changes to NP

* More defensive use of SemVer

* Update copy and include apm_oss plugin in 7.x server shim

* Update expected message in spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration Feature:Upgrade Assistant roadmap Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants