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

tools/horizon-cmp: Remove unnecessary panics, update temp folder names #1947

Merged
merged 3 commits into from
Nov 21, 2019

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented Nov 18, 2019

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

Removes unnecessary panics that stop execution of the app and changes the temp results folder name.

Why

Very often developers run horizon-cmp over the night. It's important that it continues running when unexpected scenarios occur. This commit also changes the temp results folder name to be more readable (date vs unix timestamp).

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Couple questions and a suggestion about the temp folder name.

@@ -32,6 +33,7 @@ var removeRegexps = []*regexp.Regexp{
// regexp.MustCompile(`\s*"transaction_count": [0-9]+,`),
// regexp.MustCompile(`\s*"last_modified_ledger": [0-9]+,`),
// regexp.MustCompile(`\s*"public_key": "G.*",`),
regexp.MustCompile(`,\s*"paging_token": ?""`),
Copy link
Member

Choose a reason for hiding this comment

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

The PR description doesn't mention changing the regexs that get used. Is this accidental? How does this relate to removing panics and the temp folder change?

Copy link
Member

Choose a reason for hiding this comment

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

I believe it's because we were missing a check. Our paging token diverged from the expected value so we're just future-proofing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is to ignore new paging_token field added in 0.23.0 that wasn't there in 0.22.1. Commented it for now and I'll think about moving all regexps to a config file.

@@ -119,7 +119,7 @@ func run(cmd *cobra.Command) {
if err != nil {
panic(err)
}
outputDir := fmt.Sprintf("%s/horizon-cmp-diff/%d", pwd, time.Now().Unix())
outputDir := fmt.Sprintf("%s/horizon-cmp-diff/%s", pwd, time.Now().Format(time.RFC3339))
Copy link
Member

@leighmcculloch leighmcculloch Nov 18, 2019

Choose a reason for hiding this comment

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

This will cause : to be in folder names which can be problematic. Technically folder names on Unix/Linux systems allow : but some situations, libraries and applications bork at it, for example a folder including : can't be included in $PATH. That specific example shouldn't be relevant here but I think it's still worth avoiding given that we know that developers don't usually think of it as a value that will show up in a valid path.

How about using this format instead with the separators removed, much of the same benefit but a safer filename:
20060102T150405Z0700

Copy link
Member

Choose a reason for hiding this comment

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

we could use - separators, would be easier to read than no separators

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed to 2006-01-02-15-04-05.

@@ -94,7 +98,7 @@ func NewResponse(domain, path string, stream bool) *Response {
}

if string(body) == "" {
panic("Empty body")
response.Body = fmt.Sprintf("Empty body [%d]", rand.Uint64())
Copy link
Member

Choose a reason for hiding this comment

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

What problem does the rand in the body help with? Why wouldn't we want just to return an empty body?

Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing it's for debugging - ties the output to a specific instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to make sure that diff is saved when both, base and test, servers somehow return empty responses (otherwise this case would be ignore). In the future, horizon-cmp should retry in such cases.

@@ -32,6 +33,7 @@ var removeRegexps = []*regexp.Regexp{
// regexp.MustCompile(`\s*"transaction_count": [0-9]+,`),
// regexp.MustCompile(`\s*"last_modified_ledger": [0-9]+,`),
// regexp.MustCompile(`\s*"public_key": "G.*",`),
regexp.MustCompile(`,\s*"paging_token": ?""`),
Copy link
Member

Choose a reason for hiding this comment

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

I believe it's because we were missing a check. Our paging token diverged from the expected value so we're just future-proofing.

@@ -119,7 +119,7 @@ func run(cmd *cobra.Command) {
if err != nil {
panic(err)
}
outputDir := fmt.Sprintf("%s/horizon-cmp-diff/%d", pwd, time.Now().Unix())
outputDir := fmt.Sprintf("%s/horizon-cmp-diff/%s", pwd, time.Now().Format(time.RFC3339))
Copy link
Member

Choose a reason for hiding this comment

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

we could use - separators, would be easier to read than no separators

@@ -94,7 +98,7 @@ func NewResponse(domain, path string, stream bool) *Response {
}

if string(body) == "" {
panic("Empty body")
response.Body = fmt.Sprintf("Empty body [%d]", rand.Uint64())
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing it's for debugging - ties the output to a specific instance

@bartekn bartekn merged commit 9da2243 into stellar:master Nov 21, 2019
@bartekn bartekn deleted the horizon-cmp-panics branch November 21, 2019 17:31
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.

4 participants