Skip to content

Commit c70512a

Browse files
committed
[tmpnet] Add --start-network to support hypersdk MODE=run
1 parent b9e2af2 commit c70512a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

tests/fixture/e2e/env.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork
135135
flagVars.AvalancheGoExecPath(),
136136
flagVars.PluginDir(),
137137
flagVars.NetworkShutdownDelay(),
138+
flagVars.StartNetwork(),
138139
flagVars.ReuseNetwork(),
139140
)
140141

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

162+
if flagVars.StartNetwork() {
163+
os.Exit(0)
164+
}
165+
161166
suiteConfig, _ := ginkgo.GinkgoConfiguration()
162167
require.Greater(
163168
len(network.PreFundedKeys),
@@ -214,6 +219,7 @@ func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network) {
214219
sharedNetwork.DefaultRuntimeConfig.AvalancheGoPath,
215220
pluginDir,
216221
te.PrivateNetworkShutdownDelay,
222+
false, /* skipShutdown */
217223
false, /* reuseNetwork */
218224
)
219225
}

tests/fixture/e2e/flags.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type FlagVars struct {
2222
networkDir string
2323
reuseNetwork bool
2424
delayNetworkShutdown bool
25+
startNetwork bool
2526
stopNetwork bool
2627
restartNetwork bool
2728
nodeCount int
@@ -62,6 +63,10 @@ func (v *FlagVars) NetworkShutdownDelay() time.Duration {
6263
return 0
6364
}
6465

66+
func (v *FlagVars) StartNetwork() bool {
67+
return v.startNetwork
68+
}
69+
6570
func (v *FlagVars) StopNetwork() bool {
6671
return v.stopNetwork
6772
}
@@ -112,25 +117,31 @@ func RegisterFlags() *FlagVars {
112117
&vars.reuseNetwork,
113118
"reuse-network",
114119
false,
115-
"[optional] reuse an existing network. If an existing network is not already running, create a new one and leave it running for subsequent usage.",
120+
"[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.",
116121
)
117122
flag.BoolVar(
118123
&vars.restartNetwork,
119124
"restart-network",
120125
false,
121-
"[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.",
126+
"[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.",
122127
)
123128
flag.BoolVar(
124129
&vars.delayNetworkShutdown,
125130
"delay-network-shutdown",
126131
false,
127132
"[optional] whether to delay network shutdown to allow a final metrics scrape.",
128133
)
134+
flag.BoolVar(
135+
&vars.startNetwork,
136+
"start-network",
137+
false,
138+
"[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.",
139+
)
129140
flag.BoolVar(
130141
&vars.stopNetwork,
131142
"stop-network",
132143
false,
133-
"[optional] stop an existing network and exit without executing any tests.",
144+
"[optional] stop an existing network started with --reuse-network and exit without executing any tests.",
134145
)
135146
flag.IntVar(
136147
&vars.nodeCount,

tests/fixture/e2e/helpers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func StartNetwork(
231231
avalancheGoExecPath string,
232232
pluginDir string,
233233
shutdownDelay time.Duration,
234+
skipShutdown bool,
234235
reuseNetwork bool,
235236
) {
236237
require := require.New(tc)
@@ -270,6 +271,11 @@ func StartNetwork(
270271
return
271272
}
272273

274+
if skipShutdown {
275+
tc.Outf("{{yellow}}Skipping shutdown for network %s{{/}}\n", network.Dir)
276+
return
277+
}
278+
273279
if shutdownDelay > 0 {
274280
tc.Outf("Waiting %s before network shutdown to ensure final metrics scrape\n", shutdownDelay)
275281
time.Sleep(shutdownDelay)

0 commit comments

Comments
 (0)