Documentation ¶
Index ¶
- Variables
- func IsFuzzyMatch(j1, j2 []byte) error
- func IsFuzzyMatchString(s1, s2 string) error
- func LoadSupportedPackagesList(path, supportedListFile string) ([]string, error)
- func ParseOverrideVersionsFile(path, overrideVersionFile string) (map[string]interface{}, error)
- func ParsePackagesList(expectedPackages string) ([]string, error)
- func ScrubFilename(in []byte, filename string) []byte
- func ScrubHost(in []byte) []byte
- func ScrubLineNumbers(in []byte) []byte
- func StringSliceContains(slice []string, text string) bool
- func SubEnvVars(in []byte) []byte
- type CCLI
- type CGI
- type CLI
- type ComparisonFailure
- type ComposerJSON
- type ComposerPackage
- type Context
- type PhpPackage
- type PhpPackagesCollection
- type PhpPackagesConfiguration
- type Script
- type ScriptFile
- type ScriptFragment
- type Scrub
- type Test
- func (t *Test) AddNote(note string)
- func (t *Test) Compare(harvest *newrelic.Harvest)
- func (t *Test) Fail(err error)
- func (t *Test) Fatal(err error)
- func (t *Test) GetExpectHarvest() bool
- func (t *Test) IsC() bool
- func (t *Test) IsPHP() bool
- func (t *Test) IsWeb() bool
- func (t *Test) MakeRun(ctx *Context) (Tx, error)
- func (t *Test) MakeSkipIf(ctx *Context) (Tx, error)
- func (t *Test) Reset()
- func (t *Test) SetExpectHarvest(value bool)
- func (t *Test) ShouldCheckResponseHeaders() bool
- func (t *Test) Skip(reason string)
- func (t *Test) Skipf(format string, args ...interface{})
- func (t *Test) Warn(reason string)
- func (t *Test) Warnf(format string, args ...interface{})
- func (t *Test) XFail(reason string)
- type Tx
- type ValgrindCLI
Constants ¶
This section is empty.
Variables ¶
var (
Directives = map[string]func(*Test, []byte) error{
"ENVIRONMENT": parseEnv,
"HEADERS": parseHeaders,
"SKIPIF": parseRawSkipIf,
"INI": parseSettings,
"PHPMODULES": parsePHPModules,
"CONFIG": parseConfig,
"DESCRIPTION": parseDescription,
"EXPECT_ANALYTICS_EVENTS": parseAnalyticEvents,
"EXPECT_CUSTOM_EVENTS": parseCustomEvents,
"EXPECT_ERROR_EVENTS": parseErrorEvents,
"EXPECT_SPAN_EVENTS": parseSpanEvents,
"EXPECT_SPAN_EVENTS_LIKE": parseSpanEventsLike,
"EXPECT_LOG_EVENTS": parseLogEvents,
"EXPECT_METRICS": parseMetrics,
"EXPECT_METRICS_EXIST": parseMetricsExist,
"EXPECT_METRICS_DONT_EXIST": parseMetricsDontExist,
"EXPECT": parseExpect,
"EXPECT_REGEX": parseExpectRegex,
"EXPECT_SCRUBBED": parseExpectScrubbed,
"EXPECT_HARVEST": parseExpectHarvest,
"EXPECT_SLOW_SQLS": parseSlowSQLs,
"EXPECT_TRACED_ERRORS": parseTracedErrors,
"EXPECT_TXN_TRACES": parseTxnTraces,
"EXPECT_RESPONSE_HEADERS": parseResponseHeaders,
"EXPECT_PHP_PACKAGES": parsePhpPackages,
"XFAIL": parseXFail,
}
)
var ( MetricScrubRegexps = []*regexp.Regexp{ regexp.MustCompile(`CPU/User Time`), regexp.MustCompile(`CPU/User/Utilization`), regexp.MustCompile(`Memory/Physical`), regexp.MustCompile(`Supportability/execute/user/call_count`), regexp.MustCompile(`Supportability/execute/allocated_segment_count`), regexp.MustCompile(`Memory/RSS`), regexp.MustCompile(`^Supportability\/Locale`), regexp.MustCompile(`^Supportability\/InstrumentedFunction`), regexp.MustCompile(`^Supportability\/TxnData\/.*`), regexp.MustCompile(`^Supportability/C/NewrelicVersion/.*`), } )
var (
WilcardLiteral = "??"
)
Functions ¶
func IsFuzzyMatch ¶
func IsFuzzyMatchString ¶
func ParsePackagesList ¶
expect string containing comma separated list of package names returns an array of strings with all leading/trailing whitespace removed
func ScrubFilename ¶
func ScrubLineNumbers ¶
func StringSliceContains ¶
check if string is contained in an array of strings for legacy Go as it would be preferable to use the slices
func SubEnvVars ¶
Types ¶
type CGI ¶
type CGI struct {
// contains filtered or unexported fields
}
CGI represents a Web transaction to be executed as an HTTP request using the CGI/1.1 protocol. Like CLI transactions, the lifetime of a CGI transaction is the same as the process that executes it.
type CLI ¶
type CLI struct { Path string // path to the executable Dir string // working directory for the process Env []string // specifies the environment of the process Args []string // arguments to pass to the process Stdin []byte // data to pass to the process via stdin }
CLI represents a transaction whose lifetime is the same as the process that executes it. For example, a PHP CLI invocation.
type ComparisonFailure ¶
func (ComparisonFailure) Error ¶
func (c ComparisonFailure) Error() string
type ComposerPackage ¶
composer package JSON
type Context ¶
type Context struct { PHP string // path to the PHP CLI executable CGI string // path to the PHP CGI executable Valgrind string // path to the Valgrind executable, or empty if disabled Env map[string]string // environment variables to pass to each test Settings map[string]string // settings to pass to each test Timeout time.Duration // maximum test duration }
func NewContext ¶
type PhpPackage ¶
PHP packages collection is a JSON string containing the detected PHP packages using a tool like composer
func GetPhpPackagesFromData ¶
func GetPhpPackagesFromData(data []byte) ([]PhpPackage, error)
Given a JSON harvest payload, extract the PHP packages
Params 1 : JSON byte string containing update_loaded_modules endpoint data
Returns : []PhpPackage with extracted package info, sorted by package name
nil upon error processing JSON
func (*PhpPackage) CollectorJSON ¶
func (pkg *PhpPackage) CollectorJSON() ([]byte, error)
convert PhpPackage to collector JSON representation
type PhpPackagesCollection ¶
type PhpPackagesCollection struct {
// contains filtered or unexported fields
}
func NewPhpPackagesCollection ¶
func NewPhpPackagesCollection(path string, config []byte) (*PhpPackagesCollection, error)
Create a package collection - requires config data from the EXPECT_PHP_PACKAGES stanza
func (*PhpPackagesCollection) CollectorJSON ¶
func (pkgs *PhpPackagesCollection) CollectorJSON() ([]byte, error)
convert PhpPackage to collector JSON representation
func (*PhpPackagesCollection) GatherInstalledPackages ¶
func (pkgs *PhpPackagesCollection) GatherInstalledPackages() ([]PhpPackage, error)
Detects installed PHP packages
Returns : []PhpPackage with extracted package info, sorted by package name
nil upon error processing JSON
Notes : Currently only supports an application created with composer
func (*PhpPackagesCollection) OverrideVersionsFile ¶
func (pkgs *PhpPackagesCollection) OverrideVersionsFile() string
Returns name of versions override file (if exists)
type PhpPackagesConfiguration ¶
type PhpPackagesConfiguration struct {
// contains filtered or unexported fields
}
PHP packages config describes how to collect the JSON for the packages installed for the current test case
type Script ¶
type Script interface { Dir() string // working directory Name() string // script file name Bytes() []byte // script content for code fragments IsFile() bool // true for real files }
A Script is a file or code fragment executed during a transaction.
type ScriptFile ¶
type ScriptFile string
A ScriptFile is the path to a file to be executed as a transaction. A typical use for a scriptFile is passing the path to a script to execute to the interpreter via command line argument.
func (ScriptFile) Bytes ¶
func (s ScriptFile) Bytes() []byte
func (ScriptFile) Dir ¶
func (s ScriptFile) Dir() string
func (ScriptFile) IsFile ¶
func (s ScriptFile) IsFile() bool
func (ScriptFile) Name ¶
func (s ScriptFile) Name() string
type ScriptFragment ¶
type ScriptFragment struct {
// contains filtered or unexported fields
}
A ScriptFragment is a script fragment to be executed as a transaction. A typical use for a scriptFragment is executing a SKIPIF directive by writing the fragment to a temporary file for execution by the interpreter.
func (*ScriptFragment) Bytes ¶
func (s *ScriptFragment) Bytes() []byte
func (*ScriptFragment) Dir ¶
func (s *ScriptFragment) Dir() string
func (*ScriptFragment) IsFile ¶
func (s *ScriptFragment) IsFile() bool
func (*ScriptFragment) Name ¶
func (s *ScriptFragment) Name() string
type Test ¶
type Test struct { Name string Path string Desc string Env map[string]string Settings map[string]string PhpModules map[string]string // When non-empty describes why failed should be true after the test // is run. This field may be set in the test definition to indicate // it should always fail, or it may be set at runtime if the first // line of the test's output starts with "xfail:". Xfail string // Remaining fields are populated after the test is run. Skipped bool Warned bool // If the test was skipped or the test could not be run due to an // error, describes the reason. Err error Output []byte // Response headers send through the integration runner HTTP endpoint // during the test run. ResponseHeaders http.Header // The timed duration of the test. If no timing was done, this is set // to 0. Duration time.Duration // Adaptions made to the configuration of C Agent tests. Config string // If the test ran to completion, contains one element for each // failed expectation. Failed bool Failures []error // Notes are comments generated by tests which are displayed in results Notes []string // contains filtered or unexported fields }
A Test captures the input, output and outcome of an integration test.
func ParseTestFile ¶
func (*Test) Fail ¶
Fail records an unsatisified expectation for the test and marks the test as failed.
func (*Test) Fatal ¶
Fatal records an error which prevented the test from being completed and marks the test as failed.
func (*Test) GetExpectHarvest ¶
func (*Test) SetExpectHarvest ¶
func (*Test) ShouldCheckResponseHeaders ¶
func (*Test) Skipf ¶
Skipf marks the test as skipped and formats its arguments according to the format, and records the text as the reason.
type Tx ¶
A Tx represents a transaction.
func CgiTx ¶
func CgiTx(src Script, env, settings map[string]string, headers http.Header, ctx *Context) (Tx, error)
CgiTx constructs Web transactions to be executed as an HTTP request using the CGI/1.1 protocol. Like CLI transactions, the lifetime of a CGI transaction is the same as the process that executes it.