From 2b48e5be52e874020545ee903ac1cd44586fd46c Mon Sep 17 00:00:00 2001 From: ptrus Date: Mon, 14 Jun 2021 08:54:40 +0200 Subject: [PATCH] go/oasis-test-runner: support setting custom node arguments from fixture --- go/oasis-test-runner/oasis/args.go | 5 +++++ go/oasis-test-runner/oasis/fixture.go | 4 ++++ go/oasis-test-runner/oasis/oasis.go | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/go/oasis-test-runner/oasis/args.go b/go/oasis-test-runner/oasis/args.go index 1a8db30a40a..8fbf0c5ddad 100644 --- a/go/oasis-test-runner/oasis/args.go +++ b/go/oasis-test-runner/oasis/args.go @@ -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() diff --git a/go/oasis-test-runner/oasis/fixture.go b/go/oasis-test-runner/oasis/fixture.go index 5299a887078..176fd07dd7a 100644 --- a/go/oasis-test-runner/oasis/fixture.go +++ b/go/oasis-test-runner/oasis/fixture.go @@ -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. @@ -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, }) @@ -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, diff --git a/go/oasis-test-runner/oasis/oasis.go b/go/oasis-test-runner/oasis/oasis.go index 4fad10e4d1b..22f4c12bcbb 100644 --- a/go/oasis-test-runner/oasis/oasis.go +++ b/go/oasis-test-runner/oasis/oasis.go @@ -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 @@ -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) } @@ -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. @@ -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 {