common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DETAIL  = "detail"
	DEBUG   = "debug"
	INFO    = "info"
	WARNING = "warning"
	ERROR   = "error"
)
View Source
const (
	ModuleProto   = "proto"
	ModuleControl = "control"
	ModuleCommon  = "common"
	ModuleDB      = "db"
	ModuleUtil    = "util"
	ModuleBuiltin = "builtin"
	ModulePlugin  = "plugin"
	ModuleParser  = "parser"
	ModuleRunner  = "runner"
	ModuleBuilder = "builder"
	ModuleRule    = "rule"
	ModuleReport  = "report"
)
View Source
const (
	MethodPost    = "POST"
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH"
	MethodDelete  = "DELETE"
	MethodOptions = "OPTIONS"
)
View Source
const (
	CmdPython = "python"
	CmdJava   = "java"
)
View Source
const (
	ParserGlobal        = "global"
	ParserCommon        = "common"
	ParserTemplates     = "templates"
	ParserPlugins       = "plugins"
	ParserTC            = "testcases"
	ParserRules         = "rules"
	ModuleConfig        = "config"
	ModuleControlFlow   = "control_flow"
	ModulePreCondition  = "pre_condition"
	ModulePostCondition = "post_condition"
	ModuleCheck         = "checkpoints"
)
View Source
const (
	SRC = "src"
	BIN = "bin"
	RPC = "rpc"
)
View Source
const (
	ProtoHTTP = "http"
	ProtoTCP  = "TCP"
	ProtoUDP  = "UDP"
)
View Source
const (
	ZERO             = "0"
	HYPHEN           = "-"
	UnderScope       = "_"
	DoubleUnderScope = "__"
	COMMA            = ","
	AND              = "&"
	DOT              = "."
	DoubleQuotes     = "\""
	DoubleQuotes2    = "\"\""
	EMPTY            = ""
	EOF              = "<!-- EOF -->"
	SPACE            = " "
	SLASH            = "/"
	PLUS             = "+"
	STAR             = "*"
	WILDCARD         = ".*"
	QuestionMark     = "?"
	COLON            = ":"
	AT               = "@"
	LeftBracket      = "["
	RightBracket     = "]"
	LeftParentheses  = "("
	RightParentheses = ")"
	LeftBrace        = "{"
	RightBrace       = "}"
	NUMBER           = "#"
	PARALLEL         = "||"
	VerticalBar      = "|"
	BACKSLASH        = "\\"
	NEWLINE          = "\n"
	OK               = "ok"
	BoundaryChars    = "[__0__]"
	NoChars          = " __NO_CHARS__ "
)
View Source
const (
	HeaderCT = "Content-Type"
	CTJson   = "application/json;charset=utf-8"
	HCookie  = "Cookie"
)
View Source
const (
	SpaceChar        = 32
	DoubleQuotesChar = 34
	SingleQuotesChar = 39
)
View Source
const (
	PathInit = "/init"
	PathRun  = "/run"
)
View Source
const (
	OpEqual      = "="
	NotPresent   = "--"
	ExtraPresent = "++"
	NotEqual     = "!="
	MoreThan     = ">"
	LessThan     = "<"
	OpInput      = "<-"
	OpOr         = "|" // 或运算符
	OpEOR        = "^" // 异或运算符
	OpAnd        = "&" // 与运算符
	OpNot        = "~" // 非运算符
	OpConstruct  = "->"
	OpOn         = "on"
	SpaceOn      = " on "
	OR           = "or"
	SpaceOR      = " or "
	OpWith       = "with"
	SpaceWith    = " with "
	OpWithout    = "without"
	SpaceWithout = " without "
	OpMulti      = "*"
	OpDiv        = "/"
	OpSub        = "-"
	OpPlus       = "+"
	OpLP         = "("
	OpRP         = ")"
	OpMod        = "%"  // 取模
	OpPower      = "**" // 幂运算
	OpLS         = "<<" // 左移
	OpRS         = ">>" // 左移
	OpColon      = ":"
	OpDot        = "."
	OpDotDot     = ".."
	OpDotDotDot  = "..."
)

OpCode

View Source
const (
	REQUEST  = "Request"
	REQUEST2 = "request"
	REQUEST3 = "REQUEST"
	CTX      = "x"
	CtxP     = "x."
)

系统保留关键字

View Source
const (
	ActSend    = "send"
	AKSend     = "s"
	ActReceive = "receive"
	AKReceive  = "r"
	ActDB      = "db"
	ActKeyDB   = "db"
	ActCache   = "cache"
	AKCache    = "c"
	ActHttp    = "http"
	AKHttp     = "h"
	ActHttps   = "https"
	AKHttps    = "hs"
	ActMock    = "mock"
	AKMock     = "m"
	ActAndroid = "android"
	AKAndroid  = "a"
	ActWEB     = "web"
	ActKeyWEB  = "w"
	ActIOS     = "ios"
	ActKeyIOS  = "ios"
	ActROS     = "ros"
	ActKeyROS  = "ros"
	ActCOM     = "com"
	ActKeyCOM  = "com"
)

消息模板的动作标志位

View Source
const (
	KeyArgs    = "a"
	Args       = "args"
	KeyBuffer  = "b"
	Buffer     = "buffer"
	KeyHeader  = "h"
	Header     = "header"
	KeyMainMsg = "msg"
	MainMsg    = "msg"
	KeyPath    = "p"
	Path       = "path"
	KeyResp    = "r"
	Resp       = "resp"
	KeyTopic   = "t"
	Topic      = "topic"
)
View Source
const (
	RAFile   = "file"
	RAFileZ  = "_file"
	RATotal  = "total"
	RATotalZ = "_total"
	RAResp   = "resp"
	RACode   = "code"
	RAHead   = "head"
)

保留属性

View Source
const (
	CFUrl    = "URL"
	CFMethod = "METHOD"
	CFName   = "NAME"
)
View Source
const (
	SActions = "ACTIONS"
	SAttrs   = "ATTRS"
	SPorts   = "PORTS"
)
View Source
const (
	HttpOnReadySending = "http.OnReadySending"
	HttpOnSending      = "http.OnSending"
	HttpOnReceived     = "http.OnReceived"
	HttpOnError        = "http.OnError"
)
View Source
const (
	DefaultPort = 9899
	DefaultDNS  = "8.8.8.8:80"
)
View Source
const (
	ZIP = "zip"
	GZ  = "gz"
	XZ  = "xz"
	TGZ = "tgz"
	TXZ = "txz"
	SZ  = "7z"
	TAR = "tar"
)

Plugin Archived File

View Source
const (
	ExtJson = ".json"
	ExtTxt  = ".txt"
	ExtLog  = ".log"
	ExtCfg  = ".cfg"
	ExtIni  = ".ini"
	ExtMd   = ".md"
	ExtGo   = ".go"
	ExtJava = ".java"
	ExtBash = ".bash"
	ExtSh   = ".sh"
	ExtZsh  = ".zsh"
	ExtPy   = ".py"
	ExtJar  = ".jar"
	ExtJs   = ".js"
	ExtTs   = ".ts"
	ExtSo   = ".so"
	ExtDLL  = ".dll"
	ExtEXE  = ".exe"
)
View Source
const (
	SUCCESSFUL = 0
	FAILED     = 1
	UNDEFINED  = -1
	QUIT       = 1
	DONE       = 1
)
View Source
const (
	MsgSuccessful      = "success"
	MsgUnknownRule     = "unknown rule"
	MsgIncompleteRule  = "incomplete rule"
	MsgInvalid         = "invalid rule"
	MsgDuplicatedName  = "duplicated name"
	MsgUnknownFunction = "unknown function"
	MsgExecutionFailed = "execution failed"
	MsgSetupFailed     = "setup failed"
	MsgTeardownFailed  = "teardown failed"
)
View Source
const (
	MF  = "makefile"
	MF2 = "Makefile"
	MF3 = "MAKEFILE"
)
View Source
const (
	EXECUTING = 0
	PARSING   = 1
)
View Source
const (
	Set        = 0
	Get        = 1
	Delete     = 2
	GetALLData = 3
	GetALLKeys = 4
)

缓存、DB操作码

View Source
const (
	PluginsPath        = "plugins_path"
	DBPath             = "db_path"
	TPath              = "testing"
	CasesFolder        = "testcases"
	DefaultPluginsPath = "plugins/dragon"
	DefaultPluginName  = "start.sh"
	DefaultDBPath      = "db/dragon"
	DefaultTPath       = "testing"
)
View Source
const (
	LOCALHOST = "localhost"
	PubDNS    = "publicDNS"
	PubIP     = "publicIP"
)
View Source
const (
	INIT     = 0
	MaxTry   = 1
	MaxRetry = 10
)
View Source
const (
	MarkdownType   = "*.md"
	MarkdownSuffix = ".md"
)
View Source
const (
	SETTING          = "# 设置"
	NODE             = "# 节点"
	MessageConstruct = "# 消息构造"
	DataConstruct    = "# 数据构造"
	PLUGIN           = "# 插件"
	ControlFlow      = "# 控制流"
	SETUP            = "# 前置条件"
	TEARDOWN         = "# 后置条件"
	CHECK            = "# 校验"
	CASE             = "# 用例"
	FLOW             = "# 流程"
)
View Source
const (
	SettingEN          = "# Setting"
	NodeEN             = "# Node"
	MessageConstructEN = "# Message Construct"
	DataConstructEN    = "# Data Construct"
	PluginEN           = "# Plugin"
	ControlFlowEN      = "# Control Flow"
	SetupEN            = "# Setup"
	TeardownEN         = "# Teardown"
	CheckEN            = "# Check"
	CaseEN             = "# Case"
	FlowEN             = "# Flow"
)
View Source
const (
	CaseVar = 0
	CFVar   = 1
	FlowVar = 2
)

变量类型

View Source
const (
	MarkRegion    = "# "
	MarkRegion2   = "## "
	MarkRegion3   = "### "
	MarkClass     = "> "
	MarkClass2    = ">> "
	MarkComment   = "***"
	MarkComment2  = "//"
	MarkItem      = "* "
	MarkConstruct = "->"
	MarkExpect    = "=>"
)
View Source
const (
	MaxRange   = 100
	MaxQueue   = 6
	MaxBinRead = 100
)
View Source
const (
	// Random相关
	FuncNameUUID         = "UUID"
	FuncNameRandom       = "Random"
	FuncNameRandomString = "RandomString"
	FuncNameRandomDigit  = "RandomDigit"
	// Convert相关
	FuncNameFormatDate         = "FormatDate"
	FuncNameDATE               = "DATE"
	FuncNameFormatTime         = "FormatTime"
	FuncNameTIME               = "TIME"
	FuncNameFormatSeconds      = "FormatSeconds"
	FuncNameSEC                = "SEC"
	FuncNameFormatNowInSeconds = "FormatNowInSeconds"
	FuncNameNOW                = "NOW"
	FuncNameNowAddSeconds      = "NowAddSeconds"
	FuncNameNowMS              = "NowMS"
	FuncNameMD5                = "MD5"
	FuncNameSHA1               = "SHA1"
	FuncNameBase64             = "Base64"
	// Testing相关
	FuncNameRequest = "Request"
	// 其他
	FuncNameLog = "Log"
)
View Source
const (
	WaitTask = 0
	RunTask  = 1
)

记录当前Task状态

View Source
const (
	CHARS              = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	DIGITS             = "0123456789"
	DefaultCharsLength = 10
)

Random相关常量

View Source
const (
	ALL    = "all"
	RANDOM = "random"
)

用例属性

View Source
const (
	FillRandom = 0
	FillAll    = 1
)
View Source
const (
	ScopeGroup   = "G"
	ScopeCase    = "C"
	ScopeSuite   = "S"
	ScopeAll     = "A"
	ScopeDiscard = "D"
)
View Source
const (
	HTTP  = "http"
	HTTPS = "https"
)
View Source
const (
	AuthorCN      = "作者"
	AuthorEN      = "author"
	MaintainerCN  = "维护者"
	MaintainerEN  = "maintainer"
	BugsCN        = "问题"
	BugsEN        = "bugs"
	FeaturesCN    = "需求"
	FeaturesEN    = "features"
	VersionCN     = "版本"
	VersionEN     = "version"
	TagsCN        = "标签"
	TagsEN        = "tags"
	LevelCN       = "等级"
	LevelEN       = "level"
	ModeCN        = "模式"
	ModeEN        = "mode"
	ProtoCN       = "协议"
	ProtoEN       = "proto"
	ClosedCN      = "关闭"
	ClosedEN      = "closed"
	HostCN        = "主机"
	HostEN        = "host"
	PortCN        = "端口"
	PortEN        = "port"
	TimeoutCN     = "超时"
	TimeoutEN     = "T"
	ConcurrenceCN = "并发"
	ConcurrenceEN = "C"
	RoundsCN      = "轮次"
	RoundsEN      = "R"
	FillCN        = "填充"
	FillEN        = "fill"
	NameCN        = "名称"
	NameEN        = "name"
	StartCN       = "启动"
	StartEN       = "start"
	BuildCN       = "构建"
	BuildEN       = "build"
	CallsCN       = "调用"
	CallsEN       = "calls"
	MutesCN       = "屏蔽"
	MutesEN       = "mutes"
	HostsCN       = "主机"
	HostsEN       = "hosts"
	ProxyCN       = "代理"
	ProxyEN       = "proxy"
	PluginsCN     = "插件"
	PluginsEN     = "plugins"
	ArgsCN        = "参数"
	ArgsEN        = "args"
	MatchCN       = "匹配"
	MatchEN       = "match"
	ScopeCN       = "范围"
	ScopeEN       = "scope"
	SetupsCN      = "前置"
	SetupsEN      = "setup"
	TeardownsCN   = "后置"
	TeardownsEN   = "teardown"
	ExtendCN      = "扩展"
	ExtendEN      = "E"
	UserCN        = "用户"
	UserEN        = "user"
	PassCN        = "密码"
	PassEN        = "pass"
	PathCN        = "路径"
	PathEN        = "path"
	MethodCN      = "方法"
	MethodEN      = "method"
	TunnelCN      = "通道"
	TunnelEN      = "tunnel"
	TunUserCN     = "通道用户"
	TunUserEN     = "sshuser"
	TunPassCN     = "通道密码"
	TunPassEN     = "sshpass"
	RandomCN      = "随机"
	RandomEN      = "random"
	LocalCN       = "本地"
	LocalEN       = "local"
)
View Source
const (
	STR       = "STR"
	BYTES     = "BYTES"
	INT       = "INT"
	UINT      = "UINT"
	FLOAT     = "FLOAT"
	BOOL      = "BOOL"
	LIST      = "LIST"
	ListBytes = "ListBytes"
	MAP       = "MAP"
	MapBytes  = "MapBytes"
	NULL      = "NULL"
)
View Source
const (
	ArgJar = "-jar"
)
View Source
const (
	DefaultTimeout = int64(0) // 永不超时
)
View Source
const (
	FuncProfiling = "profiling"
)
View Source
const (
	OSWindows = "windows"
)
View Source
const (
	PROJECT = "DRAGON"
)
View Source
const (
	StaticHosts = "HOSTS"
)

Variables

This section is empty.

Functions

func AddBackSlash

func AddBackSlash(text, char string) string

func AddDot

func AddDot(marks ...string) []string

func AddFields

func AddFields(data interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func AddJSON

func AddJSON(msg interface{}, value []interface{}, keys []FormatType) interface{}

func AddJsonList

func AddJsonList(data []interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func AddJsonMap

func AddJsonMap(data map[string]interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func AddUnderScope

func AddUnderScope(s string) string

func AlignType

func AlignType(field, value interface{}) interface{}

func AnyChannel

func AnyChannel(key interface{}) chan interface{}

func AnyMapChannel

func AnyMapChannel(key interface{}) chan map[interface{}]interface{}

func AssertOK

func AssertOK(err error, params ...interface{})

func Base64Decode

func Base64Decode(data string) []byte

func Base64Encode

func Base64Encode(data []byte) string

func BasicOps

func BasicOps() []string

func ByteChannel

func ByteChannel(key interface{}) chan byte

func BytesChannel

func BytesChannel(key interface{}) chan []byte

func BytesMapChannel

func BytesMapChannel(key interface{}) chan map[string][]byte

func Calculate

func Calculate(input string) string

func CheckExpected

func CheckExpected(expect interface{}, op string, receive interface{}) bool

func CheckFields

func CheckFields(data interface{}, keys []FormatType) bool

func CheckJsonList

func CheckJsonList(data []interface{}, keys []FormatType) bool

func CheckJsonMap

func CheckJsonMap(data map[string]interface{}, keys []FormatType) bool

func CheckType

func CheckType(v interface{}, expect reflect.Kind) bool

func CheckTypes

func CheckTypes(v interface{}, expects []reflect.Kind) bool

func CombineOps

func CombineOps() []string

func CompareDigits

func CompareDigits(expect, op, receive string) bool

func ConstructData

func ConstructData(s string, c []byte, r *ConstructType) (int, string)

func ConstructMessage

func ConstructMessage(s string, c []byte, r *ConstructType) (int, string)

func ConvertSpacesInsideQuotes

func ConvertSpacesInsideQuotes(c []byte) []byte

func ConvertValue

func ConvertValue(v string) interface{}

func CopyVarData

func CopyVarData(key string, src *VarData, dst map[string]*VarData)

func CopyVarDataMap

func CopyVarDataMap(src, dst map[string]*VarData)

func Debug

func Debug(params ...interface{})

func DecodeJsonList

func DecodeJsonList(b []byte, p *PluginType) []map[string][]byte

func DecodeJsonListByte

func DecodeJsonListByte(b []byte) []map[string][]byte

func DecodeJsonListStr

func DecodeJsonListStr(b []byte) []map[string][]byte

func Decompress

func Decompress(dst, src string) (int, []string)

func DeleteFields

func DeleteFields(data interface{}, keys []FormatType) interface{}

func DeleteJSON

func DeleteJSON(msg interface{}, keys []FormatType) interface{}

func DeleteJsonList

func DeleteJsonList(data []interface{}, keys []FormatType) interface{}

func DeleteJsonMap

func DeleteJsonMap(data map[string]interface{}, keys []FormatType) interface{}

func Detail

func Detail(params ...interface{})

func Equal

func Equal(c string, marks ...string) bool

func Err

func Err(params ...interface{})

func EvalVarData

func EvalVarData(key, s string, vd *VarData) string

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func FatalError

func FatalError(params ...interface{})

func Find

func Find(c []byte, marks ...string) int

func Finish

func Finish(done chan int)

func Func

func Func(skip int) (string, string, int)

func FuncName

func FuncName() string

func GetAllFromFields

func GetAllFromFields(data interface{}, keys []FormatType, value map[string]interface{}, path string)

func GetAllFromJsonList

func GetAllFromJsonList(data []interface{}, keys []FormatType, value map[string]interface{}, path string)

func GetAllFromJsonMap

func GetAllFromJsonMap(data map[string]interface{}, keys []FormatType, value map[string]interface{}, path string)

func GetAllJSON

func GetAllJSON(msg interface{}, keys []FormatType, value map[string]interface{})

func GetAny

func GetAny(key string, defaultValue interface{}) interface{}

func GetBinPath

func GetBinPath() string

func GetBuiltin

func GetBuiltin(key string) interface{}

func GetCall

func GetCall(call string) interface{}

func GetDir

func GetDir(path string) string

func GetFreePort

func GetFreePort() int

func GetFromFields

func GetFromFields(data interface{}, keys []FormatType) interface{}

func GetFromJsonList

func GetFromJsonList(data []interface{}, keys []FormatType) interface{}

func GetFromJsonMap

func GetFromJsonMap(data map[string]interface{}, keys []FormatType) interface{}

func GetIP

func GetIP(key string) string

func GetInit

func GetInit(ip string) bool

func GetInterval

func GetInterval() int

func GetJSON

func GetJSON(msg interface{}, keys []FormatType) interface{}

func GetLogLevel

func GetLogLevel() string

func GetLogModule

func GetLogModule(module string) bool

func GetPath

func GetPath(key, defaultValue string) string

func GetPlugin

func GetPlugin(service, defaultValue string) string

func GetPort

func GetPort(key string) int

func GetPublicIP

func GetPublicIP() string

func GetStatus

func GetStatus(ip string) int

func GetTask

func GetTask(task string) bool

func GobDecode

func GobDecode(p []byte, v interface{}) error

func GobEncode

func GobEncode(v interface{}) []byte

func GunzipTar

func GunzipTar(dst, src string) (int, []string)

func HasKey

func HasKey(key string, s []string) bool

func IfToBase64

func IfToBase64(v interface{}) string

func IfToBytes

func IfToBytes(v interface{}) []byte

func IfToFloat

func IfToFloat(v interface{}) float64

func IfToInt

func IfToInt(v interface{}) int64

func IfToJsonByte

func IfToJsonByte(v interface{}) [][]byte

func IfToJsonStr

func IfToJsonStr(v interface{}) []string

func IfToString

func IfToString(v interface{}) string

func IfToUInt

func IfToUInt(v interface{}) uint64

func Info

func Info(params ...interface{})

func InitChannels

func InitChannels()

func InitGlobalConfig

func InitGlobalConfig()

func InitLogConfig

func InitLogConfig()

func IntChannel

func IntChannel(key interface{}) chan int

func IntMapChannel

func IntMapChannel(key interface{}) chan map[string]int

func IsAction

func IsAction(key string) bool

func IsBool

func IsBool(v interface{}) bool

func IsBuiltin

func IsBuiltin(key string) bool

func IsBytes

func IsBytes(v interface{}) bool

func IsDigit

func IsDigit(v string) bool

func IsDir

func IsDir(path string) bool

判断所给路径文件夹是否存在

func IsField

func IsField(msg interface{}, keys []FormatType) bool

func IsFile

func IsFile(path string) bool

func IsFloat

func IsFloat(v interface{}) bool

func IsFlow

func IsFlow(key string, c *ConfigType, st *TestSuite) bool

func IsGoCode

func IsGoCode(p *PluginType) bool

func IsGroup

func IsGroup(key string, vt map[string]*VarType) bool

func IsHttpMethod

func IsHttpMethod(key string) bool

func IsInt

func IsInt(v interface{}) bool

func IsJsonList

func IsJsonList(buf []byte) bool

func IsJsonMap

func IsJsonMap(buf []byte) bool

func IsList

func IsList(v interface{}) bool

func IsListBytes

func IsListBytes(msg interface{}) bool

func IsMap

func IsMap(v interface{}) bool

func IsMapBytes

func IsMapBytes(msg interface{}) bool

func IsNewer

func IsNewer(new, old string) bool

func IsNull

func IsNull(v interface{}) bool

func IsOpVars

func IsOpVars(s string) bool

func IsPlugin

func IsPlugin(name string) bool

func IsPortUnavailable

func IsPortUnavailable(port int) bool

func IsReserved

func IsReserved(key string) bool

func IsString

func IsString(v interface{}) bool

func IsUInt

func IsUInt(v interface{}) bool

func Join

func Join(sep string, keys ...string) string

func JoinKeys

func JoinKeys(sep string, keys ...interface{}) string

func JsonListByte

func JsonListByte(params ...interface{}) []byte

func JsonListStr

func JsonListStr(params ...interface{}) []byte

func LoadKeys

func LoadKeys(cd *VarData, vt map[string]*VarType, s string)

func Log

func Log(params ...interface{})

func Log2

func Log2(params ...interface{})

func LowerCaseNoHyphen

func LowerCaseNoHyphen(s string) string

func MD5String

func MD5String(data ...string) string

func MD5Sum

func MD5Sum(data ...string) [16]byte

func MatchEnd

func MatchEnd(c []byte, marks ...string) bool

func MatchInside

func MatchInside(c []byte, marks ...string) bool

func MatchStart

func MatchStart(c []byte, marks ...string) bool

func NormalizeRegexp

func NormalizeRegexp(text string) string

func Now

func Now() string

func ParseJsonList

func ParseJsonList(buf []byte, key string, fields map[string][]FormatType, keys []FormatType) []interface{}

func ParseJsonMap

func ParseJsonMap(buf []byte, key string, fields map[string][]FormatType, keys []FormatType) map[string]interface{}

func ParseVar

func ParseVar(s string, vd *VarData) string

func ParserPath

func ParserPath(top, project, parser string, params ...string) string

func Profiling

func Profiling()

func ProfilingCPU

func ProfilingCPU(cpuProfile string)

func ProjectTasks

func ProjectTasks(path, key string) map[string]chan int

func RemoveProject

func RemoveProject(path, key string)

func RemoveProjectTask

func RemoveProjectTask(path, key, task string)

func RemoveTask

func RemoveTask(task string)

func ReplaceNoChars

func ReplaceNoChars(c []byte) []byte

func SHA1Sum

func SHA1Sum(data ...string) []byte

func SearchLongestMatchKey

func SearchLongestMatchKey(s []string, m map[string]int, b string) string

func SearchLongestMatchNode

func SearchLongestMatchNode(s []string, m map[string]*NodeType, b string) string

func SearchLongestMatchSetting

func SearchLongestMatchSetting(s []string, m map[string][]string, b string) string

func SetAny

func SetAny(key string, value interface{})

func SetCall

func SetCall(call string, value interface{})

func SetIP

func SetIP(key, ip string)

func SetInit

func SetInit(ip string)

func SetInterval

func SetInterval(interval int)

func SetLogLevel

func SetLogLevel(level string)

func SetLogModules

func SetLogModules(param string)

func SetPath

func SetPath(key, path string)

func SetPlugin

func SetPlugin(service, plugin string)

func SetPort

func SetPort(key string, port int)

func SetProjectTask

func SetProjectTask(path, key, task string, ch chan int)

func SetStatus

func SetStatus(ip string, status int)

func SetTask

func SetTask(task string)

func SortMap

func SortMap(x interface{}) string

func SplitKeys

func SplitKeys(s string, keys ...string) []string

func SplitVars

func SplitVars(s string) []string

func StrChannel

func StrChannel(key interface{}) chan string

func StrMapChannel

func StrMapChannel(key interface{}) chan map[string]string

func StrMatch

func StrMatch(c string, marks ...string) bool

func StrMatchEnd

func StrMatchEnd(c string, marks ...string) bool

func StrMatchStart

func StrMatchStart(c string, marks ...string) bool

func StrSearchStart

func StrSearchStart(c string, marks ...string) string

func TestingPath

func TestingPath(path string) string

func ToBytes

func ToBytes(v interface{}) []byte

func ToJSON

func ToJSON(buf []byte) interface{}

func ToJsonList

func ToJsonList(buf []byte) []interface{}

func ToJsonMap

func ToJsonMap(buf []byte) map[string]interface{}

func ToString

func ToString(v interface{}) string

func TrimDoubleQuotes

func TrimDoubleQuotes(s string) string

func TrimOp

func TrimOp(op *OpType)

func TrimSpaces

func TrimSpaces(c []byte) []byte

func TrimSpacesAroundColon

func TrimSpacesAroundColon(c []byte) []byte

func TrimSpacesAroundDot

func TrimSpacesAroundDot(c []byte) []byte

func TrimSpacesAroundDotDot

func TrimSpacesAroundDotDot(c []byte) []byte

func TrimSpacesAroundDotDotDot

func TrimSpacesAroundDotDotDot(c []byte) []byte

func TrimSpacesAroundEqual

func TrimSpacesAroundEqual(c []byte) []byte

func TrimSpacesAroundExtraOp

func TrimSpacesAroundExtraOp(c []byte, op string) []byte

func TrimSpacesAroundExtraPresent

func TrimSpacesAroundExtraPresent(c []byte) []byte

func TrimSpacesAroundLP

func TrimSpacesAroundLP(c []byte) []byte

func TrimSpacesAroundLS

func TrimSpacesAroundLS(c []byte) []byte

func TrimSpacesAroundLessThan

func TrimSpacesAroundLessThan(c []byte) []byte

func TrimSpacesAroundLogicAnd

func TrimSpacesAroundLogicAnd(c []byte) []byte

func TrimSpacesAroundLogicDiv

func TrimSpacesAroundLogicDiv(c []byte) []byte

func TrimSpacesAroundLogicEOR

func TrimSpacesAroundLogicEOR(c []byte) []byte

func TrimSpacesAroundLogicMulti

func TrimSpacesAroundLogicMulti(c []byte) []byte

func TrimSpacesAroundLogicNot

func TrimSpacesAroundLogicNot(c []byte) []byte

func TrimSpacesAroundLogicOr

func TrimSpacesAroundLogicOr(c []byte) []byte

func TrimSpacesAroundLogicPlus

func TrimSpacesAroundLogicPlus(c []byte) []byte

func TrimSpacesAroundLogicSub

func TrimSpacesAroundLogicSub(c []byte) []byte

func TrimSpacesAroundMod

func TrimSpacesAroundMod(c []byte) []byte

func TrimSpacesAroundMoreThan

func TrimSpacesAroundMoreThan(c []byte) []byte

func TrimSpacesAroundNotEqual

func TrimSpacesAroundNotEqual(c []byte) []byte

func TrimSpacesAroundNotPresent

func TrimSpacesAroundNotPresent(c []byte) []byte

func TrimSpacesAroundOn

func TrimSpacesAroundOn(c []byte) []byte

func TrimSpacesAroundOp

func TrimSpacesAroundOp(c []byte, opa, opb string) []byte

func TrimSpacesAroundOr

func TrimSpacesAroundOr(c []byte) []byte

func TrimSpacesAroundPower

func TrimSpacesAroundPower(c []byte) []byte

func TrimSpacesAroundRP

func TrimSpacesAroundRP(c []byte) []byte

func TrimSpacesAroundRS

func TrimSpacesAroundRS(c []byte) []byte

func TrimSpacesAroundSetVar

func TrimSpacesAroundSetVar(c []byte) []byte

func TrimSpacesAroundTextOp

func TrimSpacesAroundTextOp(c []byte, op string) []byte

func TrimSpacesAroundWith

func TrimSpacesAroundWith(c []byte) []byte

func TrimSpacesAroundWithout

func TrimSpacesAroundWithout(c []byte) []byte

func TrimSpacesWithRegexp

func TrimSpacesWithRegexp(c []byte, rs, opb string) []byte

func TypeOf

func TypeOf(v interface{}) reflect.Kind

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

func Unzip

func Unzip(dst, src string) (int, []string)

func UpdateFields

func UpdateFields(data interface{}, value interface{}) interface{}

func UpdateFieldsOnKeys

func UpdateFieldsOnKeys(data interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func UpdateJSON

func UpdateJSON(msg interface{}, value interface{}) interface{}

func UpdateJsonList

func UpdateJsonList(data []interface{}, value []interface{}) interface{}

func UpdateJsonListOnKeys

func UpdateJsonListOnKeys(data []interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func UpdateJsonMap

func UpdateJsonMap(data map[string]interface{}, value map[string]interface{}) interface{}

func UpdateJsonMapOnKeys

func UpdateJsonMapOnKeys(data map[string]interface{}, value []interface{}, keys []FormatType, top int) (int, interface{})

func UpdateJsonOnKeys

func UpdateJsonOnKeys(msg interface{}, value []interface{}, keys []FormatType) interface{}

func WaitForQuit

func WaitForQuit(sch, done, stop, quit chan int)

func WaitTimeout

func WaitTimeout(duration int, ch chan int, timeout chan bool)

func WalkFields

func WalkFields(data interface{}, key string, fields map[string][]FormatType, keys []FormatType)

func WalkJSON

func WalkJSON(buf []byte, key string) (interface{}, map[string][]FormatType)

func WalkListFields

func WalkListFields(data []interface{}, key string, fields map[string][]FormatType, keys []FormatType)

func WalkMapFields

func WalkMapFields(data map[string]interface{}, key string, fields map[string][]FormatType, keys []FormatType)

func Warning

func Warning(params ...interface{})

func ZipType

func ZipType(name string) string

Types

type CaseType

type CaseType struct {
	Line        int                 // 用例所在行号
	Timeout     int64               // 超时时间
	Rounds      int64               // 跑的轮次
	Concurrence int                 // 并发数
	Fill        int                 // 对应值 random:0/all:1, 默认random
	Random      int                 // 随机次数
	Local       int                 // 上下文的作用域,1:本地,0:全局,默认0
	TID         string              // 用例ID
	Title       string              // 用例标题
	Desc        string              // 用例描述
	Author      string              // 作者
	Maintainer  string              // 维护者
	Version     string              // 版本
	Level       string              // 等级 A/B/C/D/E 自定义
	Proto       string              // 协议 http/mqtt/ws/pb,默认 http
	Bugs        []string            // 问题列表
	Features    []string            // 需求列表
	Tags        []string            // 标签
	Extends     map[string][]string // 扩展属性列表
	Plugins     []string            // 插件列表
	FIDs        []string            // 流程列表
	Args        []OpType            // 参数值,一般是定义前置条件或后置条件的参数值
	Matches     []OpType            // 匹配条件,一般用于模拟服务匹配请求特征
	Vars        map[string]*VarType // 变量
	Steps       []StepType          // 用例步骤列表
}

type ConfigType

type ConfigType struct {
	Actions    map[string]string         // 动作
	Attributes map[string]string         // 属性
	Settings   map[string][]string       // 设置
	Meta       map[string]int            // 值
	Plugins    map[string]*PluginType    // 插件
	Messages   map[string]*ConstructType // 消息构造
	Data       map[string]*ConstructType // 数据构造
	Nodes      map[string]*NodeType      // 节点映射表,Key为节点ID
	Flows      map[string]*FlowType      // 流程映射表,Key为流程ID
}

type ConstructType

type ConstructType struct {
	IsInt    bool         // 值是否整型
	IsList   bool         // 是否列表
	ID       string       // 名称
	Op       string       // 构造操作符:->或者=
	Formats  []FormatType // 构造格式
	Keys     []FormatType // 字段路径、数据变量
	Settings []OpType     // 赋值动作
}

type ControlInfo

type ControlInfo struct {
	Port     int    // 端口
	Proto    string // 协议 tcp/http/websocket/mqtt etc.
	Service  string // 服务
	Status   string // 服务状态
	Scenario string // 场景: ok/tr/rr/pr/tw/rw/pw
}

type ControlType

type ControlType struct {
	CID     string              // 控制流ID
	Args    map[string]int      // 输入参数
	Title   string              // 标题
	Desc    string              // 描述
	Scope   string              // 范围,目前只针对前置条件和后置条件
	Plugins []string            // 插件列表
	Extends map[string][]string // 扩展属性列表
	Vars    map[string]*VarType // 变量
	Flows   []StepType          // 控制流列表
}

type DataInfo

type DataInfo struct {
	Key  string
	Data []byte
}

type DepType

type DepType struct {
	IsFuture bool         //是否未来赋值
	IsKey    bool         // 是否Key
	Var      string       // 对应变量
	Key      string       // 字段名
	Value    []FormatType // 数据
}

type FieldType

type FieldType struct {
	Key   string       // 字段名
	Value []FormatType // 值
}

type FileType

type FileType struct {
	IsVar   bool     // 是否变量
	IsFlow  bool     // 是否流程
	IsNode  bool     // 是否节点
	IsJSON  bool     // 是否JSON数据
	IsMap   bool     // JSON格式MAP结构
	IsList  bool     // JSON格式List结构
	IsBin   bool     // 是否二进制数据
	Top     string   // 顶级目录
	Name    string   // 文件名
	Path    string   // 路径
	Tags    []string // 动态标签列表
	Content []byte   // 内容
}

type FlowType

type FlowType struct {
	Line    int                 // 用例所在行号
	Random  int                 // 随机次数
	Local   int                 // 上下文的作用域,1:本地,0:全局,默认0
	FID     string              // 流程ID
	Title   string              // 用例标题
	Desc    string              // 用例描述
	Proto   string              // 协议 http/mqtt/ws/pb,默认 http
	Tags    []string            // 标签
	Extends map[string][]string // 扩展属性列表
	Plugins []string            // 插件列表
	FIDs    []string            // 流程列表
	Vars    map[string]*VarType // 变量
	Steps   []StepType          // 用例步骤列表
}

func GetFlow

func GetFlow(key string, c *ConfigType, st *TestSuite) *FlowType

type FormatType

type FormatType struct {
	IsInt      bool   // 能转成整型就设置为true,用""强制指定为字符串,值为false
	IsFloat    bool   // 能转成浮点数就设置为true,用""强制指定为字符串,值为false
	MustString bool   // 指定是字符串类型,用""强制指定为字符串,值为true,默认false,非指定
	Content    string // 内容
}

func BuildFormat

func BuildFormat(s string) FormatType

func BuildKeys

func BuildKeys(s string) []FormatType

type GlobalConfig

type GlobalConfig struct {
	Interval int
	Paths    sync.Map // 路径配置表
	IPs      sync.Map // IP列表
	Ports    sync.Map // Ports列表
	Calls    sync.Map // 调用映射
	Any      sync.Map // 任意数据
	Plugins  sync.Map // 插件
	Tasks    sync.Map
	Projects sync.Map
	Init     sync.Map
	Status   sync.Map
}

func GetGlobalConfig

func GetGlobalConfig() *GlobalConfig

type GroupData

type GroupData struct {
	Host  string                // ip:port
	SID   string                // 用例集ID
	GID   string                // 组ID
	Scope string                // 范围
	Cases map[string][]*VarData // 用例数据,Key为用例ID,多个并发多份数据
	CFs   map[string]*VarData   // 控制流数据,Key为控制流ID,用于前置条件/后置条件
	FDs   map[string]*VarData   // 流程数据,Key为流程ID
}

type GroupType

type GroupType struct {
	Line    int                  // 用例所在行号
	Timeout int64                // 超时时间
	GID     string               // 组ID
	Title   string               // 组标题
	Desc    string               // 描述
	Proto   string               // 协议 http/mqtt/ws/pb,默认 http
	CIDs    []string             // 控制流ID
	PreIDs  []string             // 前置条件ID
	PostIDs []string             // 后置条件ID
	Plugins []string             // 插件列表
	Extends map[string][]string  // 扩展属性列表
	Args    []OpType             // 参数值,一般是定义前置条件或后置条件的参数值
	Matches []OpType             // 匹配条件,一般用于模拟服务匹配请求特征
	Cases   map[string]*CaseType // 用例

}

type IPCType

type IPCType struct {
	// 协程间通信管道
	Any       sync.Map
	Int       sync.Map
	Byte      sync.Map
	String    sync.Map
	Bytes     sync.Map
	AnyMap    sync.Map
	IntMap    sync.Map
	StringMap sync.Map
	BytesMap  sync.Map
}

func GetIPCInstance

func GetIPCInstance() *IPCType

type LogConfig

type LogConfig struct {
	LogLevel   string         //日志级别
	LogALL     int            // 记录全部日志开关
	LogModules map[string]int // 打日志模块
}

func GetLogConfig

func GetLogConfig() *LogConfig

type NodeType

type NodeType struct {
	NID     string              // 服务标识
	Args    []string            // 输入参数
	Title   string              // 标题
	Desc    string              // 描述
	Hosts   []string            // 主机列表,元素值格式ip:port
	User    string              // 用户名
	Pass    string              // 密码
	Tunnel  string              // 通道,一般用于鉴权
	TunUser string              // 通道用户
	TunPass string              // 通道密码
	Path    string              // 路径,用于http协议
	Method  string              // 方法,用于http协议
	Proto   string              // 协议, i.e. http/mqtt/ws/pb
	Plugins []string            // 插件列表
	Extends map[string][]string // 扩展属性列表
	Steps   []StepType          // 控制流列表
}

type OpType

type OpType struct {
	CIDs     []int    // 并发请求ID列表
	Key      string   // 字段
	Op       string   // 操作码
	Value    []string // 值列表
	IsList   bool     // 变量是否列表类型
	IsMap    bool     // 变量是否字典类型
	IsStr    bool     // 值类型是字符串
	Continue bool     // 操作待续:true,有后续操作:false,无后续操作
}

func ParseOp

func ParseOp(c []byte) (int, string, []OpType)

func SplitColon

func SplitColon(c []byte, ot []OpType) []OpType

func SplitEqualOrNotEqual

func SplitEqualOrNotEqual(c []byte, ot []OpType) []OpType

func SplitExtraPresent

func SplitExtraPresent(c []byte, ot []OpType) []OpType

func SplitLessThan

func SplitLessThan(c []byte, ot []OpType) []OpType

func SplitMoreThan

func SplitMoreThan(c []byte, ot []OpType) []OpType

func SplitNotPresent

func SplitNotPresent(c []byte, ot []OpType) []OpType

func SplitOn

func SplitOn(c []byte, ot []OpType) []OpType

func SplitOp

func SplitOp(c []byte, opa string, ot []OpType) []OpType

func SplitOps

func SplitOps(c []byte, ot []OpType) []OpType

func SplitOr

func SplitOr(c []byte, ot []OpType) []OpType

func SplitSetVar

func SplitSetVar(c []byte, ot []OpType) []OpType

func SplitWith

func SplitWith(c []byte, ot []OpType) []OpType

func SplitWithout

func SplitWithout(c []byte, ot []OpType) []OpType

type PluginType

type PluginType struct {
	PID     string                 // 插件ID
	Title   string                 // 插件标题
	Desc    string                 // 插件描述
	Mode    string                 // 插件模式
	Name    string                 // 插件名称
	Build   string                 // 构建,一般用于定制构建
	Start   string                 // 启动,一般用于定制启动参数
	Path    string                 // 插件路径
	Proto   string                 // 协议
	Port    string                 // 端口
	Closed  int                    // 关闭
	IsSRC   bool                   // 是否源码
	IsRPC   bool                   // 是否RPC调用,用于非Go语言的源码插件
	Calls   []string               // 调用函数列表,作为过滤器,剔除掉不需要的函数,若为空,则不过滤,加载所有函数,bin模式不能为空,否则不能映射为可执行文件路径
	Mutes   []string               // 屏蔽函数列表,src模式的插件需要屏蔽的函数列表,bin模式不需要
	Extends map[string][]string    // 扩展属性列表
	Funcs   map[string]interface{} // 插件函数
	Bins    map[string]string      // 可执行文件调用函数映射表,Key为函数名,Value为可执行文件
	Cmd     *exec.Cmd              // 运行命令
}

type SettingType

type SettingType struct {
	IsList     bool     // 是否列表赋值,仅用于操作赋值
	Items      int      // 列表元素总数,仅用于操作赋值
	IsDep      bool     // 是否依赖
	IsTag      bool     // 是否标签,用于文本替换
	IsField    bool     // 是否字段,用于JSON替换
	IsInt      bool     // 能转成整型就设置为true,用""强制指定为字符串,值为false
	MustString bool     // 指定是字符串类型,用""强制指定为字符串,值为true,默认false,非指定
	Ops        []OpType // 操作赋值
}

func ParseSetting

func ParseSetting(c []byte) (int, string, SettingType)

type StepType

type StepType struct {
	Line     int         // 行号
	No       int         // 序号
	Rule     string      // 规则原文
	IsExpect bool        // 是否校验步骤
	Setting  SettingType // 赋值
	Expects  []OpType    // 期待行为
}

type StoreType

type StoreType struct {
	Service string // 服务名称
	Key     string // 缓存Key
	Data    []byte // 缓存数据
	Op      int    // 操作码,-1:删除服务数据,0:写数据,1:读数据
	BCh     chan []byte
	DCh     chan int
}

type TaskRequest

type TaskRequest struct {
	IsMocking    bool     // 是否模拟服务
	IsHijacking  bool     // 是否劫持服务
	IsExtraHosts bool     // 不覆盖已配置的HOSTS
	IsStateless  bool     // 是否无状态,用例可以随意分配
	IsSmoking    bool     // 是否冒烟测试,每个用例只测试一份数据
	IsRandom     bool     // 是否随机测试,每个用例只随机测试一份数据
	IsNoCheck    bool     // 是否不校验,一般用于A/B测试或稳定性测试
	Task         string   // 任务,唯一标识
	Project      string   // 项目名称
	Suite        []string // 测试用例集名称,一般为用例文件名称,去掉后缀名
	Group        []string // 测试用例组,一个用例集包含多个用例组,每个用例组包含多个用例
	Case         []string // 测试用例
	Concurrence  int      // 并发数
	Duration     int64    // 请求总时长
	Tags         []string // 标签列表
	Hosts        []string // 主机列表(IP:PORT)
	Quit         chan int // 结束管道
}

type TemplateType

type TemplateType struct {
	Type    int               // 模板类型, 0:消息模板(json格式), 1:二进制, 2:文本文件
	Keys    []string          // 标识符列表
	Actions []string          // 动作
	Name    string            // 名称
	Files   map[string]string // 模板列表,Key为顶级目录名称, Value为文件路径
}

type TemplateVarType

type TemplateVarType struct {
	ID      string // 标识
	Key     string // 值
	Node    string // 节点标识
	IsVar   bool   // 是否变量
	IsGroup bool   // 是否模板组
	IsFlow  bool   // 是否流程
	IsNode  bool   // 是否节点
	IsCtx   bool   // 是否上下文
	IsWait  bool   // 是否等待
	Count   int    // 倍数
	Targets []int  // 目标列表,用作消息模板的并发id列表
}

type TestReport

type TestReport struct {
	Stage   int      // 阶段, 0:解析规则配置阶段,1:执行用例阶段
	Code    int      // 状态码
	Line    int      // 用例所在行号
	Passed  int      // 是否通过,1:通过,0:不通过
	File    string   // 规则配置文件
	Title   string   // 用例标题
	Reason  string   // 用例失败原因
	Project string   // 项目名称
	Suite   string   // 用例集名称
	Group   string   // 用例组名称
	Tags    []string // 标签列表
}

type TestSuite

type TestSuite struct {
	SID         string                  // 用例集ID
	ControlFlow map[string]*ControlType // 控制流
	Setup       map[string]*ControlType // 前置条件
	Teardown    map[string]*ControlType // 后置条件
	Checks      map[string]*ControlType // 校验
	Flows       map[string]*FlowType    // 流程映射表,Key为流程ID
	Groups      map[string]*GroupType   // 用例组
}

type Testing

type Testing struct {
	Project     string                   // 项目名称
	IsMocking   bool                     // 是否模拟服务
	IsHijacking bool                     // 是否劫持服务
	Config      ConfigType               // 全局配置
	Templates   map[string]*TemplateType // 全局模板
	ControlFlow map[string]*ControlType  // 全局控制流
	Setup       map[string]*ControlType  // 全局前置条件
	Teardown    map[string]*ControlType  // 全局后置条件
	Checks      map[string]*ControlType  // 全局校验
	Suites      map[string]*TestSuite    // 所有用例集
	Funcs       map[string]*PluginType   // 插件函数
	Bins        map[string]string        //执行函数映射表,Key为函数名,Value为可执行文件路径
}

type VarData

type VarData struct {
	Total int                     // 运行时实例总数
	ID    string                  // ID
	Title string                  // 标题
	Host  string                  // ip:port
	Funcs map[string]*PluginType  // 插件函数映射,Key为插件函数名称
	Bins  map[string]string       // 可执行函数映射,Key为函数,值为可执行文件路径
	Data  map[string][]*FileType  // 数据集,Key为变量名
	Tags  map[string]*OpType      // 标签替换,Key为标签
	Vars  map[string]interface{}  // 变量映射,Key为变量
	Ctx   map[string]interface{}  // 上下文映射,Key为变量,用于流程
	Msgs  map[string]interface{}  // 消息映射,Key为消息变量
	VPos  map[string]int          // 变量值下标,用于变量遍历取值
	Keys  map[string][]FormatType // 字段映射,Key为变量
	Tops  map[string][]string     // 标记消息存在
}

VarData 运行时用例数据

type VarType

type VarType struct {
	Key        string            // 变量名
	Node       string            // 节点
	IsTop      bool              // 是否顶级变量
	IsTemplate bool              // 是否模板变量
	IsOpt      bool              // 是否操作变量
	IsGroup    bool              // 是否模板组变量
	IsFlow     bool              // 是否是流程变量
	IsNode     bool              // 是否是节点变量
	Op         string            // 操作符
	Templates  []TemplateVarType // 模板列表(包括规则、节点、上下文、消息)
	Value      []interface{}     // 变量值
}

Jump to

Keyboard shortcuts

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