import "k8s.io/kubernetes/test/e2e/instrumentation/logging/utils"
log_provider.go logging_agent.go logging_pod.go misc.go types.go wait.go
EnsureLoggingAgentDeployment checks that logging agent is present on each node and returns an error if that's not true.
func EnsureLoggingAgentRestartsCount(f *framework.Framework, appName string, maxRestarts int) error
EnsureLoggingAgentRestartsCount checks that each logging agent was restarted no more than maxRestarts times and returns an error if there's a pod which exceeds this number of restarts.
GetNodeIds returns the list of node names and panics in case of failure.
func WaitForLogs(c LogChecker, interval, timeout time.Duration) error
WaitForLogs checks that logs are ingested, as reported by the log checker until the timeout has passed. Function sleeps for interval between two log ingestion checks.
type FiniteLoggingPod interface { LoggingPod // ExpectedLinesNumber returns the number of lines that are // expected to be ingested from this pod. ExpectedLineCount() int }
FiniteLoggingPod is a logging pod that emits a known number of log lines.
func NewLoadLoggingPod(podName string, nodeName string, totalLines int, loggingDuration time.Duration) FiniteLoggingPod
NewLoadLoggingPod returns a logging pod that generates totalLines random lines over period of length loggingDuration. Lines generated by this pod are numbered and have well-defined structure.
IngestionPred is a type of a function that checks whether all required log entries were ingested.
var UntilFirstEntry IngestionPred = func(_ string, entries []LogEntry) (bool, error) { return len(entries) > 0, nil }
UntilFirstEntry is a IngestionPred that checks that at least one entry was ingested.
func UntilFirstEntryFromLocation(location string) IngestionPred
UntilFirstEntryFromLocation is a IngestionPred that checks that at least one entry from the log with a given name was ingested.
func UntilFirstEntryFromLog(log string) IngestionPred
UntilFirstEntryFromLog is a IngestionPred that checks that at least one entry from the log with a given name was ingested.
LogChecker is an interface for an entity that can check whether logging backend contains all wanted log entries.
func NewFullIngestionPodLogChecker(p LogProvider, slack float64, pods ...FiniteLoggingPod) LogChecker
NewFullIngestionPodLogChecker returns a log checks that works with numbered log entries generated by load logging pods and waits until all entries are ingested. If timeout is reached, fraction is lost logs up to slack is considered tolerable.
func NewLogChecker(p LogProvider, pred IngestionPred, timeout TimeoutFun, names ...string) LogChecker
NewLogChecker constructs a LogChecker for a list of names from custom IngestionPred and TimeoutFun.
func NewNumberedLogChecker(p LogProvider, pred NumberedIngestionPred, timeout NumberedTimeoutFun, names ...string) LogChecker
NewNumberedLogChecker returns a log checker that works with numbered log entries generated by load logging pods.
type LogEntry struct { LogName string TextPayload string Location string JSONPayload map[string]interface{} }
LogEntry represents a log entry, received from the logging backend.
TryGetEntryNumber returns the number of the log entry in sequence, if it was generated by the load logging pod (requires special log format).
type LogProvider interface { Init() error Cleanup() ReadEntries(name string) []LogEntry LoggingAgentName() string }
LogProvider interface provides an API to get logs from the logging backend.
type LoggingPod interface { // Name equals to the Kubernetes pod name. Name() string // Start method controls when the logging pod is started in the cluster. Start(f *framework.Framework) error }
LoggingPod is an interface of a pod that can be started and that logs something to its stdout, possibly indefinitely.
func NewExecLoggingPod(podName string, cmd []string) LoggingPod
NewExecLoggingPod returns a logging pod that produces logs through executing a command, passed in cmd.
func NewRepeatingLoggingPod(podName string, line string) LoggingPod
NewRepeatingLoggingPod returns a logging pod that each second prints line value to its stdout.
func StartAndReturnSelf(p LoggingPod, f *framework.Framework) (LoggingPod, error)
StartAndReturnSelf is a helper method to start a logging pod and immediately return it.
type LogsQueueCollection interface { Push(name string, logs ...LogEntry) Pop(name string) []LogEntry }
LogsQueueCollection is a thread-safe set of named log queues.
func NewLogsQueueCollection(queueSize int) LogsQueueCollection
NewLogsQueueCollection returns a new LogsQueueCollection where each queue is created with a default size of queueSize.
NumberedIngestionPred is a IngestionPred that takes into account sequential numbers of ingested entries.
NumberedTimeoutFun is a TimeoutFun that takes into account sequential numbers of ingested entries.
TimeoutFun is a function that is called when the waiting times out.
var JustTimeout TimeoutFun = func(names []string, ingested []bool) error { failedNames := []string{} for i, name := range names { if !ingested[i] { failedNames = append(failedNames, name) } } return fmt.Errorf("timed out waiting for ingestion, still not ingested: %s", strings.Join(failedNames, ",")) }
JustTimeout returns the error with the list of names for which backend is still still missing logs.
Package utils imports 19 packages (graph) and is imported by 132 packages. Updated 2020-02-27. Refresh now. Tools for package owners.