Skip to content

Commit

Permalink
go/oasis-test-runner: add 'late-start' E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Apr 29, 2020
1 parent a2fa3fe commit 7f5d7a2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
73 changes: 73 additions & 0 deletions go/oasis-test-runner/scenario/e2e/late_start.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions go/oasis-test-runner/test-runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7f5d7a2

Please sign in to comment.