e2e

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyNewVersion added in v0.7.0

func ApplyNewVersion(t *testing.T, data *TestData, antreaYML, chOperatorYML, flowVisibilityYML string)

func ClearCovFolder added in v0.7.1

func ClearCovFolder(nodeName, covPrefix string) error

func ControlPlaneNoScheduleTolerations added in v0.7.1

func ControlPlaneNoScheduleTolerations() []corev1.Toleration

func CopyCovFolder added in v0.7.1

func CopyCovFolder(nodeName, covDir, covPrefix string) error

func DeleteJob added in v0.5.0

func DeleteJob(t *testing.T, data *TestData, cmd string) (stdout string, err error)

func ExportLogs added in v0.7.1

func ExportLogs(tb testing.TB, data *TestData, logsSubDir string, writeNodeLogs bool, testMain bool, cpNodeName string)

func GetImageName added in v0.7.1

func GetImageName(uri string) string

GetImageName gets the image name from the fully qualified URI. For example: "gcr.io/kubernetes-e2e-test-images/agnhost:2.8" gets "agnhost".

func GetJobStatus added in v0.5.0

func GetJobStatus(t *testing.T, data *TestData, cmd string) (stdout string, err error)

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

IsDirEmpty checks whether a directory is empty or not.

func ListJobs added in v0.5.0

func ListJobs(t *testing.T, data *TestData, cmd string) (stdout string, err error)

func RetrieveJobResult added in v0.5.0

func RetrieveJobResult(t *testing.T, data *TestData, cmd string) (stdout string, err error)

func RunJob added in v0.5.0

func RunJob(t *testing.T, data *TestData, jobcmd string) (stdout string, jobName string, err error)

func SetupClickHouseConnection added in v0.5.0

func SetupClickHouseConnection(clientset kubernetes.Interface, kubeconfig string) (connect *sql.DB, portForward *portforwarder.PortForwarder, err error)

func TeardownFlowVisibility added in v0.7.1

func TeardownFlowVisibility(tb testing.TB, data *TestData, config FlowVisibilitySetUpConfig, nodeName string)

func TheiaManagerRestart added in v0.6.0

func TheiaManagerRestart(t *testing.T, data *TestData, jobName1 string, job string) error

func VerifyJobCleaned added in v0.6.0

func VerifyJobCleaned(t *testing.T, data *TestData, jobName string, tablename string, prefixlen int) error

Types

type ClickHouseFullRow added in v0.7.1

type ClickHouseFullRow struct {
	TimeInserted                         time.Time `json:"timeInserted"`
	FlowStartSeconds                     time.Time `json:"flowStartSeconds"`
	FlowEndSeconds                       time.Time `json:"flowEndSeconds"`
	FlowEndSecondsFromSourceNode         time.Time `json:"flowEndSecondsFromSourceNode"`
	FlowEndSecondsFromDestinationNode    time.Time `json:"flowEndSecondsFromDestinationNode"`
	FlowEndReason                        uint8     `json:"flowEndReason"`
	SourceIP                             string    `json:"sourceIP"`
	DestinationIP                        string    `json:"destinationIP"`
	SourceTransportPort                  uint16    `json:"sourceTransportPort"`
	DestinationTransportPort             uint16    `json:"destinationTransportPort"`
	ProtocolIdentifier                   uint8     `json:"protocolIdentifier"`
	PacketTotalCount                     uint64    `json:"packetTotalCount,string"`
	OctetTotalCount                      uint64    `json:"octetTotalCount,string"`
	PacketDeltaCount                     uint64    `json:"packetDeltaCount,string"`
	OctetDeltaCount                      uint64    `json:"octetDeltaCount,string"`
	ReversePacketTotalCount              uint64    `json:"reversePacketTotalCount,string"`
	ReverseOctetTotalCount               uint64    `json:"reverseOctetTotalCount,string"`
	ReversePacketDeltaCount              uint64    `json:"reversePacketDeltaCount,string"`
	ReverseOctetDeltaCount               uint64    `json:"reverseOctetDeltaCount,string"`
	SourcePodName                        string    `json:"sourcePodName"`
	SourcePodNamespace                   string    `json:"sourcePodNamespace"`
	SourceNodeName                       string    `json:"sourceNodeName"`
	DestinationPodName                   string    `json:"destinationPodName"`
	DestinationPodNamespace              string    `json:"destinationPodNamespace"`
	DestinationNodeName                  string    `json:"destinationNodeName"`
	DestinationClusterIP                 string    `json:"destinationClusterIP"`
	DestinationServicePort               uint16    `json:"destinationServicePort"`
	DestinationServicePortName           string    `json:"destinationServicePortName"`
	IngressNetworkPolicyName             string    `json:"ingressNetworkPolicyName"`
	IngressNetworkPolicyNamespace        string    `json:"ingressNetworkPolicyNamespace"`
	IngressNetworkPolicyRuleName         string    `json:"ingressNetworkPolicyRuleName"`
	IngressNetworkPolicyRuleAction       uint8     `json:"ingressNetworkPolicyRuleAction"`
	IngressNetworkPolicyType             uint8     `json:"ingressNetworkPolicyType"`
	EgressNetworkPolicyName              string    `json:"egressNetworkPolicyName"`
	EgressNetworkPolicyNamespace         string    `json:"egressNetworkPolicyNamespace"`
	EgressNetworkPolicyRuleName          string    `json:"egressNetworkPolicyRuleName"`
	EgressNetworkPolicyRuleAction        uint8     `json:"egressNetworkPolicyRuleAction"`
	EgressNetworkPolicyType              uint8     `json:"egressNetworkPolicyType"`
	TcpState                             string    `json:"tcpState"`
	FlowType                             uint8     `json:"flowType"`
	SourcePodLabels                      string    `json:"sourcePodLabels"`
	DestinationPodLabels                 string    `json:"destinationPodLabels"`
	Throughput                           uint64    `json:"throughput,string"`
	ReverseThroughput                    uint64    `json:"reverseThroughput,string"`
	ThroughputFromSourceNode             uint64    `json:"throughputFromSourceNode,string"`
	ThroughputFromDestinationNode        uint64    `json:"throughputFromDestinationNode,string"`
	ReverseThroughputFromSourceNode      uint64    `json:"reverseThroughputFromSourceNode,string"`
	ReverseThroughputFromDestinationNode uint64    `json:"reverseThroughputFromDestinationNode,string"`
	ClusterUUID                          string    `json:"clusterUUID"`
	EgressName                           string    `json:"egressName"`
	EgressIP                             string    `json:"egressIP"`
	Trusted                              uint8     `json:"trusted"`
}

func GetClickHouseOutput added in v0.7.1

func GetClickHouseOutput(t *testing.T, data *TestData, srcIP, dstIP, srcPort string, isDstService, checkAllRecords bool) []*ClickHouseFullRow

GetClickHouseOutput queries clickhouse with built-in client and checks if we have received all the expected records for a given flow with source IP, destination IP and source port. We send source port to ignore the control flows during the iperf test. Polling timeout is coded assuming IPFIX output has been checked first.

type ClusterInfo

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

type ClusterNode

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

type FlowVisibilitySetUpConfig added in v0.7.0

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

func CreateFlowVisibilitySetUpConfig added in v0.7.1

func CreateFlowVisibilitySetUpConfig(sparkOperator, grafana, clickHouseLocalPv, flowAggregator, flowAggregatorOnly bool) FlowVisibilitySetUpConfig

type PodCondition

type PodCondition func(*corev1.Pod) (bool, error)

type PodIPs

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

func ParsePodIPs added in v0.7.1

func ParsePodIPs(podIPStrings sets.Set[string]) (*PodIPs, error)

func (PodIPs) GetIPv4 added in v0.7.1

func (p PodIPs) GetIPv4() *net.IP

func (PodIPs) GetIPv6 added in v0.7.1

func (p PodIPs) GetIPv6() *net.IP

func (PodIPs) String

func (p PodIPs) String() string

type TestData

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

TestData stores the state required for each test case.

func (*TestData) CleanACNPs

func (data *TestData) CleanACNPs() error

CleanACNPs is a convenience function for deleting all Antrea ClusterNetworkPolicies in the cluster.

func (*TestData) CleanCGs

func (data *TestData) CleanCGs() error

CleanCGs is a convenience function for deleting all ClusterGroups in the cluster.

func (*TestData) Cleanup

func (data *TestData) Cleanup(namespaces []string)

func (*TestData) CollectPodCIDRInfo added in v0.7.1

func (data *TestData) CollectPodCIDRInfo(controlPlaneName string) error

func (*TestData) CreateClient

func (data *TestData) CreateClient(kubeconfigPath string) error

CreateClient initializes the K8s clientset in the TestData structure.

func (*TestData) CreateNamespace

func (data *TestData) CreateNamespace(namespace string, mutateFunc func(*corev1.Namespace)) error

CreateNamespace creates the provided namespace.

func (*TestData) CreateOrUpdateANP

func (data *TestData) CreateOrUpdateANP(anp *v1beta1.NetworkPolicy) (*v1beta1.NetworkPolicy, error)

CreateOrUpdateANP is a convenience function for updating/creating Antrea NetworkPolicies.

func (*TestData) CreatePodOnNodeInNamespace

func (data *TestData) CreatePodOnNodeInNamespace(name, ns string, nodeName, ctrName string, image string, command []string, args []string, env []corev1.EnvVar, ports []corev1.ContainerPort, hostNetwork bool, mutateFunc func(*corev1.Pod)) error

CreatePodOnNodeInNamespace creates a pod in the provided namespace with a container whose type is decided by imageName. Pod will be scheduled on the specified Node (if nodeName is not empty). mutateFunc can be used to customize the Pod if the other parameters don't meet the requirements.

func (*TestData) CreateService

func (data *TestData) CreateService(serviceName, namespace string, port, targetPort int32, selector map[string]string, affinity, nodeLocalExternal bool,
	serviceType corev1.ServiceType, ipFamily *corev1.IPFamily) (*corev1.Service, error)

CreateService creates a service with port and targetPort.

func (*TestData) CreateServiceWithAnnotations

func (data *TestData) CreateServiceWithAnnotations(serviceName, namespace string, port, targetPort int32, protocol corev1.Protocol, selector map[string]string, affinity, nodeLocalExternal bool,
	serviceType corev1.ServiceType, ipFamily *corev1.IPFamily, annotations map[string]string) (*corev1.Service, error)

CreateServiceWithAnnotations creates a service with Annotation

func (*TestData) DeleteACNP

func (data *TestData) DeleteACNP(name string) error

DeleteACNP is a convenience function for deleting ACNP by name.

func (*TestData) DeleteANP

func (data *TestData) DeleteANP(ns, name string) error

DeleteANP is a convenience function for deleting ANP by name and Namespace.

func (*TestData) DeleteNamespace

func (data *TestData) DeleteNamespace(namespace string, timeout time.Duration) error

DeleteNamespace deletes the provided namespace and waits for deletion to actually complete.

func (*TestData) DeletePod

func (data *TestData) DeletePod(namespace, name string) error

DeletePod deletes a Pod in the test namespace.

func (*TestData) DeleteV1Alpha2CG

func (data *TestData) DeleteV1Alpha2CG(name string) error

DeleteV1Alpha2CG is a convenience function for deleting crd/v1alpha2 ClusterGroup by name.

func (*TestData) DeleteV1Alpha3CG

func (data *TestData) DeleteV1Alpha3CG(name string) error

DeleteV1Alpha3CG is a convenience function for deleting core/v1alpha3 ClusterGroup by name.

func (*TestData) GetClientSet added in v0.7.1

func (data *TestData) GetClientSet() kubernetes.Interface

func (*TestData) GetClusterName added in v0.7.1

func (data *TestData) GetClusterName() string

func (*TestData) GetControlPlaneNodeIP added in v0.7.1

func (data *TestData) GetControlPlaneNodeIP(label string) (string, error)

func (*TestData) GetFlowAggregator added in v0.7.1

func (data *TestData) GetFlowAggregator() (string, error)

GetFlowAggregator retrieves the name of the Flow-Aggregator Pod (flow-aggregator-*) running on a specific Node.

func (*TestData) GetFlowAggregatorConfigMap added in v0.7.1

func (data *TestData) GetFlowAggregatorConfigMap() (*corev1.ConfigMap, error)

func (*TestData) GetPodLogs added in v0.2.0

func (data *TestData) GetPodLogs(namespace, name string, podLogOpts *corev1.PodLogOptions) (string, error)

Gets pod logs from Pod

func (*TestData) GetPodV4NetworkCIDR added in v0.7.1

func (data *TestData) GetPodV4NetworkCIDR() string

func (*TestData) GetPodV6NetworkCIDR added in v0.7.1

func (data *TestData) GetPodV6NetworkCIDR() string

func (*TestData) GetService

func (data *TestData) GetService(namespace, name string) (*corev1.Service, error)

GetService is a convenience function for getting Service

func (*TestData) InitProvider

func (data *TestData) InitProvider(providerName, providerConfigPath string) error

func (*TestData) KillProcesses added in v0.7.1

func (data *TestData) KillProcesses(namespace, podName, containerName, processName string) error

func (*TestData) MutateFlowAggregatorConfigMap added in v0.7.1

func (data *TestData) MutateFlowAggregatorConfigMap(datbaseURL string, security bool) error

func (*TestData) PodWaitFor

func (data *TestData) PodWaitFor(timeout time.Duration, name, namespace string, condition PodCondition) (*corev1.Pod, error)

PodWaitFor polls the K8s apiserver until the specified Pod is found (in the test Namespace) and the condition predicate is met (or until the provided timeout expires).

func (*TestData) PodWaitForReady added in v0.7.1

func (data *TestData) PodWaitForReady(timeout time.Duration, name, namespace string) error

PodWaitForReady polls the k8s apiserver until the specified Pod is in the "Ready" status (or until the provided timeout expires).

func (*TestData) RunCommandFromPod

func (data *TestData) RunCommandFromPod(podNamespace string, podName string, containerName string, cmd []string) (stdout string, stderr string, err error)

RunCommandFromPod Run the provided command in the specified Container for the give Pod and returns the contents of stdout and stderr as strings. An error either indicates that the command couldn't be run or that the command returned a non-zero error code.

func (*TestData) RunCommandOnNode

func (data *TestData) RunCommandOnNode(nodeName string, cmd string) (code int, stdout string, stderr string, err error)

RunCommandOnNode is a convenience wrapper around the Provider interface RunCommandOnNode method.

func (*TestData) SetClusterName added in v0.7.1

func (data *TestData) SetClusterName(name string)

func (*TestData) WaitNetworkPolicyRealize

func (data *TestData) WaitNetworkPolicyRealize(nodeName string, table *openflow.Table, policyRules int) error

type TestOptions

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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