gatherer

package
v0.0.0-...-e541d71 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

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

CLI provides function to call the OpenShift CLI, which is using to simplify state gathering during tests. This wrapper was inspired by the openshift/origin version of a similar helper. Origin version https://github.com/openshift/origin/blob/1ec0eb3175f25b525abb39253528e230a9a85684/test/extended/util/client.go#L80

func NewCLI

func NewCLI(namespace string, client runtimeclient.Client, outputBasePath string) (*CLI, error)

NewCLI initializes the OC CLI wrapper.

func (*CLI) Args

func (oc *CLI) Args(args ...string) *CLI

Args sets the additional arguments for the OpenShift CLI command.

func (*CLI) DumpPodLogs

func (oc *CLI) DumpPodLogs(pods *corev1.PodList, extraLogArgs ...string)

DumpPodLogs will dump any pod logs within namespace.

func (*CLI) DumpPodLogsSinceTime

func (oc *CLI) DumpPodLogsSinceTime(ctx context.Context, sinceTime time.Time)

DumpPodLogsSinceTime will dump any pod logs within namespace from the time provided.

func (*CLI) Namespace

func (oc *CLI) Namespace() string

Namespace returns the name of the namespace used in the current test case. If the namespace is not set, an empty string is returned.

func (*CLI) Output

func (oc *CLI) Output() (string, error)

Output executes the command and returns stdout/stderr combined into one string.

func (*CLI) OutputToFile

func (oc *CLI) OutputToFile(filename string) (string, error)

OutputToFile executes the command and store output to a file.

func (*CLI) Outputs

func (oc *CLI) Outputs() (string, string, error)

Outputs executes the command and returns the stdout/stderr output as separate strings.

func (*CLI) Run

func (oc *CLI) Run(commands ...string) *CLI

Run executes given OpenShift CLI command verb (iow. "oc <verb>"). This function also override the default 'stdout' to redirect all output to a buffer and prepare the global flags such as namespace and config path.

func (CLI) WithExec

func (oc CLI) WithExec(execPath string) *CLI

WithExec overrides 'oc' executable path.

func (CLI) WithNamespace

func (oc CLI) WithNamespace(ns string) *CLI

WithNamespace sets a new namespace.

func (CLI) WithSubPath

func (oc CLI) WithSubPath(subPath string) *CLI

WithSubPath sets a sub path for files with CLI output.

func (CLI) WithoutNamespace

func (oc CLI) WithoutNamespace() *CLI

WithoutNamespace instructs the command should be invoked without adding --namespace parameter.

type StateGatherer

type StateGatherer struct {
	CLI *CLI
	// contains filtered or unexported fields
}

StateGatherer MAPI specific wrapper for the CLI helper Intended to provide helper functions for gathering MAPI specific resources as well as related pod logs.

func NewStateGatherer

func NewStateGatherer(ctx context.Context, ocCLI *CLI, gatherSinceTime time.Time) *StateGatherer

NewStateGatherer initializes StateGatherer.

func (*StateGatherer) GatherAll

func (sg *StateGatherer) GatherAll() error

GatherAll invokes GatherResources and GatherPodLogs subsequently.

func (*StateGatherer) GatherPodLogs

func (sg *StateGatherer) GatherPodLogs()

GatherPodLogs collects logs from pods in MAPI-related namespaces since a particular time. Skips file creation if no new logs since time were found there. Store files into '%CLI.outputBasePath%/%test_name%/logs'.

func (*StateGatherer) GatherResources

func (sg *StateGatherer) GatherResources() error

GatherResources helper method to collect MAPI-specific resources such as Machines, MachineSets, Nodes, Autoscalers, and so on. Store files into '%CLI.outputBasePath%/%test_name%/resources'.

func (StateGatherer) WithSinceTime

func (sg StateGatherer) WithSinceTime(time time.Time) *StateGatherer

WithSinceTime sinceTime parameter for the StateGatherer. Uses to indicate test start time and collect logs only since then.

func (StateGatherer) WithSpecReport

func (sg StateGatherer) WithSpecReport(specReport ginkgo.SpecReport) *StateGatherer

WithSpecReport sets ginkgo spec report for the StateGatherer instance. This test description uses to extract the test name and store relevant data in a respective sub-folder.

Jump to

Keyboard shortcuts

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