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

Refactor HttpService tests #53033

Merged
merged 7 commits into from
Dec 19, 2019
Merged

Conversation

joshdover
Copy link
Contributor

@joshdover joshdover commented Dec 13, 2019

Summary

Follow up from #52434, this PR cleans up the HttpService more with these changes:

  • Splits out unit tests to separate files, targeted at the correct unit under test
  • Refactors the structure of the HttpService class to better match Core's conventions
  • Splits out the loadingCount functionality and tests to a separate sub-service
  • Removes some duplicate tests from HttpService & BasePath

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.
(https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)

For maintainers

@joshdover joshdover force-pushed the np/http-refactor-tests branch 2 times, most recently from 6bc8be7 to 6945a1a Compare December 13, 2019 21:35
stop(): Promise<void>;
setup(...params: any[]): TSetup | Promise<TSetup>;
start(...params: any[]): TStart | Promise<TStart>;
stop(): void | Promise<void>;
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 made this change to avoid making HttpService async and breaking a test utility that is used in quite a few places. I can also move this to a separate PR if we think that is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's alright and that it's actually closer to the various services implementations

@joshdover joshdover added Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.6.0 labels Dec 13, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@joshdover joshdover marked this pull request as ready for review December 13, 2019 21:39
@joshdover joshdover requested a review from a team as a code owner December 13, 2019 21:39
@joshdover joshdover requested a review from a team December 13, 2019 21:39
@joshdover joshdover requested review from a team as code owners December 13, 2019 21:39
Copy link
Member

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

APM changes LGTM 👍

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

@elastic/kibana-app-arch team changes include rename of HttpServiceBase to HttpSetup.
Added 1 comment about replacing it with HttpStart

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

APM changes lgtm

@joshdover joshdover force-pushed the np/http-refactor-tests branch 3 times, most recently from 0237996 to 18f0096 Compare December 16, 2019 23:14
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

Great cleanup imho. Most of my comments are on existing code and not directly related to the PR changes.

Comment on lines +61 to +62
public start(deps: HttpDeps) {
return this.setup(deps);
Copy link
Contributor

Choose a reason for hiding this comment

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

(Probably a NIT) we are executing twice the setup code by doing this, instead of once by storing as it was done before. The overheat is minimal (for now), but is there any upside on this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary, but it's (very slightly) more consistent with how other services work.

Comment on lines 549 to 550
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "LoadingCountSetup"
addLoadingCount: LoadingCountSetup['addLoadingCount'];
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: this is why I think we should stop using the Internal[XXX] and actually make the 'effort' of adding proper public interfaces for all exported contracts. This is additional boilerplate I agree, but we will need them anyway when we'll cleanup the documentation.

This is a shame our doc generator is not able to properly 'replace' this kind of definition on the fly though.

Copy link
Contributor Author

@joshdover joshdover Dec 17, 2019

Choose a reason for hiding this comment

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

This is a shame our doc generator is not able to properly 'replace' this kind of definition on the fly though.

I agree. I think part of the complexity of building a tool that does this is knowing when to show the resolved type and when to show a link to a different page.

For now, I'll switch this to put the documented definition on the HttpSetup interface and duplicate it on the LoadingCountSetup interface.

stop(): Promise<void>;
setup(...params: any[]): TSetup | Promise<TSetup>;
start(...params: any[]): TStart | Promise<TStart>;
stop(): void | Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's alright and that it's actually closer to the various services implementations

@joshdover joshdover force-pushed the np/http-refactor-tests branch from 18f0096 to 4bc4c51 Compare December 17, 2019 23:46
@joshdover joshdover requested a review from a team as a code owner December 17, 2019 23:46
@joshdover joshdover requested a review from pgayvallet December 17, 2019 23:46
@joshdover joshdover force-pushed the np/http-refactor-tests branch from 4bc4c51 to 8c378ca Compare December 18, 2019 19:22
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

  • 💚 Build #16309 succeeded 4bc4c51f207d76665b9dd814799db9e3b1937ed4
  • 💔 Build #15945 failed 18f00968892a55622fdd225bdd676d754c942b50
  • 💔 Build #15890 failed 0237996d66cd036ab2ecfa43daa7502e0efd3f0b
  • 💔 Build #15541 failed 6945a1adfc2f051755f088022ed0390064dc75af
  • 💔 Build #15526 failed 6bc8be755a9d1e2434c735a2a675e80694bffea4

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

@joshdover
Copy link
Contributor Author

Merging without approval from other teams since it's just a type rename.

@joshdover joshdover merged commit 4980387 into elastic:master Dec 19, 2019
@joshdover joshdover deleted the np/http-refactor-tests branch December 19, 2019 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants