Skip to content

Commit

Permalink
go/oasis-test-runner: support setting custom node arguments from fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Jun 14, 2021
1 parent 26ee7c0 commit 2b48e5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions go/oasis-test-runner/oasis/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func (args *argBuilder) clone() *argBuilder {
}
}

func (args *argBuilder) extraArgs(extra []Argument) *argBuilder {
args.vec = append(args.vec, extra...)
return args
}

func (args *argBuilder) mergeConfigMap(cfg map[string]interface{}) *argBuilder {
if args.config == nil {
args.config = viper.New()
Expand Down
4 changes: 4 additions & 0 deletions go/oasis-test-runner/oasis/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ type NodeFixture struct {
// Name is the name of the node that hosts the feature. Leave empty
// to automatically instantiate a dedicated node with a default name.
Name string `json:"node_name,omitempty"`

ExtraArgs []Argument `json:"extra_args"`
}

// TEEFixture is a TEE configuration fixture.
Expand Down Expand Up @@ -208,6 +210,7 @@ func (f *ValidatorFixture) Create(net *Network) (*Validator, error) {
SupplementarySanityInterval: f.Consensus.SupplementarySanityInterval,
EnableProfiling: f.EnableProfiling,
Entity: entity,
ExtraArgs: f.ExtraArgs,
},
Sentries: sentries,
})
Expand Down Expand Up @@ -475,6 +478,7 @@ func (f *ComputeWorkerFixture) Create(net *Network) (*Compute, error) {
LogWatcherHandlerFactories: f.LogWatcherHandlerFactories,
Consensus: f.Consensus,
Entity: entity,
ExtraArgs: f.ExtraArgs,
},
RuntimeProvisioner: f.RuntimeProvisioner,
Runtimes: f.Runtimes,
Expand Down
7 changes: 6 additions & 1 deletion go/oasis-test-runner/oasis/oasis.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ type Node struct { // nolint: maligned

Name string
NodeID signature.PublicKey
Args *argBuilder

net *Network
dir *env.Dir
cmd *exec.Cmd

extraArgs []Argument
features []Feature
hasValidators bool
assignedPorts map[string]uint16
Expand Down Expand Up @@ -202,6 +202,8 @@ func (n *Node) Start() error {
args.appendHostedRuntime(hosted.runtime, hosted.tee, hosted.binaryIdx, hosted.localConfig)
}

args.extraArgs(n.extraArgs)

if customStart != nil {
return customStart.CustomStart(args)
}
Expand Down Expand Up @@ -359,6 +361,8 @@ type NodeCfg struct { // nolint: maligned
Consensus ConsensusFixture

Entity *Entity

ExtraArgs []Argument
}

// Into sets node parameters of an existing node object from the configuration.
Expand All @@ -381,6 +385,7 @@ func (cfg *NodeCfg) Into(node *Node) {
if node.pprofPort == 0 && cfg.EnableProfiling {
node.pprofPort = node.getProvisionedPort(nodePortPprof)
}
node.extraArgs = cfg.ExtraArgs
}

func nodeLogPath(dir *env.Dir) string {
Expand Down

0 comments on commit 2b48e5b

Please sign in to comment.