-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/oasis-test-runner: add 'late-start' E2E test
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters