integration

package
v0.0.0-...-51c1140 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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,
	}
)
View Source
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/.*`),
	}
)
View Source
var (
	WilcardLiteral = "??"
)

Functions

func IsFuzzyMatch

func IsFuzzyMatch(j1, j2 []byte) error

func IsFuzzyMatchString

func IsFuzzyMatchString(s1, s2 string) error

func LoadSupportedPackagesList

func LoadSupportedPackagesList(path, supportedListFile string) ([]string, error)

func ParsePackagesList

func ParsePackagesList(expectedPackages string) ([]string, error)

expect string containing comma separated list of package names returns an array of strings with all leading/trailing whitespace removed

func ScrubFilename

func ScrubFilename(in []byte, filename string) []byte

func ScrubHost

func ScrubHost(in []byte) []byte

func ScrubLineNumbers

func ScrubLineNumbers(in []byte) []byte

func StringSliceContains

func StringSliceContains(slice []string, text string) bool

check if string is contained in an array of strings for legacy Go as it would be preferable to use the slices

func SubEnvVars

func SubEnvVars(in []byte) []byte

Types

type CCLI

type CCLI struct {
	CLI
}

func (*CCLI) Execute

func (tx *CCLI) Execute() (http.Header, []byte, error)

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.

See: https://tools.ietf.org/html/rfc3875

func (*CGI) Execute

func (tx *CGI) Execute() (http.Header, []byte, error)

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.

func (*CLI) Execute

func (tx *CLI) Execute() (http.Header, []byte, error)

type ComparisonFailure

type ComparisonFailure struct {
	Name   string
	Expect string
	Actual string
}

func (ComparisonFailure) Error

func (c ComparisonFailure) Error() string

type ComposerJSON

type ComposerJSON struct {
	Installed []ComposerPackage
}

composer entire JSON

type ComposerPackage

type ComposerPackage struct {
	Name        string
	Version     string
	Description string
}

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

func NewContext(php, cgi string) *Context

type PhpPackage

type PhpPackage struct {
	Name    string
	Version string
}

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

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 Scrub

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

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 NewTest

func NewTest(name string) *Test

func ParseTestFile

func ParseTestFile(name string) *Test

func (*Test) AddNote

func (t *Test) AddNote(note string)

AddNote adds a note to the output for the final test status

func (*Test) Compare

func (t *Test) Compare(harvest *newrelic.Harvest)

func (*Test) Fail

func (t *Test) Fail(err error)

Fail records an unsatisified expectation for the test and marks the test as failed.

func (*Test) Fatal

func (t *Test) Fatal(err error)

Fatal records an error which prevented the test from being completed and marks the test as failed.

func (*Test) GetExpectHarvest

func (t *Test) GetExpectHarvest() bool

func (*Test) IsC

func (t *Test) IsC() bool

func (*Test) IsPHP

func (t *Test) IsPHP() bool

func (*Test) IsWeb

func (t *Test) IsWeb() bool

func (*Test) MakeRun

func (t *Test) MakeRun(ctx *Context) (Tx, error)

func (*Test) MakeSkipIf

func (t *Test) MakeSkipIf(ctx *Context) (Tx, error)

func (*Test) Reset

func (t *Test) Reset()

Reset discards the results of previous test executions.

func (*Test) SetExpectHarvest

func (t *Test) SetExpectHarvest(value bool)

func (*Test) ShouldCheckResponseHeaders

func (t *Test) ShouldCheckResponseHeaders() bool

func (*Test) Skip

func (t *Test) Skip(reason string)

Skip marks the test as skipped and records the given reason.

func (*Test) Skipf

func (t *Test) Skipf(format string, args ...interface{})

Skipf marks the test as skipped and formats its arguments according to the format, and records the text as the reason.

func (*Test) Warn

func (t *Test) Warn(reason string)

Warn marks the test as unable to be run and records the given reason.

func (*Test) Warnf

func (t *Test) Warnf(format string, args ...interface{})

Warnf marks the test as unable to be run and formats its arguments according to the format, and records the text as the reason.

func (*Test) XFail

func (t *Test) XFail(reason string)

XFail marks the test as expected to fail and records the given reason.

type Tx

type Tx interface {
	Execute() (headers http.Header, body []byte, err error)
}

A Tx represents a transaction.

func CTx

func CTx(src Script, env, settings map[string]string, headers http.Header, ctx *Context) (Tx, error)

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.

See: https://tools.ietf.org/html/rfc3875

func PhpTx

func PhpTx(src Script, env, settings map[string]string, ctx *Context) (Tx, error)

PhpTx constructs non-Web transactions to be executed by PHP.

type ValgrindCLI

type ValgrindCLI struct {
	CLI
	Valgrind string
	Timeout  time.Duration
}

func (*ValgrindCLI) Execute

func (tx *ValgrindCLI) Execute() (http.Header, []byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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