Skip to content

Commit 6d6746e

Browse files
authored
fix: simulate restarting the espresso-dev-node (#557) (#562)
* fix: simulate restarting the espresso-dev-node The node currently does not support restarting from previously saved state and doing so leads to undefined behaviour. * shutdown dev-node at the end of E2E test * reconnect network before resuming dev node (cherry picked from commit 479288d)
1 parent 490e7a7 commit 6d6746e

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

system_tests/espresso_e2e_test.go

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ func TestEspressoE2E(t *testing.T) {
190190
err := waitForL1Node(ctx)
191191
Require(t, err)
192192

193-
runEspresso()
193+
shutdown := runEspresso()
194+
defer shutdown()
194195

195196
// wait for the builder
196197
err = waitForEspressoNode(ctx)
@@ -291,24 +292,57 @@ func TestEspressoE2E(t *testing.T) {
291292
// but shut down before it can be finalized
292293
time.Sleep(1 * time.Second)
293294

294-
// Shutdown the espresso node
295-
shutdownEspressoWithoutRemovingVolumes := func() {
296-
p := exec.Command("docker", "compose", "down")
295+
log.Info("Pausing espresso node")
296+
pauseEspresso := func() {
297+
p := exec.Command("docker", "compose", "pause")
297298
p.Dir = workingDir
298299
err := p.Run()
299300
if err != nil {
300301
panic(err)
301302
}
303+
// Disconnect the container from the network to ensure requests to the dev node
304+
// don't just hang but actually fail.
305+
p = exec.Command(
306+
"docker",
307+
"network",
308+
"disconnect",
309+
"espresso-e2e_default",
310+
"espresso-e2e-espresso-dev-node-1",
311+
)
312+
err = p.Run()
313+
if err != nil {
314+
panic(err)
315+
}
316+
302317
}
303-
// Note: It's important not to remove the volumes because otherwise namespace proof validations will fail
304-
shutdownEspressoWithoutRemovingVolumes()
318+
pauseEspresso()
305319

306-
// Wait for a 1 minute before restarting the espresso node
320+
log.Info("Waiting for 1 minute before resuming espresso node")
307321
time.Sleep(1 * time.Minute)
308322

309-
// Restart the espresso node
310-
cleanEspresso := runEspresso()
311-
defer cleanEspresso()
323+
log.Info("Resuming espresso node")
324+
unpauseEspresso := func() {
325+
// reconnect the network first
326+
p := exec.Command(
327+
"docker",
328+
"network",
329+
"connect",
330+
"espresso-e2e_default",
331+
"espresso-e2e-espresso-dev-node-1",
332+
)
333+
err := p.Run()
334+
if err != nil {
335+
panic(err)
336+
}
337+
// resume the dev node
338+
p = exec.Command("docker", "compose", "unpause")
339+
p.Dir = workingDir
340+
err = p.Run()
341+
if err != nil {
342+
panic(err)
343+
}
344+
}
345+
unpauseEspresso()
312346

313347
err = waitForEspressoNode(ctx)
314348
Require(t, err)

0 commit comments

Comments
 (0)