Skip to content

Commit

Permalink
goal: avoid "node successfully started" on a previously started node (a…
Browse files Browse the repository at this point in the history
…lgorand#2075)

When starting a node which is already started, two messages are show: already started and successfully started:

$ goal node start
Algorand node was already started!
Algorand node successfully started!

Only the already started message should be shown.

Also, when node restart command is given, there is a check in the code if the node was already running.
This check comes after the node was stopped, so should never return as the node is still running. But in case it does, a message is added to notify the user.
  • Loading branch information
algonautshant authored Apr 16, 2021
1 parent d585712 commit 75c12fd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/goal/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
// Node
infoNodeStart = "Algorand node successfully started!"
infoNodeAlreadyStarted = "Algorand node was already started!"
infoNodeDidNotRestart = "Algorand node did not restart. The node is still running!"
infoTryingToStopNode = "Trying to stop the node..."
infoNodeShuttingDown = "Algorand node is shutting down..."
infoNodeSuccessfullyStopped = "The node was successfully stopped."
Expand Down
21 changes: 11 additions & 10 deletions cmd/goal/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ var startCmd = &cobra.Command{
}

algodAlreadyRunning, err := nc.StartAlgod(nodeArgs)
if algodAlreadyRunning {
reportInfoln(infoNodeAlreadyStarted)
}

if err != nil {
reportErrorf(errorNodeFailedToStart, err)
} else {
reportInfoln(infoNodeStart)
if algodAlreadyRunning {
reportInfoln(infoNodeAlreadyStarted)
} else {
reportInfoln(infoNodeStart)
}
}
})
},
Expand Down Expand Up @@ -304,14 +304,15 @@ var restartCmd = &cobra.Command{
}

algodAlreadyRunning, err := nc.StartAlgod(nodeArgs)
if algodAlreadyRunning {
reportInfoln(infoNodeAlreadyStarted)
}

if err != nil {
reportErrorf(errorNodeFailedToStart, err)
} else {
reportInfoln(infoNodeStart)
if algodAlreadyRunning {
// This can never happen. In case it does, report about it.
reportInfoln(infoNodeDidNotRestart)
} else {
reportInfoln(infoNodeStart)
}
}
})
},
Expand Down
17 changes: 17 additions & 0 deletions test/e2e-go/cli/goal/expect/goalNodeTest.exp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ if { [catch {
# Start node
::AlgorandGoal::StartNode $TEST_PRIMARY_NODE_DIR

# Try starting the node again, should just report the node is already running
set ALREADY_STARTED_MESSAGE_RECEIVED 0
spawn goal node start -d $TEST_PRIMARY_NODE_DIR
expect {
timeout { close; ::AlgorandGoal::Abort "goal node start unexpectedly failed" }
"^Algorand node was already started!" {
set ALREADY_STARTED_MESSAGE_RECEIVED 1
exp_continue
}
-re "\\S+" { close; ::AlgorandGoal::Abort "Unexpected message for goal node start on a running node" }
eof {
if {$ALREADY_STARTED_MESSAGE_RECEIVED == 0} {
{ close; ::AlgorandGoal::Abort "eof recieved before the expected message "}
}
}
}

# Restart node
::AlgorandGoal::RestartNode $TEST_PRIMARY_NODE_DIR

Expand Down

0 comments on commit 75c12fd

Please sign in to comment.