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

services/horizon: Purging log.Fatal, to make horizon CLI easier to test. #3766

Merged

Conversation

paulbellamy
Copy link
Contributor

@paulbellamy paulbellamy commented Jul 13, 2021

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Remove log.Fatal and os.Exit calls from Horizon.

  • log.Fatal and os.Exit should only be called in func main(), and func init().
  • Everything else which could fail returns an error, which propagates up to func main()

Why

As discussed in #3741 (comment), using log.Fatal and os.Exit make integration testing Horizon harder. They force you to launch it as a subprocess and faff around with managing that. Removing these should make it simpler.

Reducing friction for CLI-type tests would have helped catch #3762 type bugs sooner/easier.

Known limitations

[WIP] at this point, as I want to get people's opinions, and if there are any gotchas to watch out for here before spending more time on this. If we're happy with the approach we should merge #3741 as-is, then use this to simplify it, and add a few more cli tests.

The one big outstanding thing here re: testing are the places we use os.Getenv. But.. One thing at a time.

@paulbellamy paulbellamy requested a review from a team July 13, 2021 17:21
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

Bit of a Catch-22 here: can't write CLI tests without this refactor, can't test this refactor without CLI tests! Everything seems pretty straightforward aside from the WaitGroup changes, though. My vote is to get this in really early into a sprint so that we can all interact with it a bunch throughout.

@2opremio
Copy link
Contributor

I am in favor of this.

My only concern: could this have any negative operational implications? (e.g. the monitoring system not catching bad restarts anymore because the failure wasn't logged as expected)

@paulbellamy
Copy link
Contributor Author

Yeah, we'll need to be super careful not to change error output messages too much with this. Good call.

Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

LGTM

@paulbellamy paulbellamy force-pushed the paulb/cmd_integration_testing branch 4 times, most recently from 81ce7e7 to e9ecc08 Compare August 3, 2021 14:12
@paulbellamy paulbellamy force-pushed the paulb/cmd_integration_testing branch 2 times, most recently from fc5f184 to 6ec2579 Compare August 3, 2021 15:01
@paulbellamy paulbellamy force-pushed the paulb/cmd_integration_testing branch from 6ec2579 to d297418 Compare August 3, 2021 15:16
@paulbellamy paulbellamy changed the title services/horizon: [WIP] Purging log.Fatal, to make horizon CLI easier to test. services/horizon: Purging log.Fatal, to make horizon CLI easier to test. Aug 3, 2021
@paulbellamy paulbellamy marked this pull request as ready for review August 3, 2021 16:52
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

This will be great for param testing 😍. Get someone else's ✔️ though heh.

@paulbellamy paulbellamy merged commit cf4f0d2 into stellar:master Aug 5, 2021
@paulbellamy paulbellamy deleted the paulb/cmd_integration_testing branch August 5, 2021 15:59
tamirms pushed a commit that referenced this pull request Aug 20, 2021
…st. (#3766)

* Purging os.Exit and log.Fatal from horizon/cmd

- Purging fatals from flags

* Passing back flag fail errors to see if that impacts integration tests

* Return the right error from tick setup

* wip -- integration tests

* Fix introduced whitespace in error messages

* Better usage error handling

* Add comment warning about error behaviour of UpdateStellarCoreInfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants