package proftest

import "cloud.google.com/go/profiler/proftest"

Index

Variables

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

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

Types

type 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.

type 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) PollForSerialOutput

func (tr *GCETestRunner) PollForSerialOutput(ctx context.Context, inst *InstanceConfig, finishString, errorString string) error

PollForSerialOutput polls serial port 2 of the GCE instance specified by inst and returns when the finishString appears in the serial output of the instance, or when the context times out.

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".

type 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.

type 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.

type 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.

type 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 specifed 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.

type 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.

Source Files

proftest.go

Version
v0.52.0
Published
Jan 22, 2020
Platform
js/wasm
Imports
16 packages
Last checked
25 minutes ago

Tools for package owners.