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

[tmpnet] Add --start-network to support hypersdk MODE=run #3465

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/fixture/e2e/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork
flagVars.AvalancheGoExecPath(),
flagVars.PluginDir(),
flagVars.NetworkShutdownDelay(),
flagVars.StartNetwork(),
flagVars.ReuseNetwork(),
)

Expand All @@ -158,6 +159,10 @@ func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork
}, DefaultTimeout, DefaultPollingInterval, "failed to see all chains bootstrap before timeout")
}

if flagVars.StartNetwork() {
os.Exit(0)
}
marun marked this conversation as resolved.
Show resolved Hide resolved

suiteConfig, _ := ginkgo.GinkgoConfiguration()
require.Greater(
len(network.PreFundedKeys),
Expand Down Expand Up @@ -214,6 +219,7 @@ func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network) {
sharedNetwork.DefaultRuntimeConfig.AvalancheGoPath,
pluginDir,
te.PrivateNetworkShutdownDelay,
false, /* skipShutdown */
false, /* reuseNetwork */
)
}
17 changes: 14 additions & 3 deletions tests/fixture/e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type FlagVars struct {
networkDir string
reuseNetwork bool
delayNetworkShutdown bool
startNetwork bool
stopNetwork bool
restartNetwork bool
nodeCount int
Expand Down Expand Up @@ -62,6 +63,10 @@ func (v *FlagVars) NetworkShutdownDelay() time.Duration {
return 0
}

func (v *FlagVars) StartNetwork() bool {
return v.startNetwork
}

func (v *FlagVars) StopNetwork() bool {
return v.stopNetwork
}
Expand Down Expand Up @@ -112,25 +117,31 @@ func RegisterFlags() *FlagVars {
&vars.reuseNetwork,
"reuse-network",
false,
"[optional] reuse an existing network. If an existing network is not already running, create a new one and leave it running for subsequent usage.",
"[optional] reuse an existing network previously started with --reuse-network. If a network is not already running, create a new one and leave it running for subsequent usage. Ignored if --stop-network is provided.",
)
flag.BoolVar(
&vars.restartNetwork,
"restart-network",
false,
"[optional] restarts an existing network. Useful for ensuring a network is running with the current state of binaries on disk. Ignored if a network is not already running or --stop-network is provided.",
"[optional] restart an existing network previously started with --reuse-network. Useful for ensuring a network is running with the current state of binaries on disk. Ignored if a network is not already running or --stop-network is provided.",
)
flag.BoolVar(
&vars.delayNetworkShutdown,
"delay-network-shutdown",
false,
"[optional] whether to delay network shutdown to allow a final metrics scrape.",
)
flag.BoolVar(
&vars.startNetwork,
"start-network",
false,
"[optional] start a new network and exit without executing any tests. The new network cannot be reused with --reuse-network. Ignored if either --reuse-network or --stop-network is provided.",
)
flag.BoolVar(
&vars.stopNetwork,
"stop-network",
false,
"[optional] stop an existing network and exit without executing any tests.",
"[optional] stop an existing network started with --reuse-network and exit without executing any tests.",
)
flag.IntVar(
&vars.nodeCount,
Expand Down
6 changes: 6 additions & 0 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func StartNetwork(
avalancheGoExecPath string,
pluginDir string,
shutdownDelay time.Duration,
skipShutdown bool,
reuseNetwork bool,
) {
require := require.New(tc)
Expand Down Expand Up @@ -270,6 +271,11 @@ func StartNetwork(
return
}

if skipShutdown {
tc.Outf("{{yellow}}Skipping shutdown for network %s{{/}}\n", network.Dir)
return
}

if shutdownDelay > 0 {
tc.Outf("Waiting %s before network shutdown to ensure final metrics scrape\n", shutdownDelay)
time.Sleep(shutdownDelay)
Expand Down
10 changes: 9 additions & 1 deletion tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ var _ = ginkgo.Describe("[Upgrade]", func() {
require.NoError(err)
network.Genesis = genesis

e2e.StartNetwork(tc, network, avalancheGoExecPath, "" /* pluginDir */, 0 /* shutdownDelay */, false /* reuseNetwork */)
e2e.StartNetwork(
tc,
network,
avalancheGoExecPath,
"", /* pluginDir */
0, /* shutdownDelay */
false, /* skipShutdown */
false, /* reuseNetwork */
)

tc.By(fmt.Sprintf("restarting all nodes with %q binary", avalancheGoExecPathToUpgradeTo))
for _, node := range network.Nodes {
Expand Down
Loading