commConsts

package
v0.0.0-...-a97389e Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	App        = "ztf"
	AppServer  = "server"
	AppAgent   = "agent"
	AppCommand = "cmd"

	Ip   = "127.0.0.1"
	Port = 8085

	JobTimeoutTime = 60 * 30
	JobRetryTime   = 3

	ConfigVersion      = "3.0"
	ConfigDir          = "conf"
	ConfigFile         = "ztf.conf"
	LogDirName         = "log"
	ExtNameSuite       = "cs"
	LogText            = "log.txt"
	ResultText         = "result.txt"
	ResultJson         = "result.json"
	ResultZip          = "result.zip"
	ExecZip            = "exec.zip"
	ExecZipPath        = "uploadTmp"
	DownloadServerPath = "serverTmp"
	DownloadPath       = "downloadTmp"
	ExecProxyPath      = "proxyExecDir"

	ExpectResultPass = "pass"

	LevelToScanScriptFile = 8

	PathInfo = "PATH_INFO"
	Get      = "GET"
	PthSep   = string(os.PathSeparator)

	PluginDir      = "plugin"
	DownloadDir    = "download"
	BinDir         = "bin"
	ZapDownloadUrl = "https://dl.cnezsoft.com/ztf/plugin/zap/zap-%s.zip"
)

Variables

View Source
var (
	UnitBuildToolMap = map[string]BuildTool{
		"mvn": Maven,
	}

	SpaceQuote = " "

	AutoTestTypes = []string{Selenium.String(), Appium.String(), AutoIt.String()}
	UnitTestTypes = []string{
		Allure.String(),
		JUnit.String(), TestNG.String(), PHPUnit.String(), PyTest.String(), Jest.String(), CppUnit.String(), GTest.String(), QTest.String(),
		RobotFramework.String(), Cypress.String(), Playwright.String(), Puppeteer.String(), K6.String(), Zap.String(),
	}

	DirToIgnore = []string{"node_modules", ".webpack",
		"bin", "logs", "xdoc", "log", "log-bak", "conf"}
)
View Source
var (
	Success         = ResponseCode{0, "Request Successfully"}
	CommErr         = ResponseCode{100, "Common Error"}
	ParamErr        = ResponseCode{200, "Parameter Error"}
	UnAuthorizedErr = ResponseCode{401, "UnAuthorized"}

	ResponseParseErr = ResponseCode{6000, "Json Parse Error"}
	NeedInitErr      = ResponseCode{1000, "Data Not Init"}

	ErrCommon                         = ResponseCode{2000, "Common Error"}
	ErrDirNotEmpty                    = ResponseCode{1100, "Dir Not Empty Error"}
	ErrZentaoConfig                   = ResponseCode{2000, "Zentao Config Error"}
	ErrZentaoRequest                  = ResponseCode{3000, "zentao request Error"}
	ErrRecordWithSameNameExist        = ResponseCode{3010, "Record With Same Name Exist"}
	ErrRecordWithSamePathExist        = ResponseCode{3011, "Record With Same Path Exist"}
	ErrRecordWithSameInterpreterExist = ResponseCode{2000, "Record With Same Interpreter Exist"}
	ErrRecordNotExist                 = ResponseCode{4000, "Record Not Found"}
	ErrRecordNotAllowDelete           = ResponseCode{2000, "Record Can Not Delete"}
	ErrPostParam                      = ResponseCode{2000, "Parameter Error"}
	NotAvailable                      = ResponseCode{5000, "Not Available"}
	ServerNotAvailable                = ResponseCode{5001, "Server Not Available"}
	ProxyNotAvailable                 = ResponseCode{5002, "Proxy Not Available"}

	ErrFileOrDirExist = ResponseCode{6000, "File or Dir Exist"}
)
View Source
var (
	ScriptExtToNameMap map[string]string

	EditorExtToLangMap map[string]string
)
View Source
var (
	LangMap = map[string]map[string]string{
		"shell": {
			"name":         "Shell",
			"extName":      "sh",
			"commentsTag":  "#",
			"printGrammar": "echo \"#\"",
		},
		"bat": {
			"name":         "BAT",
			"extName":      "bat",
			"commentsTag":  "::",
			"printGrammar": "echo #",
		},
		"autoit": {
			"name":         "AutoIT",
			"extName":      "au3",
			"commentsTag":  "#",
			"printGrammar": "ConsoleWrite(text & @CRLF)",
			"interpreter":  "c:\\Program Files (x86)\\AutoIt3\\AutoIt3_x64.exe",
		},

		"javascript": {
			"name":          "JavaScript",
			"extName":       "js",
			"commentsTag":   "//",
			"printGrammar":  "console.log(\"#\")",
			"interpreter":   "C:\\Program Files\\nodejs\\node.exe",
			"whereCmd":      "where node",
			"linuxWhereCmd": "which -a node",
			"versionCmd":    "-v",
		},
		"lua": {
			"name":          "Lua",
			"extName":       "lua",
			"commentsTag":   "--",
			"printGrammar":  "print('#')",
			"interpreter":   "C:\\lua-5.3.6_Win32_bin\\lua53.exe",
			"whereCmd":      "where lua*.exe",
			"linuxWhereCmd": "which -a lua",
			"versionCmd":    "-v",
		},
		"perl": {
			"name":          "Perl",
			"extName":       "pl",
			"commentsTag":   "#",
			"printGrammar":  "print \"#\\n\";",
			"interpreter":   "C:\\Perl64\\bin\\perl.exe",
			"whereCmd":      "where perl",
			"linuxWhereCmd": "which -a perl",
			"versionCmd":    "-v",
		},
		"php": {
			"name":          "PHP",
			"extName":       "php",
			"commentsTag":   "//",
			"printGrammar":  "echo \"#\\n\";",
			"interpreter":   "C:\\php-7.3.9-Win32-VC15-x64\\php.exe",
			"whereCmd":      "where php",
			"linuxWhereCmd": "which -a php",
			"versionCmd":    "-v",
		},
		"python": {
			"name":          "Python",
			"extName":       "py",
			"commentsTag":   "#",
			"printGrammar":  "print(\"#\")",
			"interpreter":   "C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe",
			"whereCmd":      "where python",
			"linuxWhereCmd": "which -a python python2 python3",
			"versionCmd":    "--version",
		},
		"ruby": {
			"name":          "Ruby",
			"extName":       "rb",
			"commentsTag":   "#",
			"printGrammar":  "print(\"#\\n\")",
			"interpreter":   "C:\\Ruby26-x64\\bin\\ruby.exe",
			"whereCmd":      "where ruby",
			"linuxWhereCmd": "which -a ruby",
			"versionCmd":    "-v",
		},
		"tcl": {
			"name":          "TCL",
			"extName":       "tl",
			"commentsTag":   "#",
			"printGrammar":  "set hello \"#\"; \n puts [set hello];",
			"interpreter":   "C:\\ActiveTcl\\bin\\tclsh.exe",
			"whereCmd":      "where tclsh",
			"linuxWhereCmd": "which -a tclsh",
			"versionCmd":    "echo 'puts $tcl_version;exit 0'",
		},
		"go": {
			"name":            "Go",
			"extName":         "go",
			"commentsTag":     "//",
			"printGrammar":    "print(\"#\")",
			"interpreter":     "C:\\Program Files\\go\\bin\\go.exe",
			"whereCmd":        "where go",
			"linuxWhereCmd":   "which -a go",
			"versionCmd":      "version",
			"CompiledCommand": "run",
		},
	}

	LangCommentsTagMap = map[string][]string{
		"bat":        {`goto start`, `:start`},
		"javascript": {`/*`, `*/`},
		"lua":        {`--[[`, `]]`},
		"perl":       {`=pod`, `=cut`},
		"php":        {`/**`, `*/`},
		"python":     {"'''", "'''"},
		"ruby":       {`=begin`, `=end`},
		"shell":      {`:<<!`, `!`},
		"tcl":        {`set case {`, `}`},
		"go":         {`/**`, `*/`},
	}

	LangCommentsRegxMap = map[string][]string{
		"bat":        {"^\\s*goto start\\s*$", "^\\s*:start\\s*$"},
		"javascript": {"^\\s*/\\*{1,}\\s*$", "^\\s*\\*{1,}/\\s*$"},
		"lua":        {"^\\s*--\\[\\[\\s*$", "^\\s*\\]\\]\\s*$"},
		"perl":       {"^\\s*=pod\\s*$", "^\\s*=cut\\s*$"},
		"php":        {"^\\s*/\\*{1,}\\s*$", "^\\s*\\*{1,}/\\s*$"},
		"python":     {"^\\s*'''\\s*$", "^\\s*'''\\s*$"},
		"ruby":       {"^\\s*=begin\\s*$", "^\\s*=end\\s*$"},
		"shell":      {"^\\s*:<<!\\s*$", "^\\s*!\\s*$"},
		"tcl":        {"^\\s*set case {", "^\\s*}"},
		"go":         {"^\\s*/\\*{1,}\\s*$", "^\\s*\\*{1,}/\\s*$"},
	}

	EditorLangMap = map[string]map[string]string{
		"markdown": {
			"name":    "readme",
			"extName": "md,markdown",
		},
		"dockerfile": {
			"name":    "dockerfile",
			"extName": "",
		},

		"shell": {
			"name":    "",
			"extName": "sh",
		},
		"bat": {
			"name":    "",
			"extName": "bat",
		},

		"javascript": {
			"name":    "",
			"extName": "js",
		},
		"lua": {
			"name":    "",
			"extName": "lua",
		},
		"perl": {
			"name":    "",
			"extName": "pl",
		},
		"php": {
			"name":    "",
			"extName": "php",
		},
		"python": {
			"name":    "",
			"extName": "py",
		},
		"ruby": {
			"name":    "",
			"extName": "rb",
		},
		"tcl": {
			"name":    "",
			"extName": "tl",
		},

		"typescript": {
			"name":    "",
			"extName": "ts,tsx",
		},
		"coffeescript": {
			"name":    "",
			"extName": "coffee",
		},
		"sql": {
			"name":    "",
			"extName": "sql",
		},
		"html": {
			"name":    "",
			"extName": "html",
		},
		"css": {
			"name":    "",
			"extName": "css",
		},
		"less": {
			"name":    "",
			"extName": "less",
		},
		"scss": {
			"name":    "",
			"extName": "scss,sass",
		},
		"xml": {
			"name":    "",
			"extName": "xml",
		},
		"yaml": {
			"name":    "",
			"extName": "yaml,yml",
		},
		"json": {
			"name":    "",
			"extName": "json",
		},
		"ini": {
			"name":    "",
			"extName": "ini",
		},
		"plaintext": {
			"name":    "",
			"extName": "txt",
		},

		"c": {
			"name":    "",
			"extName": "c,h",
		},
		"csharp": {
			"name":    "",
			"extName": "cs",
		},
		"cpp": {
			"name":    "",
			"extName": "cpp,cc",
		},
		"dart": {
			"name":    "",
			"extName": "dart",
		},
		"go": {
			"name":    "",
			"extName": "go",
		},
		"java": {
			"name":    "",
			"extName": "java",
		},
		"julia": {
			"name":    "",
			"extName": "jl",
		},
		"kotlin": {
			"name":    "",
			"extName": "kt",
		},
		"objective-c": {
			"name":    "",
			"extName": "m,mm",
		},
		"pascal": {
			"name":    "",
			"extName": "pas",
		},
		"powershell": {
			"name":    "",
			"extName": "ps",
		},
		"rust": {
			"name":    "",
			"extName": "rs",
		},
		"scala": {
			"name":    "",
			"extName": "scala",
		},
		"swift": {
			"name":    "",
			"extName": "swift",
		},
		"vb": {
			"name":    "",
			"extName": "vb,vbs",
		},
	}
)
View Source
var (
	LanguageZh = "zh"
	LanguageEn = "en"
	Language   = LanguageZh

	AutoCommitResult bool
	AutoCommitBug    bool
	AutoExtract      bool
	BatchCount       = 1
	Verbose          = false
	IsRelease        bool
	ZtfDir           string
	WorkDir          string
	ExecLogDir       string
	LogDir           string
	WithCache        bool

	RequestType string
	ExecFrom    ExecFromDef
)
View Source
var (
	ConfigPath         string
	ServerWorkDir      string
	ServerWorkspaceDir string

	CommandArgs []string

	UnitTestType    string
	UnitBuildTool   BuildTool
	UnitTestTool    TestTool
	AllureReportDir string
	JacocoReport    string
	Options         string
	ProductId       string

	ZenTaoVersion string
	Token         = "Token"
	SessionVar    = "zentaosid"
	SessionId     string
	RequestFix    string

	CurrScriptFile string // scripts/tc-001.py
	CurrResultDate string // 2019-08-15T173802
	CurrCaseId     int    // 2019-08-15T173802

	ScreenWidth    int
	ScreenHeight   int
	CurrBugStepIds string
	Interpreter    string

	// server
	RunMode     string
	IP          string
	MAC         string
	AgentLogDir string
)

Functions

This section is empty.

Types

type BuildTool

type BuildTool string
const (
	Maven      BuildTool = "maven"
	MavenShort BuildTool = "mvn"
	Mocha      BuildTool = "mocha"
)

func (BuildTool) Get

func (BuildTool) Get(str string) BuildTool

func (BuildTool) String

func (e BuildTool) String() string

type CaseStepType

type CaseStepType string
const (
	Group CaseStepType = "group"
	Item  CaseStepType = "item"
)

type DropPos

type DropPos int
const (
	Before DropPos = -1
	Inner  DropPos = 0
	After  DropPos = 1
)

func (DropPos) Int

func (e DropPos) Int() int

type ExecBy

type ExecBy string
const (
	Case   ExecBy = "case"
	Module ExecBy = "module"
	Suite  ExecBy = "suite"
	Task   ExecBy = "task"
)

func (ExecBy) Get

func (ExecBy) Get(str string) ExecBy

func (ExecBy) String

func (e ExecBy) String() string

type ExecCmd

type ExecCmd string
const (
	ExecInit ExecCmd = "init"
	ExecStop ExecCmd = "execStop"

	ExecCase   ExecCmd = "execCase"
	ExecModule ExecCmd = "execModule"
	ExecSuite  ExecCmd = "execSuite"
	ExecTask   ExecCmd = "execTask"

	ExecUnit    ExecCmd = "execUnit"
	ExecZapScan ExecCmd = "zapScan"

	Watch ExecCmd = "watch"
)

func (ExecCmd) String

func (e ExecCmd) String() string

type ExecFromDef

type ExecFromDef string
const (
	FromZentao ExecFromDef = "zentao"
	FromCmd    ExecFromDef = "cmd"
	FromClient ExecFromDef = "client"
)

func (ExecFromDef) String

func (e ExecFromDef) String() string

type JobStatus

type JobStatus string
const (
	JobCreated    JobStatus = "created"
	JobInprogress JobStatus = "inprogress"

	// temp status
	JobTimeout JobStatus = "timeout"
	JobError   JobStatus = "error"

	// final status
	JobCanceled  JobStatus = "canceled"
	JobCompleted JobStatus = "completed"
	JobFailed    JobStatus = "failed"
)

func (JobStatus) ToString

func (e JobStatus) ToString() string

type K6ResultType

type K6ResultType string
const (
	Metric K6ResultType = "Metric"
	Point  K6ResultType = "Point"
)

func (K6ResultType) ToString

func (e K6ResultType) ToString() string

type NodeCreateMode

type NodeCreateMode string
const (
	Brother NodeCreateMode = "brother"
	Child   NodeCreateMode = "child"
)

func (NodeCreateMode) String

func (e NodeCreateMode) String() string

type NodeCreateType

type NodeCreateType string
const (
	CreateDir  NodeCreateType = "dir"
	CreateNode NodeCreateType = "node"
)

func (NodeCreateType) String

func (e NodeCreateType) String() string

type OsType

type OsType string
const (
	OsWindows OsType = "windows"
	OsLinux   OsType = "linux"
	OsMac     OsType = "mac"
)

func (OsType) Get

func (OsType) Get(osName string) OsType

func (OsType) String

func (e OsType) String() string

type PlatformType

type PlatformType string
const (
	Android PlatformType = "android"
	Ios     PlatformType = "ios"
	Host    PlatformType = "host"
	Vm      PlatformType = "vm"
)

type ResponseCode

type ResponseCode struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

type ResultStatus

type ResultStatus string
const (
	PASS    ResultStatus = "pass"
	FAIL    ResultStatus = "fail"
	SKIP    ResultStatus = "skip"
	BLOCKED ResultStatus = "blocked"
	UNKNOWN ResultStatus = "unknown"
)

func (ResultStatus) String

func (e ResultStatus) String() string

type ScriptFilterType

type ScriptFilterType string
const (
	FilterWorkspace ScriptFilterType = "workspace"
	FilterModule    ScriptFilterType = "module"
	FilterSuite     ScriptFilterType = "suite"
	FilterTask      ScriptFilterType = "task"
)

type TestTool

type TestTool string
const (
	ZTF     TestTool = "ztf"
	Allure  TestTool = "allure"
	JUnit   TestTool = "junit"
	TestNG  TestTool = "testng"
	PHPUnit TestTool = "phpunit"
	PyTest  TestTool = "pytest"
	Jest    TestTool = "jest"
	CppUnit TestTool = "cppunit"
	GTest   TestTool = "gtest"
	QTest   TestTool = "qtest"
	GoTest  TestTool = "gotest"

	AutoIt         TestTool = "autoit"
	Selenium       TestTool = "selenium"
	Appium         TestTool = "appium"
	RobotFramework TestTool = "robot"
	Cypress        TestTool = "cypress"
	Playwright     TestTool = "playwright"
	Puppeteer      TestTool = "puppeteer"
	K6             TestTool = "k6"
	Zap            TestTool = "zap"
)

func (TestTool) Get

func (TestTool) Get(str string) TestTool

func (TestTool) String

func (e TestTool) String() string

type TestType

type TestType string
const (
	TestFunc TestType = "func"
	TestUnit TestType = "unit"
	TestZap  TestType = "zap"
)

func (TestType) Get

func (TestType) Get(str string) TestType

func (TestType) String

func (e TestType) String() string

type TreeNodeType

type TreeNodeType string
const (
	Root      TreeNodeType = "root"
	Workspace TreeNodeType = "workspace"
	Dir       TreeNodeType = "dir"
	File      TreeNodeType = "file"

	ZentaoModule TreeNodeType = "module"
)

type WsMsgCategory

type WsMsgCategory string
const (
	Output WsMsgCategory = "output"

	Run    WsMsgCategory = "run"
	Result WsMsgCategory = "result"
	Error  WsMsgCategory = "error"

	Communication WsMsgCategory = "communication"
	Unknown       WsMsgCategory = ""
)

func (WsMsgCategory) String

func (e WsMsgCategory) String() string

Jump to

Keyboard shortcuts

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