Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Tonix517
Copy link
Collaborator

@Tonix517 Tonix517 commented May 1, 2025

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

  • ran new e2e test cases locally

How is this documented

Copy link
Contributor

@artemanosov artemanosov left a 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()
Copy link
Contributor

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

Copy link
Collaborator Author

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 {
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good reminder

Copy link
Collaborator Author

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()
})

Copy link
Collaborator

@sukantoraymond sukantoraymond May 2, 2025

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",
	)

Copy link
Collaborator

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

Copy link
Collaborator Author

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

Copy link
Collaborator

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"))
})

Copy link
Collaborator

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",
	)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added in

Copy link
Collaborator Author

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?

Copy link
Collaborator

@sukantoraymond sukantoraymond May 5, 2025

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

Copy link
Collaborator

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

@Tonix517 Tonix517 force-pushed the tonyz/add_more_local_network_tests branch from 6e94b79 to cbaf8a2 Compare May 2, 2025 18:10
@@ -19,6 +19,7 @@ type CommandGroup string

const (
BlockchainCmd CommandGroup = "blockchain"
NetworkCmd CommandGroup = "network"
Copy link
Collaborator

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) {
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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

Copy link
Collaborator

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
Copy link
Collaborator

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"))
})
})
Copy link
Collaborator

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

Copy link
Collaborator

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()
Copy link
Collaborator

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"))
Copy link
Collaborator

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()
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants