testhelpers

package
v0.0.0-...-b44688a Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SwanPath = path.Join(os.Getenv("GOPATH"), "src", "github.com/intelsdi-x/swan")

SwanPath is an absolute path of project.

Functions

func AssertFileExists

func AssertFileExists(executable string) string

AssertFileExists makes sure that executable is available in $PATH or panics returning location of executable.

func IsPodRunning

func IsPodRunning(podName string, numberOfAttempts int, sleepBetweenAttempts time.Duration) bool

IsPodRunning checks if pod is in Running state.

func PreparePublisher

func PreparePublisher(loader *snap.PluginLoader) (cleanup func(), publisher *wmap.PublishWorkflowMapNode, publisherMetricsFile string)

PreparePublisher creates session publisher and publisher output file, returns cleanup function, publisher and file name where publisher data will be stored

func ReadAndTestPublisherData

func ReadAndTestPublisherData(dataFilePath string, expectedMetrics map[string]string) (validData bool)

ReadAndTestPublisherData reads publisher output, when data are read, function checks if we have all data, if we have all columns, if yes, then we compare read data against expectedMetrics. Function returns bool, which if true means that all data are valid, if false - data have not been read properly. If data do not match expected data, convey.So is "thrown"

func RunAndTestSnaptel

func RunAndTestSnaptel() (cleanup func(), loader *snap.PluginLoader, snaptelURL string)

RunAndTestSnaptel checks snapteld on returning cleanup function, plugin loader and string with snapteld address Note: It is facade function that assumes snapteld is running all the time. But can be easily replaced with self-provided snapteld.

func WipeTestClusterFromSurfaceOfTheEarth

func WipeTestClusterFromSurfaceOfTheEarth(handle executor.TaskHandle)

WipeTestClusterFromSurfaceOfTheEarth does a lot to make sure that Kubernetes cluster is stopped and there are not artifacts in etcd or /var/lib/kubelet.

Types

type FilePublisherMetric

type FilePublisherMetric struct {
	// Namespace contains snap metric namespace.
	Namespace string `json:"namespace"`
	// Data contains snap metric value.
	Data interface{} `json:"data"`
	// Tags contains map of tags from metric.
	Tags map[string]string `json:"tags"`
}

FilePublisherMetric is used for decoding content of file publisher.

func GetMetric

func GetMetric(namespace string, metrics []FilePublisherMetric) (*FilePublisherMetric, error)

GetMetric returns FilePublisherMetric structure with requested metric's namespace.

func GetOneMeasurementFromFile

func GetOneMeasurementFromFile(fileLocation string) ([]FilePublisherMetric, error)

GetOneMeasurementFromFile gets one random measurement from file.

type KubeClient

type KubeClient struct {
	Clientset *kubernetes.Clientset
	// contains filtered or unexported fields
}

KubeClient is a helper struct to communicate with K8s API. It stores Kubernetes client and extends it to additional functionality needed by integration tests.

func NewKubeClient

func NewKubeClient(kubernetesConfig executor.KubernetesConfig) (*KubeClient, error)

NewKubeClient creates KubeClient object based on given KubernetesConfig structure. It returns error if given configuration is invalid.

func (*KubeClient) DeletePod

func (k *KubeClient) DeletePod(podName string) error

DeletePod with given podName.

func (*KubeClient) GetPods

func (k *KubeClient) GetPods() ([]*v1.Pod, []*v1.Pod, error)

GetPods gathers running and not running pods from K8s cluster.

func (*KubeClient) TaintNode

func (k *KubeClient) TaintNode()

TaintNode with NoSchedule taint (can panic).

func (*KubeClient) UntaintNode

func (k *KubeClient) UntaintNode()

UntaintNode removes all tains for given node (can panic on failure).

type Snapteld

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

Snapteld represents Snap daemon used in tests.

func NewSnapteld

func NewSnapteld() *Snapteld

NewSnapteld constructs Snapteld on random high ports.

func NewSnapteldOnDefaultPorts

func NewSnapteldOnDefaultPorts() *Snapteld

NewSnapteldOnDefaultPorts constructs Snapteld on chosen ports.

func NewSnapteldOnPort

func NewSnapteldOnPort(apiPort, rpcPort int) *Snapteld

NewSnapteldOnPort constructs Snapteld on chosen ports.

func (*Snapteld) CleanAndEraseOutput

func (s *Snapteld) CleanAndEraseOutput() error

CleanAndEraseOutput cleans and removes Output.

func (*Snapteld) Connected

func (s *Snapteld) Connected() bool

Connected checks if we can connect to Snap daemon.

func (*Snapteld) Port

func (s *Snapteld) Port() int

Port returns port Snapteld is listening.

func (*Snapteld) Start

func (s *Snapteld) Start() error

Start starts Snap daemon and wait until it is responsive.

func (*Snapteld) Stop

func (s *Snapteld) Stop() error

Stop stops Snap daemon.

Jump to

Keyboard shortcuts

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