driver

package
v0.0.0-...-d812fb0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package driver is a generated GoMock package.

Package driver is a generated GoMock package.

Package driver is a generated GoMock package.

Index

Constants

View Source
const DefaultClientDockerImageName = "sonic"

DefaultClientDockerImageName is the name of the docker image to use for clients.

View Source
const (
	// ErrEmptyNetwork is returned when trying to connect to an empty network.
	ErrEmptyNetwork = common.ConstError("network is empty")
)

Variables

This section is empty.

Functions

func GetValidatorStakes

func GetValidatorStakes(validators Validators) []uint64

GetValidatorStakes returns the list of validator stakes based on the provided configuration. If a validator has a stake of 0, it defaults to 5 million.

func ResolveClientImageName

func ResolveClientImageName(imageName string) string

ResolveClientImageName returns imageName if set, otherwise the default client image name.

Types

type Application

type Application interface {
	// Start begins producing load on the network as configured for this app.
	Start(context.Context) error
	// Stop terminates the load production.
	Stop() error

	// Config returns current application configuration.
	Config() *ApplicationConfig

	// GetNumberOfUsers retrieves the number of users interacting with this application.
	// This value is expected to be a constant over the life-time of an application.
	GetNumberOfUsers() int

	// GetSentTransactions returns the number of transactions sent by a given user.
	GetSentTransactions(user int) (uint64, error)

	// GetReceivedTransactions returns the number fo transactions received by the appliation
	// on the network.
	GetReceivedTransactions() (uint64, error)
}

Application is an abstraction of an application running on a Norma net.

type ApplicationConfig

type ApplicationConfig struct {
	Name string

	// Type defines the on-chain app which should generate the traffic.
	Type string

	// Rate defines the Tx/s config the source should produce while active.
	Rate *parser.Rate

	// Users defines the number of users sending transactions to the app.
	Users int
}

type MockApplication

type MockApplication struct {
	// contains filtered or unexported fields
}

MockApplication is a mock of Application interface.

func NewMockApplication

func NewMockApplication(ctrl *gomock.Controller) *MockApplication

NewMockApplication creates a new mock instance.

func (*MockApplication) Config

func (m *MockApplication) Config() *ApplicationConfig

Config mocks base method.

func (*MockApplication) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockApplication) GetNumberOfUsers

func (m *MockApplication) GetNumberOfUsers() int

GetNumberOfUsers mocks base method.

func (*MockApplication) GetReceivedTransactions

func (m *MockApplication) GetReceivedTransactions() (uint64, error)

GetReceivedTransactions mocks base method.

func (*MockApplication) GetSentTransactions

func (m *MockApplication) GetSentTransactions(user int) (uint64, error)

GetSentTransactions mocks base method.

func (*MockApplication) Start

func (m *MockApplication) Start(arg0 context.Context) error

Start mocks base method.

func (*MockApplication) Stop

func (m *MockApplication) Stop() error

Stop mocks base method.

type MockApplicationMockRecorder

type MockApplicationMockRecorder struct {
	// contains filtered or unexported fields
}

MockApplicationMockRecorder is the mock recorder for MockApplication.

func (*MockApplicationMockRecorder) Config

func (mr *MockApplicationMockRecorder) Config() *gomock.Call

Config indicates an expected call of Config.

func (*MockApplicationMockRecorder) GetNumberOfUsers

func (mr *MockApplicationMockRecorder) GetNumberOfUsers() *gomock.Call

GetNumberOfUsers indicates an expected call of GetNumberOfUsers.

func (*MockApplicationMockRecorder) GetReceivedTransactions

func (mr *MockApplicationMockRecorder) GetReceivedTransactions() *gomock.Call

GetReceivedTransactions indicates an expected call of GetReceivedTransactions.

func (*MockApplicationMockRecorder) GetSentTransactions

func (mr *MockApplicationMockRecorder) GetSentTransactions(user any) *gomock.Call

GetSentTransactions indicates an expected call of GetSentTransactions.

func (*MockApplicationMockRecorder) Start

func (mr *MockApplicationMockRecorder) Start(arg0 any) *gomock.Call

Start indicates an expected call of Start.

func (*MockApplicationMockRecorder) Stop

Stop indicates an expected call of Stop.

type MockNetwork

type MockNetwork struct {
	// contains filtered or unexported fields
}

MockNetwork is a mock of Network interface.

func NewMockNetwork

func NewMockNetwork(ctrl *gomock.Controller) *MockNetwork

NewMockNetwork creates a new mock instance.

func (*MockNetwork) AdvanceEpoch

func (m *MockNetwork) AdvanceEpoch(epochIncrement int) error

AdvanceEpoch mocks base method.

func (*MockNetwork) ApplyNetworkRules

func (m *MockNetwork) ApplyNetworkRules(rules NetworkRules) error

ApplyNetworkRules mocks base method.

func (*MockNetwork) CreateApplication

func (m *MockNetwork) CreateApplication(arg0 context.Context, arg1 *ApplicationConfig) (Application, error)

CreateApplication mocks base method.

func (*MockNetwork) CreateNode

func (m *MockNetwork) CreateNode(config *NodeConfig) (Node, error)

CreateNode mocks base method.

func (*MockNetwork) DialRandomRpc

func (m *MockNetwork) DialRandomRpc() (rpc.Client, error)

DialRandomRpc mocks base method.

func (*MockNetwork) EXPECT

func (m *MockNetwork) EXPECT() *MockNetworkMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNetwork) GetActiveApplications

func (m *MockNetwork) GetActiveApplications() []Application

GetActiveApplications mocks base method.

func (*MockNetwork) GetActiveNodes

func (m *MockNetwork) GetActiveNodes() []Node

GetActiveNodes mocks base method.

func (*MockNetwork) RegisterListener

func (m *MockNetwork) RegisterListener(arg0 NetworkListener)

RegisterListener mocks base method.

func (*MockNetwork) RemoveNode

func (m *MockNetwork) RemoveNode(arg0 Node) error

RemoveNode mocks base method.

func (*MockNetwork) SendTransaction

func (m *MockNetwork) SendTransaction(tx *types.Transaction, source string)

SendTransaction mocks base method.

func (*MockNetwork) Shutdown

func (m *MockNetwork) Shutdown() error

Shutdown mocks base method.

func (*MockNetwork) UnregisterListener

func (m *MockNetwork) UnregisterListener(arg0 NetworkListener)

UnregisterListener mocks base method.

func (*MockNetwork) WaitForEpochChange

func (m *MockNetwork) WaitForEpochChange() error

WaitForEpochChange mocks base method.

type MockNetworkListener

type MockNetworkListener struct {
	// contains filtered or unexported fields
}

MockNetworkListener is a mock of NetworkListener interface.

func NewMockNetworkListener

func NewMockNetworkListener(ctrl *gomock.Controller) *MockNetworkListener

NewMockNetworkListener creates a new mock instance.

func (*MockNetworkListener) AfterApplicationCreation

func (m *MockNetworkListener) AfterApplicationCreation(arg0 Application)

AfterApplicationCreation mocks base method.

func (*MockNetworkListener) AfterNodeCreation

func (m *MockNetworkListener) AfterNodeCreation(arg0 Node)

AfterNodeCreation mocks base method.

func (*MockNetworkListener) BeforeNodeRemoval

func (m *MockNetworkListener) BeforeNodeRemoval(arg0 Node)

BeforeNodeRemoval mocks base method.

func (*MockNetworkListener) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockNetworkListenerMockRecorder

type MockNetworkListenerMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetworkListenerMockRecorder is the mock recorder for MockNetworkListener.

func (*MockNetworkListenerMockRecorder) AfterApplicationCreation

func (mr *MockNetworkListenerMockRecorder) AfterApplicationCreation(arg0 any) *gomock.Call

AfterApplicationCreation indicates an expected call of AfterApplicationCreation.

func (*MockNetworkListenerMockRecorder) AfterNodeCreation

func (mr *MockNetworkListenerMockRecorder) AfterNodeCreation(arg0 any) *gomock.Call

AfterNodeCreation indicates an expected call of AfterNodeCreation.

func (*MockNetworkListenerMockRecorder) BeforeNodeRemoval

func (mr *MockNetworkListenerMockRecorder) BeforeNodeRemoval(arg0 any) *gomock.Call

BeforeNodeRemoval indicates an expected call of BeforeNodeRemoval.

type MockNetworkMockRecorder

type MockNetworkMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetworkMockRecorder is the mock recorder for MockNetwork.

func (*MockNetworkMockRecorder) AdvanceEpoch

func (mr *MockNetworkMockRecorder) AdvanceEpoch(epochIncrement any) *gomock.Call

AdvanceEpoch indicates an expected call of AdvanceEpoch.

func (*MockNetworkMockRecorder) ApplyNetworkRules

func (mr *MockNetworkMockRecorder) ApplyNetworkRules(rules any) *gomock.Call

ApplyNetworkRules indicates an expected call of ApplyNetworkRules.

func (*MockNetworkMockRecorder) CreateApplication

func (mr *MockNetworkMockRecorder) CreateApplication(arg0, arg1 any) *gomock.Call

CreateApplication indicates an expected call of CreateApplication.

func (*MockNetworkMockRecorder) CreateNode

func (mr *MockNetworkMockRecorder) CreateNode(config any) *gomock.Call

CreateNode indicates an expected call of CreateNode.

func (*MockNetworkMockRecorder) DialRandomRpc

func (mr *MockNetworkMockRecorder) DialRandomRpc() *gomock.Call

DialRandomRpc indicates an expected call of DialRandomRpc.

func (*MockNetworkMockRecorder) GetActiveApplications

func (mr *MockNetworkMockRecorder) GetActiveApplications() *gomock.Call

GetActiveApplications indicates an expected call of GetActiveApplications.

func (*MockNetworkMockRecorder) GetActiveNodes

func (mr *MockNetworkMockRecorder) GetActiveNodes() *gomock.Call

GetActiveNodes indicates an expected call of GetActiveNodes.

func (*MockNetworkMockRecorder) RegisterListener

func (mr *MockNetworkMockRecorder) RegisterListener(arg0 any) *gomock.Call

RegisterListener indicates an expected call of RegisterListener.

func (*MockNetworkMockRecorder) RemoveNode

func (mr *MockNetworkMockRecorder) RemoveNode(arg0 any) *gomock.Call

RemoveNode indicates an expected call of RemoveNode.

func (*MockNetworkMockRecorder) SendTransaction

func (mr *MockNetworkMockRecorder) SendTransaction(tx, source any) *gomock.Call

SendTransaction indicates an expected call of SendTransaction.

func (*MockNetworkMockRecorder) Shutdown

func (mr *MockNetworkMockRecorder) Shutdown() *gomock.Call

Shutdown indicates an expected call of Shutdown.

func (*MockNetworkMockRecorder) UnregisterListener

func (mr *MockNetworkMockRecorder) UnregisterListener(arg0 any) *gomock.Call

UnregisterListener indicates an expected call of UnregisterListener.

func (*MockNetworkMockRecorder) WaitForEpochChange

func (mr *MockNetworkMockRecorder) WaitForEpochChange() *gomock.Call

WaitForEpochChange indicates an expected call of WaitForEpochChange.

type MockNode

type MockNode struct {
	// contains filtered or unexported fields
}

MockNode is a mock of Node interface.

func NewMockNode

func NewMockNode(ctrl *gomock.Controller) *MockNode

NewMockNode creates a new mock instance.

func (*MockNode) Cleanup

func (m *MockNode) Cleanup(arg0 context.Context) error

Cleanup mocks base method.

func (*MockNode) DialRpc

func (m *MockNode) DialRpc(arg0 context.Context) (rpc.Client, error)

DialRpc mocks base method.

func (*MockNode) EXPECT

func (m *MockNode) EXPECT() *MockNodeMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNode) GetLabel

func (m *MockNode) GetLabel() string

GetLabel mocks base method.

func (*MockNode) GetNodeID

func (m *MockNode) GetNodeID() (NodeID, error)

GetNodeID mocks base method.

func (*MockNode) GetServiceUrl

func (m *MockNode) GetServiceUrl(arg0 *network.ServiceDescription) (*URL, error)

GetServiceUrl mocks base method.

func (*MockNode) GetValidatorId

func (m *MockNode) GetValidatorId() *int

GetValidatorId mocks base method.

func (*MockNode) Hostname

func (m *MockNode) Hostname() string

Hostname mocks base method.

func (*MockNode) IsExpectedFailure

func (m *MockNode) IsExpectedFailure() bool

IsExpectedFailure mocks base method.

func (*MockNode) IsRunning

func (m *MockNode) IsRunning() bool

IsRunning mocks base method.

func (*MockNode) Kill

func (m *MockNode) Kill(arg0 context.Context) error

Kill mocks base method.

func (*MockNode) MetricsPort

func (m *MockNode) MetricsPort() int

MetricsPort mocks base method.

func (*MockNode) Stop

func (m *MockNode) Stop(arg0 context.Context) error

Stop mocks base method.

func (*MockNode) StreamLog

func (m *MockNode) StreamLog(arg0 context.Context) (io.ReadCloser, error)

StreamLog mocks base method.

type MockNodeMockRecorder

type MockNodeMockRecorder struct {
	// contains filtered or unexported fields
}

MockNodeMockRecorder is the mock recorder for MockNode.

func (*MockNodeMockRecorder) Cleanup

func (mr *MockNodeMockRecorder) Cleanup(arg0 any) *gomock.Call

Cleanup indicates an expected call of Cleanup.

func (*MockNodeMockRecorder) DialRpc

func (mr *MockNodeMockRecorder) DialRpc(arg0 any) *gomock.Call

DialRpc indicates an expected call of DialRpc.

func (*MockNodeMockRecorder) GetLabel

func (mr *MockNodeMockRecorder) GetLabel() *gomock.Call

GetLabel indicates an expected call of GetLabel.

func (*MockNodeMockRecorder) GetNodeID

func (mr *MockNodeMockRecorder) GetNodeID() *gomock.Call

GetNodeID indicates an expected call of GetNodeID.

func (*MockNodeMockRecorder) GetServiceUrl

func (mr *MockNodeMockRecorder) GetServiceUrl(arg0 any) *gomock.Call

GetServiceUrl indicates an expected call of GetServiceUrl.

func (*MockNodeMockRecorder) GetValidatorId

func (mr *MockNodeMockRecorder) GetValidatorId() *gomock.Call

GetValidatorId indicates an expected call of GetValidatorId.

func (*MockNodeMockRecorder) Hostname

func (mr *MockNodeMockRecorder) Hostname() *gomock.Call

Hostname indicates an expected call of Hostname.

func (*MockNodeMockRecorder) IsExpectedFailure

func (mr *MockNodeMockRecorder) IsExpectedFailure() *gomock.Call

IsExpectedFailure indicates an expected call of IsExpectedFailure.

func (*MockNodeMockRecorder) IsRunning

func (mr *MockNodeMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning.

func (*MockNodeMockRecorder) Kill

func (mr *MockNodeMockRecorder) Kill(arg0 any) *gomock.Call

Kill indicates an expected call of Kill.

func (*MockNodeMockRecorder) MetricsPort

func (mr *MockNodeMockRecorder) MetricsPort() *gomock.Call

MetricsPort indicates an expected call of MetricsPort.

func (*MockNodeMockRecorder) Stop

func (mr *MockNodeMockRecorder) Stop(arg0 any) *gomock.Call

Stop indicates an expected call of Stop.

func (*MockNodeMockRecorder) StreamLog

func (mr *MockNodeMockRecorder) StreamLog(arg0 any) *gomock.Call

StreamLog indicates an expected call of StreamLog.

type Network

type Network interface {
	// CreateNode creates a new node instance running a network client based on
	// the given configuration. It is used by the scenario executor to add
	// nodes to the network as needed.
	CreateNode(config *NodeConfig) (Node, error)

	// RemoveNode ends the client gracefully and removes node from the network
	RemoveNode(Node) error

	// CreateApplication creates a new application in this network, ready to
	// produce load as defined by its configuration.
	CreateApplication(context.Context, *ApplicationConfig) (Application, error)

	// GetActiveNodes obtains a list of active nodes in the network.
	GetActiveNodes() []Node

	// GetActiveApplications obtains a list of active apps in the network.
	GetActiveApplications() []Application

	// RegisterListener registers a listener to receive updates on network
	// changes, for instance, to update monitoring information. Registering
	// the same listener more than once will have no effect.
	RegisterListener(NetworkListener)

	// UnregisterListener removes the given listener from this network.
	UnregisterListener(NetworkListener)

	// Shutdown stops all applications and nodes in the network and frees
	// any potential other resources.
	Shutdown() error

	// SendTransaction sends a transaction to the network.
	// The source parameter is used for logging and debugging purposes.
	SendTransaction(tx *types.Transaction, source string)

	// Create a connection to a random node on the network. May fail if there
	// is no node on the network with a ErrorEmptyNetwork error.
	DialRandomRpc() (rpc.Client, error)

	// ApplyNetworkRules applies the given network rules to the network.
	ApplyNetworkRules(rules NetworkRules) error

	// AdvanceEpoch advances an epoch by the given number.
	AdvanceEpoch(epochIncrement int) error

	// WaitForEpochChange waits until the epoch changes.
	WaitForEpochChange() error
}

Network abstracts an execution environment for running scenarios. Implementations may run nodes and applications locally, in docker images, or remotely, on actual nodes. The interface is used by the scenario driver to execute scenario descriptions.

type NetworkConfig

type NetworkConfig struct {
	// Validators is a list of validators to start up in the network.
	Validators Validators
	// RoundTripTime is the average round trip time between nodes in the network.
	RoundTripTime time.Duration
	// NetworkRules is a map of network rules to be applied to the network.
	NetworkRules NetworkRules
	// OutputDir is the directory where temp data are written.
	OutputDir string
}

NetworkConfig is a collection of network parameters to be used by factories creating network instances.

type NetworkListener

type NetworkListener interface {
	// AfterNodeCreation is called whenever a new node has joined the network.
	AfterNodeCreation(Node)
	// BeforeNodeRemoval is called whenever a node is removed from the network.
	BeforeNodeRemoval(Node)
	// AfterApplicationCreation is called after a new application has started.
	AfterApplicationCreation(Application)
}

NetworkListener can be registered to networks to get callbacks whenever there are changes in the network.

type NetworkRules

type NetworkRules = genesis.NetworkRulesPatch

NetworkRules defines a set of network rules that can be applied to the network. Network rules contains all the fields in sonic's opera.Rules, but all fields are optional and only the non-nil fields will be applied to the network.

This type is used to define the initial rule set in the genesis, by applying the diff to the default rules: opera.FakeNetRules(opera.GetSonicUpgrades()) Additionally it can be sent serialized using json to change the network rules during execution.

type Node

type Node interface {
	// GetLabel returns a human-readable identifier for this node. Is is intended
	// to label data and should be unique within a single scenario run.
	GetLabel() string

	// IsExpectedFailure returns true if the node is supposed to fail during network execution.
	IsExpectedFailure() bool

	// Hostname returns the hostname of the host.
	Hostname() string

	// MetricsPort returns the port on which the node exposes its metrics.
	MetricsPort() int

	// IsRunning returns true if the node is still running, false if stopped.
	IsRunning() bool

	// GetNodeID returns an enode identifying this node within the Norma network.
	// An error shall be produced if no valid node ID could be obtained.
	GetNodeID() (NodeID, error)

	// GetValidatorId returns the validator ID used by this node, if it is a
	// validator node. If the node is not a validator, it returns nil.
	GetValidatorId() *int

	// GetServiceUrl returns the URL of a service running on the
	// represented node. May be nil if no such service is offered.
	GetServiceUrl(*network.ServiceDescription) (*URL, error)

	// DialRpc establish an RPC connection with the node and returns the RPC client.
	DialRpc(context.Context) (rpc.Client, error)

	// StreamLog provides a reader that is continuously providing the host log.
	// It is up to the caller to close the stream.
	StreamLog(context.Context) (io.ReadCloser, error)

	// Stop shuts down this node gracefully, using its regular shutdown
	// procedure (not killed). After stopping the service, no more interactions
	// are expected to succeed.
	Stop(context.Context) error

	// Kill shuts down this node disgracefully by using SigKill.
	Kill(context.Context) error

	// Cleanup releases all underlying resources. After the cleanup no more
	// operations on this node are expected to succeed.
	Cleanup(context.Context) error
}

Node is controlling a single node in a Norma network. It provides abstract control of a node, allowing it to be started (through an Environment), interact with the node, and shut it down.

type NodeConfig

type NodeConfig struct {
	Name           string
	Failing        bool
	Validator      bool
	ValidatorId    *int
	Cheater        bool
	Image          string
	DataVolume     *string
	ExtraArguments string
}

type NodeID

type NodeID string

NodeID is a unique ID identifying each node. This identifier is used, for instance, to connect nodes within the network. In Opera, this ID is known as an 'enode' identifier.

type URL

type URL string

URL is a mere alias type for a string supposed to encode a URL.

type Validator

type Validator struct {
	Name           string
	Failing        bool
	Instances      int
	ImageName      string
	Stake          uint64 // < Stake in FTM
	ExtraArguments string // Extra command line arguments for sonicd
}

Validator is a configuration for a group of network start-up validators.

type Validators

type Validators []Validator

func DefaultValidators

func DefaultValidators(name string) Validators

DefaultValidators is a default configuration for a single validator.

func NewDefaultTestValidators

func NewDefaultTestValidators(name string, instances int) Validators

func NewDefaultValidators

func NewDefaultValidators(instances int) Validators

NewDefaultValidators creates a new Validators with a single validator defining only the number of instances, using the default client docker image.

func (Validators) GetNumValidators

func (v Validators) GetNumValidators() int

Directories

Path Synopsis
Package checking is a generated GoMock package.
Package checking is a generated GoMock package.
Package executor is a generated GoMock package.
Package executor is a generated GoMock package.
globalflags is a package that provides global flags for the driver.
globalflags is a package that provides global flags for the driver.
Package monitoring is a generated GoMock package.
Package monitoring is a generated GoMock package.
app
Package network is a generated GoMock package.
Package network is a generated GoMock package.
rpc
Package rpc is a generated GoMock package.
Package rpc is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL