executor

package
v0.0.0-...-5212089 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoOutput = ""
)
View Source
const (
	TESTS_NAMESPACE = "collector-tests"
)

Variables

This section is empty.

Functions

func Retry

func Retry(f retryable) (output string, err error)

Simple retry in loop for commands produce only one string output and error

func RetryWithErrorCheck

func RetryWithErrorCheck(ec errorchecker, f retryable) (output string, err error)

Simple retry with error checker

func RetryWithTimeout

func RetryWithTimeout(f retryable, timeoutMsg error) (
	output string, err error)

Retry based on a ticker with timeout.

Note that the caller is responsible for reporting outstanding errors in ticker function

Types

type CommandBuilder

type CommandBuilder interface {
	ExecCommand(args ...string) *exec.Cmd
}

type ContainerFilter

type ContainerFilter struct {
	Name      string
	Namespace string
}

type ContainerLogs

type ContainerLogs struct {
	Stdout string
	Stderr string
}

func (*ContainerLogs) Empty

func (c *ContainerLogs) Empty() bool

func (*ContainerLogs) GetSingleLog

func (l *ContainerLogs) GetSingleLog() string

Will return Stderr if it is not empty, otherwise it returns Stdout. Useful for accessing the logs for collector and container-stats that use a single stream.

type ContainerStat

type ContainerStat struct {
	Timestamp time.Time
	Id        string
	Name      string
	Mem       uint64
	Cpu       uint64
}

type ExecOptions

type ExecOptions struct {
	ContainerName string
	Command       []string
	Detach        bool
}

type Executor

type Executor interface {
	PullImage(image string) error
	IsContainerRunning(container string) (bool, error)
	ContainerExists(filter ContainerFilter) (bool, error)
	ExitCode(filter ContainerFilter) (int, error)
	ExecContainer(opts *ExecOptions) (string, error)
	KillContainer(name string) (string, error)
	RemoveContainer(filter ContainerFilter) (string, error)
	StopContainer(name string) (string, error)
	StartContainer(config config.ContainerStartConfig) (string, error)
	GetContainerHealthCheck(containerID string) (string, error)
	GetContainerStats(ctx context.Context, containerID string) (*ContainerStat, error)
	GetContainerIP(containerID string) (string, error)
	GetContainerLogs(containerID string) (ContainerLogs, error)
	CaptureLogs(testName, containerName string) (string, error)
	GetContainerPorts(containerID string) ([]string, error)
	IsContainerFoundFiltered(containerID, filter string) (bool, error)
}

func New

func New() (Executor, error)

type K8sExecutor

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

func NewK8sExecutor

func NewK8sExecutor() (*K8sExecutor, error)

func (*K8sExecutor) CapturePodConfiguration

func (e *K8sExecutor) CapturePodConfiguration(testName, ns, podName string) error

func (*K8sExecutor) ClientSet

func (e *K8sExecutor) ClientSet() *kubernetes.Clientset

func (*K8sExecutor) CreateConfigMap

func (e *K8sExecutor) CreateConfigMap(ns string, configMap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)

func (*K8sExecutor) CreateNamespace

func (e *K8sExecutor) CreateNamespace(ns string) (*coreV1.Namespace, error)

func (*K8sExecutor) CreateNamespaceEventWatcher

func (e *K8sExecutor) CreateNamespaceEventWatcher(testName, ns string) (watch.Interface, error)

func (*K8sExecutor) CreatePod

func (e *K8sExecutor) CreatePod(ns string, pod *coreV1.Pod) (*coreV1.Pod, error)

func (*K8sExecutor) ExitCode

func (e *K8sExecutor) ExitCode(podFilter ContainerFilter) (int, error)

func (*K8sExecutor) IsPodRunning

func (e *K8sExecutor) IsPodRunning(podName string) (bool, error)

func (*K8sExecutor) NamespaceExists

func (e *K8sExecutor) NamespaceExists(ns string) (bool, error)

func (*K8sExecutor) PodContainerID

func (e *K8sExecutor) PodContainerID(podFilter ContainerFilter) string

func (*K8sExecutor) PodExists

func (e *K8sExecutor) PodExists(podFilter ContainerFilter) (bool, error)

func (*K8sExecutor) PodIP

func (e *K8sExecutor) PodIP(ns, name string) (string, error)

func (*K8sExecutor) RemoveConfigMap

func (e *K8sExecutor) RemoveConfigMap(ns, name string) error

func (*K8sExecutor) RemoveNamespace

func (e *K8sExecutor) RemoveNamespace(ns string) error

func (*K8sExecutor) RemovePod

func (e *K8sExecutor) RemovePod(podFilter ContainerFilter) (string, error)

func (*K8sExecutor) UpdateConfigMap

func (e *K8sExecutor) UpdateConfigMap(ns string, configMap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)

func (*K8sExecutor) WaitPodRemoved

func (e *K8sExecutor) WaitPodRemoved(podFilter ContainerFilter) error

Jump to

Keyboard shortcuts

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