common

package
v0.0.0-...-2f16193 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 9 Imported by: 20

Documentation

Index

Constants

View Source
const (
	BenchmarkDirPath     = "__BenchmarkDirPath__"
	BenchmarkArchivePath = "__BenchmarkArchivePath__"
)

config path

View Source
const (
	WorkerPath    = "worker"
	WorkerCapPath = "worker.cap"
)

worker

View Source
const (
	CollectorSummaryMode = "summary"
	CollectorDetailsMode = "details"
)

collector mode

View Source
const (
	EnginePath         = "engine"
	EngineRatePath     = "engine.rate"
	EngineDurationPath = "engine.duration"
	EngineCapPath      = "engine.cap"
	EngineURLsPath     = "engine.urls"
)

engine

View Source
const (
	ClientScriptPath       = "client.script"
	ClientTypePath         = "client.type"
	ClientConfigPath       = "client.config"
	ClientContractPath     = "client.contract"
	ClientContractArgsPath = "client.args"
	ClientOptionPath       = "client.options"
	ClientPluginPath       = "client.plugin"
)

client

View Source
const (
	//
	RecorderCsvPath    = "recorder.csv"
	RecorderCsvDirPath = "recorder.csv.dir"
	// log
	LogLevelPath = "recorder.log.level"
	LogDirPath   = "recorder.log.dir"
	LogDumpPath  = "recorder.log.dump"
)

recorder

View Source
const (
	InvalidLabel         = ""
	BuiltinTransferLabel = "__transfer"
	InvalidUID           = "0x0"
)

Builtin

View Source
const (
	CollectorModePath = "collector.mode"
)

collector

View Source
const (
	WorkersPath = "workers"
)

workers

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(module string) *logging.Logger

GetLogger get logging.Logger with module

func InitLog

func InitLog() string

InitLog init log

Types

type AggData

type AggData struct {
	// key
	Label    string
	Time     int64
	Duration int64

	// request
	Num      int
	Statuses map[Status]int

	// latency
	Send    Latency
	Confirm Latency
	Write   Latency
}

AggData aggregation data.

type Blockchain

type Blockchain interface {

	// DeployContract should deploy contract with config file
	DeployContract() error

	// Invoke just invoke the contract
	Invoke(Invoke, ...Option) *Result

	// Transfer a amount of money from a account to the other one
	Transfer(Transfer, ...Option) *Result

	// Confirm check the result of `Invoke` or `Transfer`
	Confirm(*Result, ...Option) *Result

	// Query do some query
	Query(Query, ...Option) interface{}

	// Option pass the options to affect the action of client
	Option(Option) error

	// GetContext Generate TxContext based on New/Init/DeployContract
	// GetContext will only be run in master
	// return the information how to invoke the contract, maybe include
	// contract address, abi or so.
	// the return value will be send to worker to tell them how to invoke the contract
	GetContext() (string, error)

	// SetContext set test context into go client
	// SetContext will be run once per worker
	SetContext(ctx string) error

	// ResetContext reset test group context in go client
	ResetContext() error

	// Statistic query the statistics information in the time interval defined by
	// nanosecond-level timestamps `from` and `to`
	Statistic(statistic Statistic) (*RemoteStatistic, error)

	// LogStatus records blockheight and time
	LogStatus() (int64, error)
}

Blockchain define the service need provided in blockchain.

type Context

type Context string

Context the context in vm.

type Data

type Data struct {
	// Type data type.
	Type DataType
	// Results the slice of AggData.
	Results []AggData
}

Data define the data which will be reported.

type DataType

type DataType string

DataType data type.

const (
	// Cur current data type.
	Cur DataType = "Cur"
	// Sum sum data type.
	Sum DataType = "Sum"
)

type Invoke

type Invoke struct {
	Func string        `mapstructure:"func"`
	Args []interface{} `mapstructure:"args"`
}

Invoke define need filed for invoke contract.

type Latency

type Latency struct {
	Avg  int64 // Avg is the average latency
	P0   int64 // P0  is the minimal latency
	P50  int64 // P50 is the median of latency
	P90  int64 // P90 is the latency exactly larger than 90%
	P95  int64 // P90 is the latency exactly larger than 95%
	P99  int64 // P99 is the latency exactly larger than 95%
	P100 int64 // P100 is the maximal latency
}

Latency is the percent of latency in increase order

type Option

type Option map[string]interface{}

Option for receive options.

type Query

type Query struct {
	Func string        `mapstructure:"func"`
	Args []interface{} `mapstructure:"args"`
}

Query define need filed for query info.

type RemoteStatistic

type RemoteStatistic struct {
	// time info
	Start int64
	End   int64
	// block info
	BlockNum int
	// transaction info of blockchain
	TxNum int
	// tps of blockchain
	CTps float64
	// bps of blockchain
	Bps float64
	// sent transaction info
	SentTx int64
	// missed transaction info
	MissedTx int64
	// tps of system
	Tps float64
}

RemoteStatistic remote statistic data.

type Report

type Report struct {
	Cur *Data
	Sum *Data
}

Report contains need report data about tx been executed info.

type Result

type Result struct {
	// Label is the group name of sent transaction
	Label string `mapstructure:"label"`
	// UID is the unique id of sent transaction
	UID string `mapstructure:"uid"`
	// BuildTime is the client start time when client constructs transaction
	BuildTime int64 `mapstructure:"build"`
	// SendTime is the client time when client receives transaction response
	SendTime int64 `mapstructure:"send"`
	// ConfirmTime is the client time when client check transaction is written in block stably
	ConfirmTime int64 `mapstructure:"confirm"`
	// WriteTime is the node time when transaction is written in block stably
	WriteTime int64 `mapstructure:"write"`
	// Status marks the status of transaction
	Status Status `mapstructure:"status"`
	// Ret is the return value of transaction
	Ret []interface{} `mapstructure:"ret"`
}

Result define the filed for describe tx invoke result.

type Statistic

type Statistic struct {
	From int64 `mapstructure:"from"`
	To   int64 `mapstructure:"to"`
}

Statistic contains statistic time.

type Status

type Status string

Status tx execute status.

const (
	// Failure means client sent transaction unsuccessfully
	Failure Status = "failure"
	// Success means client sent transaction successfully
	Success Status = "success"
	// Unknown means sent transaction isn't written in block stably for asynchronous processing
	Unknown Status = "unknown"
	// Confirm means sent transaction is written in block stably for asynchronous processing
	Confirm Status = "confirm"
)

type Transfer

type Transfer struct {
	From   string `mapstructure:"from"`
	To     string `mapstructure:"to"`
	Amount int64  `mapstructure:"amount"`
	Extra  string `mapstructure:"extra"`
}

Transfer define need filed for transfer.

type TxContext

type TxContext struct {
	context.Context
	TxIndex
}

TxContext is the context of transaction (`vm.Run`)

type TxIndex

type TxIndex struct {
	EngineIdx int64 // EngineIdx is the index of engine (maybe support multiple test stage in future)
	TxIdx     int64 // TxIdx is the index of sent transaction
	MissIdx   int64 // MissIdx is the index of missed transaction
}

TxIndex is the unique index of a transaction (`vm.Run`)

type VMContext

type VMContext struct {
	WorkerIdx int64 `mapstructure:"worker"` // WorkerIdx is the index of worker
	VMIdx     int64 `mapstructure:"vm"`     // VMIdx is the index of vm
}

VMContext is the context of vm

Jump to

Keyboard shortcuts

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