runner

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//nolint:revive // LeaderNode and FollowerNode represent db nodes role.
	LeaderNode   = "leader"
	FollowerNode = "follower"
)
View Source
const (
	Orderer = 1 << iota
	Sidecar
	Coordinator
	Verifier
	VC
	QueryService

	LoadGenForOnlyOrderer
	LoadGenForOrderer
	LoadGenForCommitter
	LoadGenForCoordinator
	LoadGenForVerifier
	LoadGenForVCService
	LoadGenForDistributedLoadGen

	CommitterTxPath       = Sidecar | Coordinator | Verifier | VC
	FullTxPath            = Orderer | CommitterTxPath
	FullTxPathWithLoadGen = FullTxPath | LoadGenForOrderer
	FullTxPathWithQuery   = FullTxPath | QueryService

	CommitterTxPathWithLoadGen = CommitterTxPath | LoadGenForCommitter
)

Service flags.

Variables

This section is empty.

Functions

func Run

func Run(cmd *exec.Cmd, name, startCheck string) ifrit.Process

Run executes the specified command and returns the corresponding process. It is important to note that the underlying invocation function (Invoke) returns only when either process.Ready or process.Wait has been read. Consequently, the caller only needs to read process.Wait to wait for the process to complete and capture any errors that may have occurred during execution.

Types

type CmdParameters

type CmdParameters struct {
	Name     string
	Bin      string
	Arg      string
	Template string
}

CmdParameters holds the parameters for a command.

type CommitterRuntime

type CommitterRuntime struct {
	SystemConfig config.SystemConfig

	MockOrderer  *ProcessWithConfig
	Sidecar      *ProcessWithConfig
	Coordinator  *ProcessWithConfig
	QueryService *ProcessWithConfig
	Verifier     []*ProcessWithConfig
	VcService    []*ProcessWithConfig

	CoordinatorClient  protocoordinatorservice.CoordinatorClient
	QueryServiceClient protoqueryservice.QueryServiceClient

	CommittedBlock chan *common.Block

	LastReceivedBlockNumber uint64
	// contains filtered or unexported fields
}

CommitterRuntime represents a test system of Coordinator, SigVerifier, VCService and Query processes.

func NewRuntime

func NewRuntime(t *testing.T, conf *Config) *CommitterRuntime

NewRuntime creates a new test runtime.

func (*CommitterRuntime) AddSignatures

func (c *CommitterRuntime) AddSignatures(t *testing.T, tx *protoblocktx.Tx)

AddSignatures adds signature for each namespace in a given transaction.

func (*CommitterRuntime) CountAlternateStatus

func (c *CommitterRuntime) CountAlternateStatus(t *testing.T, status protoblocktx.Status) int

CountAlternateStatus returns the number of transactions not with a given tx status.

func (*CommitterRuntime) CountStatus

func (c *CommitterRuntime) CountStatus(t *testing.T, status protoblocktx.Status) int

CountStatus returns the number of transactions with a given tx status.

func (*CommitterRuntime) CreateCryptoForNs

func (c *CommitterRuntime) CreateCryptoForNs(t *testing.T, nsID string, schema signature.Scheme) *Crypto

CreateCryptoForNs creates Crypto materials for a namespace and stores it locally. It will fail the test if we create crypto material twice for the same namespace.

func (*CommitterRuntime) CreateMetaTX

func (c *CommitterRuntime) CreateMetaTX(t *testing.T, namespaces ...string) *protoblocktx.Tx

CreateMetaTX creates a meta transaction without submitting it.

func (*CommitterRuntime) CreateNamespacesAndCommit

func (c *CommitterRuntime) CreateNamespacesAndCommit(t *testing.T, namespaces ...string)

CreateNamespacesAndCommit creates namespaces in the committer.

func (*CommitterRuntime) GerOrCreateCryptoForNs

func (c *CommitterRuntime) GerOrCreateCryptoForNs(t *testing.T, nsID string, schema signature.Scheme) *Crypto

GerOrCreateCryptoForNs creates Crypto materials for a namespace and stores it locally. It will get existing material if it already exists.

func (*CommitterRuntime) GetAllCrypto

func (c *CommitterRuntime) GetAllCrypto() []*Crypto

GetAllCrypto returns all the Crypto material.

func (*CommitterRuntime) GetCryptoForNs

func (c *CommitterRuntime) GetCryptoForNs(t *testing.T, nsID string) *Crypto

GetCryptoForNs returns the Crypto material a namespace.

func (*CommitterRuntime) SendTransactionsToOrderer

func (c *CommitterRuntime) SendTransactionsToOrderer(t *testing.T, txs []*protoblocktx.Tx)

SendTransactionsToOrderer creates a block with given transactions and sent it to the committer.

func (*CommitterRuntime) Start

func (c *CommitterRuntime) Start(t *testing.T, serviceFlags int)

Start runs all services and load generator as configured by the serviceFlags.

func (*CommitterRuntime) UpdateCryptoForNs

func (c *CommitterRuntime) UpdateCryptoForNs(t *testing.T, nsID string, schema signature.Scheme) *Crypto

UpdateCryptoForNs creates Crypto materials for a namespace and stores it locally. It will fail the test if we create crypto material for the first time.

func (*CommitterRuntime) ValidateExpectedResultsInCommittedBlock

func (c *CommitterRuntime) ValidateExpectedResultsInCommittedBlock(t *testing.T, expected *ExpectedStatusInBlock)

ValidateExpectedResultsInCommittedBlock validates the status of transactions in the committed block.

type Config

type Config struct {
	NumVerifiers      int
	NumVCService      int
	BlockSize         uint64
	BlockTimeout      time.Duration
	LoadgenBlockLimit uint64

	// DBCluster configures the cluster to operate in DB cluster mode.
	DBCluster *dbtest.Connection
}

Config represents the runtime configuration.

type Crypto

type Crypto struct {
	Namespace  string
	Profile    *workload.Policy
	HashSigner *workload.HashSignerVerifier
	NsSigner   *sigtest.NsSigner
	PubKey     []byte
	PubKeyPath string
}

Crypto holds crypto material for a namespace.

type DBClusterController

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

DBClusterController is a class that facilitates the manipulation of a DB cluster, with its nodes running in Docker containers.

func (*DBClusterController) GetClusterSize

func (cc *DBClusterController) GetClusterSize() int

GetClusterSize returns the number of active nodes in the cluster.

func (*DBClusterController) GetNodesContainerID

func (cc *DBClusterController) GetNodesContainerID(t *testing.T) []string

GetNodesContainerID returns the container IDs of the current nodes.

func (*DBClusterController) StopAndRemoveNodeWithRole

func (cc *DBClusterController) StopAndRemoveNodeWithRole(t *testing.T, role string)

StopAndRemoveNodeWithRole stops and removes a node given a role.

type ExpectedStatusInBlock

type ExpectedStatusInBlock struct {
	TxIDs    []string
	Statuses []protoblocktx.Status
}

ExpectedStatusInBlock holds pairs of expected txID and the corresponding status in a block. The order of statuses is expected to be the same as in the committed block.

type PostgresClusterController

type PostgresClusterController struct {
	DBClusterController
}

PostgresClusterController is a struct that facilitates the manipulation of postgres cluster, with its nodes running in Docker containers. We create a cluster of size 2; one primary and one secondary.

func StartPostgresCluster

func StartPostgresCluster(ctx context.Context, t *testing.T) (*PostgresClusterController, *dbtest.Connection)

StartPostgresCluster creates a postgres cluster in a Docker environment and returns its connection properties.

func (*PostgresClusterController) PromoteFollowerNode

func (cc *PostgresClusterController) PromoteFollowerNode(t *testing.T)

PromoteFollowerNode runs a script that promotes the first follower db node it finds, from read-only to read-write node.

type ProcessWithConfig

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

ProcessWithConfig holds the ifrit process and the corresponding configuration.

func (*ProcessWithConfig) Restart

func (p *ProcessWithConfig) Restart(t *testing.T)

Restart stops the process if it is running and then starts it.

func (*ProcessWithConfig) Stop

func (p *ProcessWithConfig) Stop(t *testing.T)

Stop stops the running process.

type YugaClusterController

type YugaClusterController struct {
	DBClusterController
}

YugaClusterController is a struct that facilitates the manipulation of a DB cluster, with its nodes running in Docker containers.

To create the cluster, we are using Yugabyte's preconfigured tool, which is set up as follows: 1. If the cluster size is greater than or equal to 3, the replication factor (RF) is set to 3; otherwise, RF is set to 1. 2. The cluster supports a maximum of 3 master nodes. Therefore, a cluster with more than 3 master nodes cannot be created. Any additional node will act as a tserver node.

In addition, RF=3 supports the failure of one master node, while RF=1 does not provide resilience to node failures. There are some bugs in YugaDB that prevent the cluster behavior from functioning as expected: 1. After a master-node is deleted, a new master-node cannot be added to the cluster as a replacement. 2. If the leader node is failing, the whole db connectivity will stop functioning.

func StartYugaCluster

func StartYugaCluster(ctx context.Context, t *testing.T, clusterSize uint) (
	*YugaClusterController, *dbtest.Connection,
)

StartYugaCluster creates a Yugabyte cluster in a Docker environment and returns its connection properties.

func (*YugaClusterController) AddNode

AddNode creates, starts and add a YugabyteDB node to the cluster.

Jump to

Keyboard shortcuts

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