common

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterScope        = ""
	FrisbeeInstallation = "frisbee"
	FrisbeeNamespace    = "frisbee"
)
View Source
const (
	FrisbeeRepo  = "https://carv-ics-forth.github.io/frisbee/charts"
	JetstackRepo = "https://charts.jetstack.io"
)
View Source
const (
	NotReadyRegex        = `.* container "(\w+)" in pod "(.*)" is waiting to start: (\w+)`
	NoPodsFoundReg       = `.* pods "\w+" not found`
	NotResourcesFoundReg = `No resources found*`
	NotFound             = `Error from server (NotFound)`

	NoResources         = `No resources found in .+ namespace.`
	NoMatchingResources = `no matching resources found`
	PodNotFound         = `Error from server \(NotFound\): pods ".+" not found`
	NamespaceNotFound   = `Error from server \(NotFound\): namespaces ".+" not found`
)
View Source
const (
	Scenarios      = "scenarios.frisbee.dev"
	Clusters       = "clusters.frisbee.dev"
	Services       = "services.frisbee.dev"
	Chaos          = "chaos.frisbee.dev"
	Cascades       = "cascades.frisbee.dev"
	Calls          = "calls.frisbee.dev"
	VirtualObjects = "virtualobjects.frisbee.dev"
	Templates      = "templates.frisbee.dev"
)
View Source
const (
	NetworkChaos = "networkchaos.chaos-mesh.org"
	PodChaos     = "podchaos.chaos-mesh.org"
	IOChaos      = "iochaos.chaos-mesh.org"
	KernelChaos  = "kernelchaos.chaos-mesh.org"
	TimeChaos    = "timechaos.chaos-mesh.org"
)
View Source
const (
	K8PODs            = "pods"
	K8PVCs            = "persistentvolumeclaims"
	K8PVs             = "persistentvolumes"
	K8SStorageClasses = "storageclasses.storage.k8s.io"
)
View Source
const (
	AllPods = "all"
)
View Source
const EmptyChaosResourceInspectionFields = "Kind   Job   InjectionTime   Phase   Target"
View Source
const EmptyK8SResourceInspectionFields = "API   Kind   Name   Action   Component   Phase*   Reason*   Message*"
View Source
const EmptyResourceInspectionFields = "Name   Kind   Job   Component   Phase   Reason   Message"
View Source
const EmptyTemplateResources = "Chart   Template   Parameters"
View Source
const (
	K8SRemoveFinalizer = `--patch=[{"op":"remove","path":"/metadata/finalizers"}]`
)
View Source
const (
	ManagedNamespace = "app.kubernetes.io/managed-by=Frisbee"
)
View Source
const (
	TestTimeout = "24h"
)

Variables

View Source
var BackoffPodCreation = wait.Backoff{
	Duration: 10 * time.Second,
	Factor:   1.5,
	Jitter:   0.1,
	Steps:    60,
}
View Source
var ChaosResourceInspectionFields = strings.Join([]string{
	"custom-columns=Kind:.kind",
	"Job:.metadata.name",
	"InjectionTime:.metadata.creationTimestamp",
	"Phase:.status.experiment.desiredPhase",
	"Target:.status.experiment.containerRecords[*].id",
}, ",")
View Source
var FrisbeeResourceInspectionFields = strings.Join([]string{
	"custom-columns=Name:.metadata.namespace",
	"Kind:.kind",
	"Job:.metadata.name",
	"Component:.metadata.labels.scenario\\.frisbee\\.dev\\/component",
	"Phase:.status.phase",
	"Reason:.status.reason",
	"Message:.status.message",
}, ",")
View Source
var K8SResourceInspectionFields = strings.Join([]string{
	"custom-columns=API:.apiVersion",
	"Kind:.kind",
	"Name:.metadata.name",
	"Action:.metadata.labels.scenario\\.frisbee\\.dev\\/action",
	"Component:.metadata.labels.scenario\\.frisbee\\.dev\\/component",
	"Phase*:.status.phase",
	"Reason*:.status.reason",
	"Message*:.status.message",
}, ",")
View Source
var TemplateInspectionFields = strings.Join([]string{
	"custom-columns=Chart:.metadata.annotations.meta\\.helm\\.sh\\/release-name",
	"Template:.metadata.name",
	"Parameters:spec.inputs.parameters",
}, ",")

Functions

func CRDsExist added in v1.0.28

func CRDsExist(apiresource string) bool

func CompleteFlags added in v1.0.41

func CompleteFlags(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

func CompleteScenarios added in v1.0.41

func CompleteScenarios(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

CompleteScenarios list the available test-cases

func CompleteServices added in v1.0.41

func CompleteServices(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CompleteServices list the available services. Assumes that args[0] is the namespace

func CreateNamespace

func CreateNamespace(name string, labels ...string) error

func Dashboards

func Dashboards(testName string) error

func DeleteNamespaces

func DeleteNamespaces(selector string, testNames ...string) error

func ErrContainerNotReady added in v1.0.26

func ErrContainerNotReady(out []byte) bool

func ErrNamespaceNotFound added in v1.0.37

func ErrNamespaceNotFound(out []byte) bool

func ErrNoMatchingResources added in v1.0.41

func ErrNoMatchingResources(out []byte) bool

func ErrNoResources added in v1.0.37

func ErrNoResources(out []byte) bool

func ErrNotFound added in v1.0.26

func ErrNotFound(out []byte) bool

func ErrPodNotFound added in v1.0.37

func ErrPodNotFound(out []byte) bool

func ForceDelete

func ForceDelete(testName string) error

ForceDelete iterates the Frisbee CRDs and remove its finalizers.

func GetChaosResources

func GetChaosResources(testName string) error

func GetFrisbeeResources

func GetFrisbeeResources(testName string, watch bool) error

func GetK8sEvents added in v1.0.28

func GetK8sEvents(testName string) error

func GetK8sResources

func GetK8sResources(testName string) error

func GetTemplateResources

func GetTemplateResources(testName string) error

func Helm

func Helm(testName string, command ...string) ([]byte, error)

func HelmIgnoreNotFound added in v1.0.28

func HelmIgnoreNotFound(err error) error

func InstallFrisbeeOnK8s added in v1.0.28

func InstallFrisbeeOnK8s(command []string, options *FrisbeeInstallOptions)

func InstallPDFExporter added in v1.0.41

func InstallPDFExporter(location string)

func Kubectl

func Kubectl(testName string, command ...string) ([]byte, error)

func KubectlLogs added in v1.0.37

func KubectlLogs(ctx context.Context, testName string, tail bool, lines int, pods ...string) error

KubectlLogs provides convenience on printing the logs from prods. Filter query:

  • Run with '--logs all'. -> monitor all pods (SYS + SUT)
  • Run with '--logs SYS'. -> monitor only SYS pods
  • Run with '--logs SUT'. -> monitor only SUT pods
  • Run with '--logs pod1'. -> monitor a specific pod
  • Run with '--logs pod1,pod2,pod3,...'. -> monitoring multiple pods

func LabelNamespace added in v1.0.25

func LabelNamespace(name string, labels ...string) error

func LoadPDFExporter added in v1.0.42

func LoadPDFExporter(cacheLocation string)

func LoggedHelm added in v1.0.28

func LoggedHelm(testName string, command ...string) ([]byte, error)

func LoggedKubectl added in v1.0.28

func LoggedKubectl(testName string, command ...string) ([]byte, error)

func NoArgs added in v1.0.41

func NoArgs(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

func OpenShell

func OpenShell(testName string, podName string, shellArgs ...string) error

func PopulateInstallFlags added in v1.0.28

func PopulateInstallFlags(cmd *cobra.Command, options *FrisbeeInstallOptions)

func RenderGoTemplate

func RenderGoTemplate(item interface{}, w io.Writer, tpl string) error

func RenderGoTemplateList

func RenderGoTemplateList(list []interface{}, w io.Writer, tpl string) error

func RenderJSON

func RenderJSON(obj interface{}, w io.Writer) error

func RenderList

func RenderList(obj interface{}, w io.Writer) error

func RenderPrettyList

func RenderPrettyList(obj ui.TableData, w io.Writer) error

func RenderYaml

func RenderYaml(obj interface{}, w io.Writer) error

func RunTest

func RunTest(testName string, testFile string, mode ValidationMode) error

func WaitForCondition added in v1.0.27

func WaitForCondition(ctx context.Context, testName string, condition v1alpha1.ConditionType, timeout string) error

Types

type CliObjRenderer

type CliObjRenderer func(ui *ui.UI, obj interface{}) error

type FrisbeeInstallOptions added in v1.0.28

type FrisbeeInstallOptions struct {
	NoCertManager bool
}

type OutputType

type OutputType string
const (
	OutputGoTemplate OutputType = "go"
	OutputJSON       OutputType = "json"
	OutputYAML       OutputType = "yaml"
	OutputPretty     OutputType = "pretty"
)

type PDFExporter added in v1.0.41

type PDFExporter string
var (
	// DefaultPDFExport points to either FastPDFExporter or LongPDFExporter.
	DefaultPDFExport PDFExporter

	// FastPDFExporter is fast on individual panels, but does not render dashboard with many panels.
	FastPDFExporter PDFExporter

	// LongPDFExporter can render dashboards with many panels, but it's a bit slow.
	LongPDFExporter PDFExporter
)

type ValidationMode added in v1.0.30

type ValidationMode uint8
const (
	ValidationNone ValidationMode = iota
	ValidationClient
	ValidationServer
)

Jump to

Keyboard shortcuts

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