testhelper

package
v0.0.0-...-c2535d8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS = iota
	FAILURE
	ERROR
)
View Source
const (
	Namespace                       = "Namespace"
	Name                            = "Name"
	PodName                         = "Pod Name"
	ContainerName                   = "Container Name"
	ProcessID                       = "Process ID"
	ProcessCommandLine              = "Process CommandLine"
	SchedulingPolicy                = "Scheduling Policy"
	SchedulingPriority              = "Scheduling Priority"
	ReasonForNonCompliance          = "Reason For Non Compliance"
	ReasonForCompliance             = "Reason For Compliance"
	Category                        = "Category"
	RoleBindingName                 = "Role Binding Name"
	ClusterRoleName                 = "Cluster Role Reference Name"
	RoleBindingNamespace            = "Role Binding Namespace"
	ServiceAccountName              = "Service Account Name"
	ServiceMode                     = "Service Type"
	ServiceName                     = "Service Name"
	ServiceIPVersion                = "Service IP Version"
	DeploymentName                  = "Deployment Name"
	StatefulSetName                 = "StatefulSet Name"
	PodDisruptionBudgetReference    = "Pod Disruption Budget Reference"
	CustomResourceDefinitionName    = "Custom Resource Definition Name"
	CustomResourceDefinitionVersion = "Custom Resource Definition Version"
	SCCCapability                   = "SCC Capability"
	Path                            = "Path"
	Repository                      = "Repository"
	ImageName                       = "Image Name"
	Version                         = "Version"
	OpenAPIV3Schema                 = "OpenAPIV3Schema"
	CrdVersion                      = "Operator CRD Version"
	OCPVersion                      = "OCP Version"
	OCPChannel                      = "OCP Channel"
	NodeSelector                    = "Node Selector"
	PersistentVolumeName            = "Persistent Volume Name"
	PersistentVolumeClaimName       = "Persistent Volume Claim Name"
	TolerationKey                   = "Toleration Key"
	TolerationEffect                = "Toleration Effect"
	StorageClassName                = "Storage Class Name"
	StorageClassProvisioner         = "Storage Class Provisioner"
	ChangedFolders                  = "Changed Folders"
	DeletedFolders                  = "Deleted Folders"
	TaintBit                        = "Taint Bit"
	TaintBitDescription             = "Taint Bit Description"
	TaintMask                       = "Taint Mask"
	ModuleName                      = "Module Name"
	Taints                          = "Taints"
	SysctlKey                       = "Sysctl Key"
	SysctlValue                     = "Sysctl Value"
	OSImage                         = "OS Image"
	DebugPodName                    = "Debug Pod Name"

	// ICMP tests
	NetworkName              = "Network Name"
	DestinationNamespace     = "Destination Namespace"
	DestinationPodName       = "Destination Pod Name"
	DestinationContainerName = "Destination Container Name"
	DestinationIP            = "Destination IP"
	SourceIP                 = "Source IP"

	// Rbac roles
	RoleName     = "Role Name"
	Group        = "Group"
	ResourceName = "Resource Name"
	Verb         = "Verb"

	// Listening ports
	PortNumber   = "Port Number"
	PortProtocol = "Port Protocol"

	// OLM
	SubscriptionName = "Subscription Name"
	OperatorPhase    = "Operator Phase"
	OperatorName     = "Operator Name"

	// Lists
	OperatorList = "Operator List"
)
View Source
const (
	UndefinedType                = "Undefined Type"
	CnfType                      = "Cnf"
	PodType                      = "Pod"
	HelmType                     = "Helm"
	OperatorType                 = "Operator"
	ContainerType                = "Container"
	ContainerImageType           = "Container Image"
	NodeType                     = "Node"
	OCPClusterType               = "OCP Cluster"
	OCPClusterVersionType        = "OCP Cluster Version"
	ContainerProcessType         = "ContainerProcess"
	ContainerCategory            = "ContainerCategory"
	ServiceType                  = "Service"
	DeploymentType               = "Deployment"
	StatefulSetType              = "StatefulSet"
	ICMPResultType               = "ICMP result"
	NetworkType                  = "Network"
	CustomResourceDefinitionType = "Custom Resource Definition"
	RoleRuleType                 = "Role Rule"
	RoleType                     = "Role"
	ListeningPortType            = "Listening Port"
	DeclaredPortType             = "Declared Port"
	ContainerPort                = "Container Port"
	HostPortType                 = "Host Port"
	HostPathType                 = "Host Path"
	HelmVersionType              = "Helm Version"
	Error                        = "Error"
	OperatorPermission           = "Operator Cluster Permission"
	TaintType                    = "Taint"
	ImageDigest                  = "Image Digest"
	ImageRepo                    = "Image Repo"
	ImageTag                     = "Image Tag"
	ImageRegistry                = "Image Registry"
	PodRoleBinding               = "Pods with RoleBindings details"
)

Variables

View Source
var AbortTrigger string

Functions

func Equal

func Equal(p, other []*ReportObject) bool

func FailureReasonOutTestString

func FailureReasonOutTestString(p FailureReasonOut) (out string)

FailureReasonOutTestString returns a string representation of the FailureReasonOut struct.

func GetDaemonSetFailedToSpawnSkipFn

func GetDaemonSetFailedToSpawnSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoAffinityRequiredPodsSkipFn

func GetNoAffinityRequiredPodsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoBareMetalNodesSkipFn

func GetNoBareMetalNodesSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoCPUPinningPodsSkipFn

func GetNoCPUPinningPodsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoContainersUnderTestSkipFn

func GetNoContainersUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoCrdsUnderTestSkipFn

func GetNoCrdsUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoDeploymentsUnderTestSkipFn

func GetNoDeploymentsUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoGuaranteedPodsWithExclusiveCPUsSkipFn

func GetNoGuaranteedPodsWithExclusiveCPUsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoHugepagesPodsSkipFn

func GetNoHugepagesPodsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoIstioSkipFn

func GetNoIstioSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoNamespacesSkipFn

func GetNoNamespacesSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoOperatorCrdsSkipFn

func GetNoOperatorCrdsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoOperatorsSkipFn

func GetNoOperatorsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoPersistentVolumeClaimsSkipFn

func GetNoPersistentVolumeClaimsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoPersistentVolumesSkipFn

func GetNoPersistentVolumesSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoPodsUnderTestSkipFn

func GetNoPodsUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoRolesSkipFn

func GetNoRolesSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoSRIOVPodsSkipFn

func GetNoSRIOVPodsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoServicesUnderTestSkipFn

func GetNoServicesUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoStatefulSetsUnderTestSkipFn

func GetNoStatefulSetsUnderTestSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNoStorageClassesSkipFn

func GetNoStorageClassesSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetNonOCPClusterSkipFn

func GetNonOCPClusterSkipFn() func() (bool, string)

func GetNotEnoughWorkersSkipFn

func GetNotEnoughWorkersSkipFn(env *provider.TestEnvironment, minWorkerNodes int) func() (bool, string)

func GetNotIntrusiveSkipFn

func GetNotIntrusiveSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetPodsWithoutAffinityRequiredLabelSkipFn

func GetPodsWithoutAffinityRequiredLabelSkipFn(env *provider.TestEnvironment) func() (bool, string)

func GetSharedProcessNamespacePodsSkipFn

func GetSharedProcessNamespacePodsSkipFn(env *provider.TestEnvironment) func() (bool, string)

func ReportObjectTestString

func ReportObjectTestString(p []*ReportObject) (out string)

ReportObjectTestString returns a string representation of the given slice of ReportObject. Each ReportObject is formatted using the %#v format specifier and appended to the output string. The resulting string is enclosed in square brackets and prefixed with "[]testhelper.ReportObject{".

func ReportObjectTestStringPointer

func ReportObjectTestStringPointer(p []*ReportObject) (out string)

ReportObjectTestStringPointer takes a slice of pointers to ReportObject and returns a string representation of the objects. The returned string is in the format "[]*testhelper.ReportObject{&{...}, &{...}, ...}".

func ResultObjectsToString

func ResultObjectsToString(compliantObject, nonCompliantObject []*ReportObject) (string, error)

func ResultToString

func ResultToString(result int) (str string)

ResultToString converts an integer result code into a corresponding string representation. It takes an integer result as input and returns the corresponding string representation. The possible result codes are SUCCESS, FAILURE, and ERROR. If the input result code is not recognized, an empty string is returned.

Types

type FailureReasonOut

type FailureReasonOut struct {
	CompliantObjectsOut    []*ReportObject
	NonCompliantObjectsOut []*ReportObject
}

func (FailureReasonOut) Equal

func (p FailureReasonOut) Equal(other FailureReasonOut) bool

Equal checks if the current FailureReasonOut is equal to the other FailureReasonOut. It compares the CompliantObjectsOut and NonCompliantObjectsOut fields of both structs. Returns true if they are equal, false otherwise.

type ReportObject

type ReportObject struct {
	ObjectType         string
	ObjectFieldsKeys   []string
	ObjectFieldsValues []string
}

func NewCertifiedContainerReportObject

func NewCertifiedContainerReportObject(cii provider.ContainerImageIdentifier, aReason string, isCompliant bool) (out *ReportObject)

NewCertifiedContainerReportObject creates a new ReportObject for a certified container. It takes a ContainerImageIdentifier, aReason string, and a boolean indicating whether the container is compliant. It returns a pointer to the created ReportObject.

func NewClusterVersionReportObject

func NewClusterVersionReportObject(version, aReason string, isCompliant bool) (out *ReportObject)

NewClusterVersionReportObject creates a new ReportObject for a cluster version. It takes the version, aReason, and isCompliant as input parameters and returns the created ReportObject.

func NewContainerReportObject

func NewContainerReportObject(aNamespace, aPodName, aContainerName, aReason string, isCompliant bool) (out *ReportObject)

NewContainerReportObject creates a new ReportObject for a container. It takes the namespace, pod name, container name, reason, and compliance status as parameters. It returns a pointer to the created ReportObject.

func NewCrdReportObject

func NewCrdReportObject(aName, aVersion, aReason string, isCompliant bool) (out *ReportObject)

NewCrdReportObject creates a new ReportObject for a custom resource definition (CRD). It takes the name, version, reason, and compliance status as parameters and returns the created ReportObject.

func NewDeploymentReportObject

func NewDeploymentReportObject(aNamespace, aDeploymentName, aReason string, isCompliant bool) (out *ReportObject)

NewDeploymentReportObject creates a new ReportObject for a deployment. It takes the namespace, deployment name, reason, and compliance status as input parameters. It returns a pointer to the created ReportObject.

func NewHelmChartReportObject

func NewHelmChartReportObject(aNamespace, aHelmChartName, aReason string, isCompliant bool) (out *ReportObject)

NewHelmChartReportObject creates a new ReportObject for a Helm chart. It takes the namespace, Helm chart name, reason, and compliance status as input parameters. It returns the created ReportObject.

func NewNamespacedNamedReportObject

func NewNamespacedNamedReportObject(aReason, aType string, isCompliant bool, aNamespace, aName string) (out *ReportObject)

NewNamespacedNamedReportObject creates a new namespaced named report object with the given parameters. It returns a pointer to the created ReportObject. The report object contains the specified reason, type, compliance status, namespace, and name.

func NewNamespacedReportObject

func NewNamespacedReportObject(aReason, aType string, isCompliant bool, aNamespace string) (out *ReportObject)

NewNamespacedReportObject creates a new ReportObject with the specified reason, type, compliance status, and namespace. It adds the namespace field to the ReportObject.

func NewNodeReportObject

func NewNodeReportObject(aNodeName, aReason string, isCompliant bool) (out *ReportObject)

NewNodeReportObject creates a new ReportObject for a node with the given name, reason, and compliance status. It returns the created ReportObject.

func NewOperatorReportObject

func NewOperatorReportObject(aNamespace, aOperatorName, aReason string, isCompliant bool) (out *ReportObject)

NewOperatorReportObject creates a new ReportObject for an operator. It takes the namespace, operator name, reason, and compliance status as input parameters. It returns the created ReportObject.

func NewPodReportObject

func NewPodReportObject(aNamespace, aPodName, aReason string, isCompliant bool) (out *ReportObject)

NewPodReportObject creates a new ReportObject for a pod. It takes the namespace, pod name, reason, and compliance status as input parameters. It returns a pointer to the created ReportObject.

func NewReportObject

func NewReportObject(aReason, aType string, isCompliant bool) (out *ReportObject)

NewReportObject creates a new ReportObject with the specified reason, type, and compliance status. If isCompliant is true, the reason is added as a field with the key ReasonForCompliance. If isCompliant is false, the reason is added as a field with the key ReasonForNonCompliance. Returns a pointer to the created ReportObject.

func NewStatefulSetReportObject

func NewStatefulSetReportObject(aNamespace, aStatefulSetName, aReason string, isCompliant bool) (out *ReportObject)

NewStatefulSetReportObject creates a new ReportObject for a StatefulSet. It takes the namespace, statefulSetName, reason, and compliance status as parameters. It returns the created ReportObject.

func NewTaintReportObject

func NewTaintReportObject(taintBit, nodeName, aReason string, isCompliant bool) (out *ReportObject)

NewTaintReportObject creates a new ReportObject with taint-related information. It takes in the taintBit, nodeName, aReason, and isCompliant parameters and returns a pointer to the created ReportObject.

func (*ReportObject) AddField

func (obj *ReportObject) AddField(aKey, aValue string) (out *ReportObject)

AddField adds a key-value pair to the ReportObject. It appends the given key to the ObjectFieldsKeys slice and the given value to the ObjectFieldsValues slice. It returns the modified ReportObject.

func (*ReportObject) SetContainerProcessValues

func (obj *ReportObject) SetContainerProcessValues(aPolicy, aPriority, aCommandLine string) *ReportObject

SetContainerProcessValues sets the values for a container process in the report object. It takes the scheduling policy, scheduling priority, and command line as input parameters. It adds the process command line, scheduling policy, and scheduling priority fields to the report object. Finally, it sets the object type to ContainerProcessType.

func (*ReportObject) SetType

func (obj *ReportObject) SetType(aType string) (out *ReportObject)

SetType sets the type of the ReportObject. It takes aType as a parameter and updates the ObjectType field of the ReportObject. It returns a pointer to the updated ReportObject.

Jump to

Keyboard shortcuts

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