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 28, 2020
1 parent 9ff8b7c commit c64e73e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
84 changes: 84 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,84 @@
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 (s *lateStartImpl) Fixture() (*oasis.NetworkFixture, error) {
f, err := s.basicImpl.Fixture()
if err != nil {
return nil, err
}

// Start without a client.
f.Clients = []oasis.ClientFixture{}

return f, nil
}

func (s *lateStartImpl) Run(childEnv *env.Env) error {
// Start the network.
var err error
if err = s.net.Start(); err != nil {
return err
}

s.logger.Info("Waiting before starting the client node",
"wait_for", lateStartInitialWait,
)
time.Sleep(lateStartInitialWait)

s.logger.Info("Starting the client node")
clientFixture := &oasis.ClientFixture{}
client, err := clientFixture.Create(s.net)
if err != nil {
return err
}
if err = client.Start(); err != nil {
return err
}

s.logger.Info("Starting the basic client")
// Start basic client.
cmd, err := startClient(childEnv, s.net, resolveClientBinary(s.clientBinary), s.clientArgs)
if err != nil {
return err
}
clientErrCh := make(chan error)
go func() {
clientErrCh <- cmd.Wait()
}()

// Wait for the client to exit.
select {
case err = <-clientErrCh:
_ = cmd.Process.Kill()
case err = <-clientErrCh:
}
if err != nil {
return err
}

return nil
}
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 c64e73e

Please sign in to comment.