-
Notifications
You must be signed in to change notification settings - Fork 97
Adding localnetwork e2e tests: start\status\clean #2784
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but would refactor to use new testing function
ginkgo.AfterEach(func() { | ||
err := commands.StopNetwork() | ||
gomega.Expect(err).Should(gomega.BeNil()) | ||
_, _ = commands.CleanNetwork() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe clean stops network, so we don't need to stop it before cleaning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
@@ -53,17 +54,42 @@ func StartNetwork() string { | |||
return StartNetworkWithVersion("") | |||
} | |||
|
|||
func StartNetworkWithNodeNumber(numOfNodes uint) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably start using Raymond's test function so that we don't create these additional utils functions for every scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good reminder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
ginkgo.AfterEach(func() { | ||
_, _ = commands.CleanNetwork() | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add tests for these flags too
cmd.Flags().StringVar(
&startFlags.UserProvidedAvagoVersion,
"avalanchego-version",
constants.DefaultAvalancheGoVersion,
"use this version of avalanchego (ex: v1.17.12)",
)
cmd.Flags().StringVar(&startFlags.AvagoBinaryPath, "avalanchego-path", "", "use this avalanchego binary path")
cmd.Flags().StringVar(&startFlags.RelayerBinaryPath, "relayer-path", "", "use this relayer binary path")
cmd.Flags().StringVar(&startFlags.SnapshotName, "snapshot-name", constants.DefaultSnapshotName, "name of snapshot to use to start the network from")
cmd.Flags().StringVar(
&startFlags.RelayerVersion,
"relayer-version",
constants.DefaultRelayerVersion,
"use this relayer version",
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For relayer related tests, feel free to create issue for it / if you want to pick it up, @felipemadero can give more context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i just created a ticket for it: https://ava-labs.atlassian.net/browse/DPTN-1665 - will address it in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about the other flags;
cmd.Flags().StringVar(
&startFlags.UserProvidedAvagoVersion,
"avalanchego-version",
constants.DefaultAvalancheGoVersion,
"use this version of avalanchego (ex: v1.17.12)",
)
cmd.Flags().StringVar(&startFlags.AvagoBinaryPath, "avalanchego-path", "", "use this avalanchego binary path")
cmd.Flags().StringVar(&startFlags.SnapshotName, "snapshot-name", constants.DefaultSnapshotName, "name of snapshot to use to start the network from")
gomega.Expect(err).Should(gomega.BeNil()) | ||
gomega.Expect(out).Should(gomega.ContainSubstring("Process terminated")) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add test for this flag too
cmd.Flags().BoolVar(
&hard,
"hard",
false,
"Also clean downloaded avalanchego and plugin binaries",
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comments here say plugin bins
are also cleaned up, but per https://github.com/ava-labs/avalanche-cli/blob/main/cmd/networkcmd/clean.go#L65 we only clean ava-go bins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we follow up with @felipemadero to see if this is a bug? If it is might need to create a PR to fix network clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most probably this flag should be deprecated
6e94b79
to
cbaf8a2
Compare
@@ -19,6 +19,7 @@ type CommandGroup string | |||
|
|||
const ( | |||
BlockchainCmd CommandGroup = "blockchain" | |||
NetworkCmd CommandGroup = "network" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a ticket to move this constants into cmd/
and unify?
cmd := exec.Command( | ||
CLIBinary, | ||
NetworkCmd, | ||
func CleanNetworkHard() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we don't need this command anymore, we can just do it with clean network I believe
func startNetworkWithParams(paramMap map[string]string) string { | ||
cmdArgs := utils.GlobalFlags{} | ||
|
||
for k, v := range paramMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this field remapping? we can just pass in the flags
} | ||
|
||
/* #nosec G204 */ | ||
func StartNetwork() string { | ||
return StartNetworkWithVersion("") | ||
} | ||
|
||
func StartNetworkWithNodeNumber(numOfNodes uint) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the caller can just use startNetworkWithParams. I also would make some changes so the numOfNodes is directly passed as map[string]interface{}
"number-of-nodes": strconv.FormatUint(uint64(numOfNodes), 10), | ||
}) | ||
} | ||
|
||
/* #nosec G204 */ | ||
func StartNetworkWithVersion(version string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the called can just use startNetworkWithParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better called, startNetwork
gomega.Expect(out).Should(gomega.ContainSubstring("Network ready to use")) | ||
|
||
// https://github.com/ava-labs/avalanchego/blob/master/tests/fixture/tmpnet/defaults.go#L27 | ||
defaultNodeCount := 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constants lives in CLI constants.LocalNetworkNumNodes we don't use tmpnet default
gomega.Expect(err).Should(gomega.BeNil()) | ||
gomega.Expect(out).Should(gomega.ContainSubstring("Network is Up")) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add tests for starting from a stopped cluster. most important test
consideration is that the state is preserved. eg:
start with N nodes -> stop -> start with no args-> the same N is obtained
and check that L1s are started, blockchain deploy -> stop -> start -> the L1s are up and running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also check for start with different snapshot names, and see that:
- it does not modify or create a default snapshot
- stop only restores that state if given that snapshot name
also, clean only affects the default snapshot, no other snapshots
all the snapshots semantic may be well tested in this commands, together with stop
}) | ||
|
||
ginkgo.It("can get status of started network", func() { | ||
out := commands.StartNetwork() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you check the status is current for different network configurations, and for deployed L1s?
|
||
ginkgo.It("can get status of started network", func() { | ||
out := commands.StartNetwork() | ||
gomega.Expect(out).Should(gomega.ContainSubstring("Network ready to use")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you force in some way an unhealthy status and check it is reported?
ginkgo.AfterEach(func() { | ||
commands.CleanNetwork() | ||
_, _ = commands.CleanNetwork() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should add here a test case for stopping a locally deployed L1. it should both stop the network and
the L1s
Why this should be merged
https://ava-labs.atlassian.net/browse/DPTN-1625
https://ava-labs.atlassian.net/browse/DPTN-1626
https://ava-labs.atlassian.net/browse/DPTN-1627
How this works
How this was tested
How is this documented