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: Fix tm bench quit #2405

Merged
merged 6 commits into from
Oct 8, 2018
Merged

tools: Fix tm bench quit #2405

merged 6 commits into from
Oct 8, 2018

Conversation

bradyjoestar
Copy link
Contributor

@bradyjoestar bradyjoestar commented Sep 15, 2018

refs #2369

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

@bradyjoestar bradyjoestar changed the base branch from master to develop September 15, 2018 07:36
Copy link
Contributor

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

Thanks for contributing to Tendermint. A few changes must be made before merging. NOTE you can setup gofmt to automatically format your code in almost any popular editor https://robots.thoughtbot.com/writing-go-in-vim https://atom.io/packages/go-plus https://github.com/microsoft/vscode-go

@@ -173,3 +177,13 @@ func startTransacters(

return transacters
}

// RunForever waits for an interrupt signal and stops the node.
func catchInterrupt(transacters []*transacter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

formatting is off (please use https://golang.org/cmd/gofmt/)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised this wasn't caught by linting. We should probably consider adding a second step then, like we do in the SDK, to make sure gofmt is correct.


// RunForever waits for an interrupt signal and stops the node.
func catchInterrupt(transacters []*transacter) {
// Sleep forever and then...
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove (comment is useless)

func catchInterrupt(transacters []*transacter) {
// Sleep forever and then...
cmn.TrapSignal(func() {
for _,e := range transacters {
Copy link
Contributor

Choose a reason for hiding this comment

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

e -> t

@@ -93,6 +94,9 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)

//catch Interrupt and quit tm-bench
go catchInterrupt(transacters)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove catchInterrupt altogether and just call

go cmn.TrapSignal(func() {
  ...
}

why need in intermediate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review! All was done according to your nice advice.

@@ -93,6 +94,13 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)

//catch Interrupt and quit tm-bench
go cmn.TrapSignal(func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't seem advisable to further use this method, it logs uncontrolled and the functionality is simple enough that it could be copied as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do agree, but I think we can remove all the cmn.TrapSignals at once in a separate PR.

Its already written, who knows when we're going to get to deleting / refactoring the trap signal logic.

@codecov-io
Copy link

Codecov Report

Merging #2405 into develop will decrease coverage by 0.02%.
The diff coverage is 0%.

@@             Coverage Diff             @@
##           develop    #2405      +/-   ##
===========================================
- Coverage    60.99%   60.96%   -0.03%     
===========================================
  Files          197      197              
  Lines        16313    16320       +7     
===========================================
  Hits          9950     9950              
- Misses        5496     5505       +9     
+ Partials       867      865       -2
Impacted Files Coverage Δ
tools/tm-bench/main.go 0% <0%> (ø) ⬆️
blockchain/reactor.go 39.1% <0%> (-0.34%) ⬇️
consensus/reactor.go 72.75% <0%> (-0.27%) ⬇️
p2p/pex/pex_reactor.go 74.33% <0%> (+0.33%) ⬆️
blockchain/pool.go 66.43% <0%> (+0.69%) ⬆️

@@ -93,6 +95,19 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)

//catch Interrupt and quit tm-bench
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this comment is needed

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed or have proper form of: Catch interrupt and quit.

xla
xla previously requested changes Sep 20, 2018
Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

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

Some style and functional changes needed.

@@ -12,6 +12,8 @@ import (

"github.com/tendermint/tendermint/libs/log"
tmrpc "github.com/tendermint/tendermint/rpc/client"
"os/signal"
"syscall"
Copy link
Contributor

Choose a reason for hiding this comment

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

Import order is as follows:

import (
	// stdlib
	
	// external packages
	
	// internal packages
)

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can capture this in the linter ?!

Copy link
Contributor

Choose a reason for hiding this comment

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

I wrote this so many times by now, was wondering the same.

@@ -93,6 +95,19 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)

//catch Interrupt and quit tm-bench
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed or have proper form of: Catch interrupt and quit.

@@ -93,6 +95,19 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)

//catch Interrupt and quit tm-bench
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be moved up, before the first side-effectful call on line 86. It also doesn't need to be wrapped in a goroutine entirely, only the part which ranges over the channel.

for _, t := range transacters {
t.Stop()
}
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it an error if the user quits on purpose? Would challenge that and rethink if the binary exit with an error code.

@xla
Copy link
Contributor

xla commented Sep 25, 2018

@bradyjoestar Gentle ping on this. Would you be able to address the latest comments? Then it should be good to go.

@xla xla self-assigned this Sep 25, 2018
@xla xla added T:enhancement Type: Enhancement tools labels Sep 25, 2018
@xla xla changed the title Fix tm bench quit tools: Fix tm bench quit Sep 25, 2018
@melekes melekes dismissed xla’s stale review October 8, 2018 07:05

I'll address comments in a separate PR

@melekes melekes merged commit 4c0c6e0 into tendermint:develop Oct 8, 2018
melekes added a commit that referenced this pull request Oct 8, 2018
xla pushed a commit that referenced this pull request Oct 8, 2018
* specify time unit for FlushThrottleTimeout in TestP2PConfig
Refs #2555
* [tm-bench] refactor code
#2405 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:enhancement Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants