kubernetes: k8s.io/kubernetes/test/e2e/instrumentation/logging/utils Index | Files

package utils

import "k8s.io/kubernetes/test/e2e/instrumentation/logging/utils"


Package Files

log_provider.go logging_agent.go logging_pod.go misc.go types.go wait.go

func EnsureLoggingAgentDeployment Uses

func EnsureLoggingAgentDeployment(f *framework.Framework, appName string) error

EnsureLoggingAgentDeployment checks that logging agent is present on each node and returns an error if that's not true.

func EnsureLoggingAgentRestartsCount Uses

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.

func GetNodeIds Uses

func GetNodeIds(cs clientset.Interface) []string

GetNodeIds returns the list of node names and panics in case of failure.

func WaitForLogs Uses

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 Uses

type FiniteLoggingPod interface {

    // 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 Uses

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.

type IngestionPred Uses

type IngestionPred func(string, []LogEntry) (bool, error)

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 Uses

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 Uses

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.

type LogChecker Uses

type LogChecker interface {
    EntriesIngested() (bool, error)
    Timeout() error

LogChecker is an interface for an entity that can check whether logging backend contains all wanted log entries.

func NewFullIngestionPodLogChecker Uses

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 Uses

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 Uses

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 Uses

type LogEntry struct {
    LogName     string
    TextPayload string
    Location    string
    JSONPayload map[string]interface{}

LogEntry represents a log entry, received from the logging backend.

func (LogEntry) TryGetEntryNumber Uses

func (entry LogEntry) TryGetEntryNumber() (int, bool)

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 Uses

type LogProvider interface {
    Init() error
    ReadEntries(name string) []LogEntry
    LoggingAgentName() string

LogProvider interface provides an API to get logs from the logging backend.

type LoggingPod Uses

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 Uses

func NewExecLoggingPod(podName string, cmd []string) LoggingPod

NewExecLoggingPod returns a logging pod that produces logs through executing a command, passed in cmd.

func NewRepeatingLoggingPod Uses

func NewRepeatingLoggingPod(podName string, line string) LoggingPod

NewRepeatingLoggingPod returns a logging pod that each second prints line value to its stdout.

func StartAndReturnSelf Uses

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 Uses

type LogsQueueCollection interface {
    Push(name string, logs ...LogEntry)
    Pop(name string) []LogEntry

LogsQueueCollection is a thread-safe set of named log queues.

func NewLogsQueueCollection Uses

func NewLogsQueueCollection(queueSize int) LogsQueueCollection

NewLogsQueueCollection returns a new LogsQueueCollection where each queue is created with a default size of queueSize.

type NumberedIngestionPred Uses

type NumberedIngestionPred func(string, map[int]bool) (bool, error)

NumberedIngestionPred is a IngestionPred that takes into account sequential numbers of ingested entries.

type NumberedTimeoutFun Uses

type NumberedTimeoutFun func([]string, map[string]map[int]bool) error

NumberedTimeoutFun is a TimeoutFun that takes into account sequential numbers of ingested entries.

type TimeoutFun Uses

type TimeoutFun func([]string, []bool) error

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.