Skip to content

Commit 6626d2b

Browse files
authored
[tmpnet] Enable network restart to simplify iteration (#3272)
1 parent 9b34a2d commit 6626d2b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

tests/e2e/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ If a network is not already running the first time the suite runs with
7777
`--reuse-network`, one will be started automatically and configured
7878
for reuse by subsequent test runs also supplying `--reuse-network`.
7979

80+
### Restarting temporary networks
81+
82+
When iterating on a change to avalanchego and/or a VM, it may be
83+
useful to restart a running network to ensure the network is using the
84+
latest binary state. Supplying `--restart-network` in addition to
85+
`--reuse-network` will ensure that all nodes are restarted before
86+
tests are run. `--restart-network` is ignored if a network is not
87+
running or if `--stop-network` is supplied.
88+
89+
### Stopping temporary networks
90+
8091
To stop a network configured for reuse, invoke the test suite with the
8192
`--stop-network` argument. This will stop the network and exit
8293
immediately without executing any tests:

tests/fixture/e2e/env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork
110110
tc.Outf("No network to stop\n")
111111
}
112112
os.Exit(0)
113+
} else if network != nil && flagVars.RestartNetwork() {
114+
// A network is only restarted if it is already running and stop was not requested
115+
require.NoError(network.Restart(tc.DefaultContext(), tc.GetWriter()))
113116
}
114117
}
115118

tests/fixture/e2e/flags.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type FlagVars struct {
1919
reuseNetwork bool
2020
delayNetworkShutdown bool
2121
stopNetwork bool
22+
restartNetwork bool
2223
nodeCount int
2324
activateEtna bool
2425
}
@@ -45,6 +46,10 @@ func (v *FlagVars) ReuseNetwork() bool {
4546
return v.reuseNetwork
4647
}
4748

49+
func (v *FlagVars) RestartNetwork() bool {
50+
return v.restartNetwork
51+
}
52+
4853
func (v *FlagVars) NetworkShutdownDelay() time.Duration {
4954
if v.delayNetworkShutdown {
5055
// Only return a non-zero value if the delay is enabled. Make sure this value takes
@@ -92,6 +97,12 @@ func RegisterFlags() *FlagVars {
9297
false,
9398
"[optional] reuse an existing network. If an existing network is not already running, create a new one and leave it running for subsequent usage.",
9499
)
100+
flag.BoolVar(
101+
&vars.restartNetwork,
102+
"restart-network",
103+
false,
104+
"[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.",
105+
)
95106
flag.BoolVar(
96107
&vars.delayNetworkShutdown,
97108
"delay-network-shutdown",

0 commit comments

Comments
 (0)