Package cloud.google.com/go/profiler/proftest (v0.86.0)

Variables

BaseStartupTmpl

var BaseStartupTmpl = template.Must(template.New("startupScript").Parse("" /* 641 byte string literal not displayed */,
))

BaseStartupTmpl is the common part of the startup script that can be shared by multiple tests.

Functions

func CheckSerialOutputForBackoffs

func CheckSerialOutputForBackoffs(output string, numBenchmarks int, serverBackoffSubstring, createProfileSubstring, benchmarkNumPrefix string) error

CheckSerialOutputForBackoffs parses serial port output, and validates that server-specified backoffs were respected by the agent.

ClusterConfig

type ClusterConfig struct {
	ProjectID       string
	Zone            string
	ClusterName     string
	PodName         string
	ImageSourceName string
	ImageName       string
	Bucket          string
	Dockerfile      string
}

ClusterConfig is configuration for starting single GKE cluster for profiling agent test case.

GCETestRunner

type GCETestRunner struct {
	TestRunner
	ComputeService *compute.Service
}

GCETestRunner supports testing a profiling agent on GCE.

func (*GCETestRunner) DeleteInstance

func (tr *GCETestRunner) DeleteInstance(ctx context.Context, inst *InstanceConfig) error

DeleteInstance deletes an instance with project id, name, and zone matched by inst.

func (*GCETestRunner) PollAndLogSerialPort

func (tr *GCETestRunner) PollAndLogSerialPort(ctx context.Context, inst *InstanceConfig, finishString, errorString string, logf func(string, ...interface{})) (string, error)

PollAndLogSerialPort polls serial port 2 of the given GCE instance and returns when the finishString appears in the serial output of the instance, or when the context times out. It logs the serial output of the instance using the specified log function and returns the serial output in the first return value.

func (*GCETestRunner) StartInstance

func (tr *GCETestRunner) StartInstance(ctx context.Context, inst *InstanceConfig) error

StartInstance starts a GCE Instance with configs specified by inst, and which runs the startup script specified in inst. If image project is not specified, it defaults to "debian-cloud". If image family is not specified, it defaults to "debian-9".

GKETestRunner

type GKETestRunner struct {
	TestRunner
	ContainerService *container.Service
	StorageClient    *storage.Client
	Dockerfile       string
}

GKETestRunner supports testing a profiling agent on GKE.

func (*GKETestRunner) DeleteClusterAndImage

func (tr *GKETestRunner) DeleteClusterAndImage(ctx context.Context, cfg *ClusterConfig) []error

DeleteClusterAndImage deletes cluster and images used to create cluster.

InstanceConfig

type InstanceConfig struct {
	ProjectID     string
	Zone          string
	Name          string
	StartupScript string
	MachineType   string
	ImageProject  string
	ImageFamily   string
	Scopes        []string
}

InstanceConfig is configuration for starting single GCE instance for profiling agent test case.

ProfileData

type ProfileData struct {
	Samples           []int32         `json:"samples"`
	SampleMetrics     interface{}     `json:"sampleMetrics"`
	DefaultMetricType string          `json:"defaultMetricType"`
	TreeNodes         interface{}     `json:"treeNodes"`
	Functions         functionArray   `json:"functions"`
	SourceFiles       sourceFileArray `json:"sourceFiles"`
}

ProfileData has data of a single profile.

ProfileResponse

type ProfileResponse struct {
	Profile     ProfileData   `json:"profile"`
	NumProfiles int32         `json:"numProfiles"`
	Deployments []interface{} `json:"deployments"`
}

ProfileResponse contains the response produced when querying profile server.

func (*ProfileResponse) CheckNonEmpty

func (pr *ProfileResponse) CheckNonEmpty() error

CheckNonEmpty returns nil if the profile has a profiles and deployments associated. Otherwise, returns a desciptive error.

func (*ProfileResponse) HasFunction

func (pr *ProfileResponse) HasFunction(functionName string) error

HasFunction returns nil if the function is present, or, if the function is not present, and error providing more details why the function is not present.

func (*ProfileResponse) HasFunctionInFile

func (pr *ProfileResponse) HasFunctionInFile(functionName string, filename string) error

HasFunctionInFile returns nil if function is present in the specified file, and an error if the function/file combination is not present in the profile.

func (*ProfileResponse) HasSourceFile

func (pr *ProfileResponse) HasSourceFile(filename string) error

HasSourceFile returns nil if the file (or file where the end of the file path matches the filename) is present in the profile. Or, if the filename is not present, an error is returned.

TestRunner

type TestRunner struct {
	Client *http.Client
}

TestRunner has common elements used for testing profiling agents on a range of environments.

func (*TestRunner) QueryProfiles

func (tr *TestRunner) QueryProfiles(projectID, service, startTime, endTime, profileType string) (ProfileResponse, error)

QueryProfiles retrieves profiles of a specific type, from a specific time range, associated with a particular service and project.

func (*TestRunner) QueryProfilesWithZone

func (tr *TestRunner) QueryProfilesWithZone(projectID, service, startTime, endTime, profileType, zone string) (ProfileResponse, error)

QueryProfilesWithZone retrieves profiles of a specific type, from a specific time range, in a specified zone, associated with a particular service and project.