From 7f5d7a2bfa82e6584f33669e30ec94004a611904 Mon Sep 17 00:00:00 2001 From: ptrus Date: Tue, 28 Apr 2020 15:22:34 +0200 Subject: [PATCH] go/oasis-test-runner: add 'late-start' E2E test --- .../scenario/e2e/late_start.go | 73 +++++++++++++++++++ go/oasis-test-runner/test-runner.go | 2 + 2 files changed, 75 insertions(+) create mode 100644 go/oasis-test-runner/scenario/e2e/late_start.go diff --git a/go/oasis-test-runner/scenario/e2e/late_start.go b/go/oasis-test-runner/scenario/e2e/late_start.go new file mode 100644 index 00000000000..e8b85f998e9 --- /dev/null +++ b/go/oasis-test-runner/scenario/e2e/late_start.go @@ -0,0 +1,73 @@ +package e2e + +import ( + "time" + + "github.com/oasislabs/oasis-core/go/oasis-test-runner/env" + "github.com/oasislabs/oasis-core/go/oasis-test-runner/oasis" + "github.com/oasislabs/oasis-core/go/oasis-test-runner/scenario" +) + +var ( + // LateStart is the LateStart node basic scenario. + LateStart scenario.Scenario = newLateStartImpl("late-start", "simple-keyvalue-client", nil) +) + +const lateStartInitialWait = 2 * time.Minute + +type lateStartImpl struct { + basicImpl +} + +func newLateStartImpl(name, clientBinary string, clientArgs []string) scenario.Scenario { + return &lateStartImpl{ + basicImpl: *newBasicImpl(name, clientBinary, clientArgs), + } +} + +func (sc *lateStartImpl) Fixture() (*oasis.NetworkFixture, error) { + f, err := sc.basicImpl.Fixture() + if err != nil { + return nil, err + } + + // Start without a client. + f.Clients = []oasis.ClientFixture{} + + return f, nil +} + +func (sc *lateStartImpl) Run(childEnv *env.Env) error { + // Start the network. + var err error + if err = sc.net.Start(); err != nil { + return err + } + + sc.logger.Info("Waiting before starting the client node", + "wait_for", lateStartInitialWait, + ) + time.Sleep(lateStartInitialWait) + + sc.logger.Info("Starting the client node") + clientFixture := &oasis.ClientFixture{} + client, err := clientFixture.Create(sc.net) + if err != nil { + return err + } + if err = client.Start(); err != nil { + return err + } + + sc.logger.Info("Starting the basic client") + cmd, err := startClient(childEnv, sc.net, resolveClientBinary(sc.clientBinary), sc.clientArgs) + if err != nil { + return err + } + clientErrCh := make(chan error) + go func() { + clientErrCh <- cmd.Wait() + }() + + return sc.wait(childEnv, cmd, clientErrCh) +} diff --git a/go/oasis-test-runner/test-runner.go b/go/oasis-test-runner/test-runner.go index 35f81c039c6..50ae664026f 100644 --- a/go/oasis-test-runner/test-runner.go +++ b/go/oasis-test-runner/test-runner.go @@ -67,6 +67,8 @@ func main() { _ = cmd.Register(e2e.NodeUpgradeCancel) // Debonding entries from genesis test. _ = cmd.Register(e2e.Debond) + // Late start test. + _ = cmd.Register(e2e.LateStart) // Register the remote signer test cases. rootCmd.Flags().AddFlagSet(remotesigner.Flags)