Skip to content

AP-490: Finalize federated service check and add integration tests#1308

Merged
justinanastos merged 14 commits intomasterfrom
justin/federated-service-check
Jun 13, 2019
Merged

AP-490: Finalize federated service check and add integration tests#1308
justinanastos merged 14 commits intomasterfrom
justin/federated-service-check

Conversation

@justinanastos
Copy link
Copy Markdown
Contributor

@justinanastos justinanastos commented May 30, 2019

Review this PR commit-by-commit

This PR:

  • Adds integration tests for service:check
    • Input: CLI commands being run as a user would run them
    • Background: Mock network calls with nock
    • Measure: Compare expected CLI output. This includes titles and status being modified as commands are run
  • Add federated service check functionality
    • Replace --federated flag in place of implying federated behavior with --serviceName
    • Also adds integration test
    • --markdown and --json are not supported; but that's coming soon.

When creating new responses, use nock's recorder functionality (https://github.com/nock/nock#recording). We made the request matching only check the query name so the code would be less brittle.

TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests \o/
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Document nock recorder functionality :)

@justinanastos justinanastos force-pushed the justin/federated-service-check branch 15 times, most recently from 7ab8e9f to 95f4245 Compare June 6, 2019 15:11
@justinanastos justinanastos marked this pull request as ready for review June 6, 2019 15:25
@justinanastos justinanastos changed the title WIP: Fix federated service check Finalize federated service check and add integration tests Jun 6, 2019
Comment thread packages/apollo/src/commands/service/check.ts Outdated
@justinanastos justinanastos force-pushed the justin/federated-service-check branch from 95f4245 to a450348 Compare June 6, 2019 15:35
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts Outdated
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts Outdated
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts
Comment thread packages/apollo/src/commands/service/check.ts Outdated
Comment thread packages/apollo/src/commands/service/check.ts
Comment thread packages/apollo/src/commands/service/check.ts
Comment thread packages/apollo/src/commands/service/check.ts Outdated
Comment thread packages/apollo/src/commands/service/check.ts
@justinanastos justinanastos changed the title Finalize federated service check and add integration tests AP-490: Finalize federated service check and add integration tests Jun 6, 2019
Copy link
Copy Markdown
Contributor

@evans evans left a comment

Choose a reason for hiding this comment

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

Some suggestions for to improve the usability and maintainability. Quite possible that some aren't possible in the existing world.

Comment thread packages/apollo/src/commands/service/check.ts Outdated
Comment thread packages/apollo/src/commands/service/check.ts Outdated
throw new Error("No SDL found for federated service");
}

task.output = `Attempting to compose graph with ${chalk.blue(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be great to have some diagnostic information about how many other services are included in the composition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unloaded question: why do you think this is important @evans ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good question! I think it's a nice to have, which would indicate how much work apollo is doing and a nice way for users to understand that the command is working as intended

Comment thread packages/apollo/src/commands/service/check.ts
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts Outdated
Comment thread packages/apollo/src/commands/service/check.ts Outdated
@justinanastos justinanastos force-pushed the justin/federated-service-check branch from a450348 to ef31e2a Compare June 11, 2019 16:27
@justinanastos justinanastos requested review from evans and trevor-scheer and removed request for evans June 11, 2019 16:27
Comment thread packages/apollo/README.md
Comment thread packages/apollo/src/commands/service/__tests__/check.test.ts
I left a few small ones that won't be changing. There's a bug right now
causing inline snapshots to not be mutable. Let's stick with regular
snapshots until we resolve that.
This only appears in tests when we capture stdout. We don't want the times in our tests!
We shouldn't be forcing a type cast; we should instead check and guarantee
the type.
`configName` is ambiguous in the world where we're now considering the
result of composition a "graph" and the partial schemas that comprise a
federated graph "service."
We'll use this to capture stdout in our integration tests. This library was
chosen only because `@oclif/test` is already using it.
Per Matt's instructions; this will also remove the `--federated` flag in
place of `--serviceName` implying federation.
Allowing Listr to chose it's own renderer can cause insidious bugs. For
example, bash and zsh will choose different renderers for tests, causing
unpredictable outputs.

1. We don't want to show a spinner in tests
2. We want to see individual changes to titles and output lines; this is
   accomplished with the verbose renderer. Note that this _must_ be
   override-able because some functions require the `silent` renderer.
   See https://github.com/SamVerschueren/listr#renderer
@justinanastos justinanastos force-pushed the justin/federated-service-check branch from ef31e2a to a12eab0 Compare June 12, 2019 19:35
@justinanastos justinanastos merged commit 2a9a75d into master Jun 13, 2019
@justinanastos justinanastos deleted the justin/federated-service-check branch June 13, 2019 14:53
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.

3 participants