Documentation
¶
Index ¶
- Constants
- Variables
- func GetAgentFeatures() (featuregate.FeatureGate, error)
- func GetControllerFeatures() (featuregate.FeatureGate, error)
- func IPFamily(ip string) string
- func IsDirEmpty(name string) (bool, error)
- func NodeCount() int
- func NodeName(idx int) string
- func ProbeCommand(url, protocol, executor string) []string
- func RunTests(m *testing.M) int
- func SkipIfIPv6Cluster(tb testing.TB)
- func SkipIfNotAntreaIPAMTest(tb testing.TB)
- func SkipIfNotIPv4Cluster(tb testing.TB)
- func SkipIfNotIPv6Cluster(tb testing.TB)
- func TeardownTest(tb testing.TB, data *TestData)
- type ClusterInfo
- type ClusterNode
- type Connectivity
- type ConnectivityTable
- func (ct *ConnectivityTable) Compare(other *ConnectivityTable) *TruthTable
- func (ct *ConnectivityTable) Get(from string, to string) PodConnectivityMark
- func (ct *ConnectivityTable) PrettyPrint(indent string) string
- func (ct *ConnectivityTable) Set(from string, to string, value PodConnectivityMark)
- func (ct *ConnectivityTable) SetAllFrom(from string, value PodConnectivityMark)
- func (ct *ConnectivityTable) SetAllTo(to string, value PodConnectivityMark)
- type CustomPod
- type CustomProbe
- type ExternalInfo
- type KubernetesUtils
- func (k *KubernetesUtils) Bootstrap(namespaces map[string]TestNamespaceMeta, podsPerNamespace []string, ...) (map[string][]string, error)
- func (k *KubernetesUtils) CleanGroups(namespace string) error
- func (k *KubernetesUtils) Cleanup(namespaces map[string]TestNamespaceMeta)
- func (k *KubernetesUtils) CreateOrUpdateGroup(g *crdv1beta1.Group) (*crdv1beta1.Group, error)
- func (k *KubernetesUtils) DeleteGroup(namespace, name string) error
- func (k *KubernetesUtils) GetCG(name string) (*crdv1beta1.ClusterGroup, error)
- func (k *KubernetesUtils) GetClusterSearchDomain() (string, error)
- func (k *KubernetesUtils) GetGroup(namespace, name string) (*crdv1beta1.Group, error)
- func (k *KubernetesUtils) GetPodByLabel(ns string, name string) (*v1.Pod, error)
- func (k *KubernetesUtils) GetPodsByLabel(ns string, key string, val string) ([]v1.Pod, error)
- func (k *KubernetesUtils) LabelPod(ns, name, key, value string) (*v1.Pod, error)
- func (k *KubernetesUtils) Probe(ns1, pod1, ns2, pod2 string, port int32, protocol utils.AntreaPolicyProtocol, ...) (PodConnectivityMark, error)
- func (k *KubernetesUtils) ProbeAddr(ns, podLabelKey, podLabelValue, dstAddr string, port int32, ...) (PodConnectivityMark, error)
- func (k *KubernetesUtils) Validate(allPods []Pod, reachability *Reachability, ports []int32, ...)
- func (k *KubernetesUtils) ValidateRemoteCluster(remoteCluster *KubernetesUtils, allPods []Pod, reachability *Reachability, ...)
- type NPEvalActionType
- type NPEvaluation
- type NPEvaluationSpec
- type Pod
- type PodBuilder
- func (b *PodBuilder) AddVolume(volume corev1.Volume) *PodBuilder
- func (b *PodBuilder) AddVolumeMount(volumeMount corev1.VolumeMount) *PodBuilder
- func (b *PodBuilder) Create(data *TestData) error
- func (b *PodBuilder) InHostNetwork() *PodBuilder
- func (b *PodBuilder) MountConfigMap(configMapName string, mountPath string, volumeName string) *PodBuilder
- func (b *PodBuilder) MountHostPath(hostPath string, hostPathType corev1.HostPathType, mountPath string, ...) *PodBuilder
- func (b *PodBuilder) MountSecret(secretName string, mountPath string, volumeName string) *PodBuilder
- func (b *PodBuilder) OnNode(nodeName string) *PodBuilder
- func (b *PodBuilder) Privileged() *PodBuilder
- func (b *PodBuilder) WithAnnotations(annotations map[string]string) *PodBuilder
- func (b *PodBuilder) WithArgs(args []string) *PodBuilder
- func (b *PodBuilder) WithCommand(command []string) *PodBuilder
- func (b *PodBuilder) WithContainerName(ctrName string) *PodBuilder
- func (b *PodBuilder) WithCustomDNSConfig(dnsConfig *corev1.PodDNSConfig) *PodBuilder
- func (b *PodBuilder) WithEnv(env []corev1.EnvVar) *PodBuilder
- func (b *PodBuilder) WithHostNetwork(v bool) *PodBuilder
- func (b *PodBuilder) WithLabels(labels map[string]string) *PodBuilder
- func (b *PodBuilder) WithMutateFunc(f func(*corev1.Pod)) *PodBuilder
- func (b *PodBuilder) WithPorts(ports []corev1.ContainerPort) *PodBuilder
- func (b *PodBuilder) WithReadinessProbe(probe *corev1.Probe) *PodBuilder
- func (b *PodBuilder) WithResources(ResourceRequests, ResourceLimits corev1.ResourceList) *PodBuilder
- func (b *PodBuilder) WithServiceAccountName(name string) *PodBuilder
- type PodCondition
- type PodConnectivityMark
- type PodIPs
- type PodInfo
- type Reachability
- func (r *Reachability) Expect(pod1 Pod, pod2 Pod, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectAllEgress(pod Pod, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectAllIngress(pod Pod, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectAllSelfNamespace(connectivity PodConnectivityMark)
- func (r *Reachability) ExpectConn(spec *Connectivity)
- func (r *Reachability) ExpectEgressToNamespace(pod Pod, namespace string, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectIngressFromNamespace(pod Pod, namespace string, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectNamespaceEgressToNamespace(srcNamespace, dstNamespace string, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectNamespaceIngressFromNamespace(dstNamespace, srcNamespace string, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectSelf(allPods []Pod, connectivity PodConnectivityMark)
- func (r *Reachability) ExpectSelfNamespace(namespace string, connectivity PodConnectivityMark)
- func (r *Reachability) NewReachabilityWithSameExpectations() *Reachability
- func (r *Reachability) Observe(pod1 Pod, pod2 Pod, connectivity PodConnectivityMark)
- func (r *Reachability) PrintSummary(printExpected bool, printObserved bool, printComparison bool)
- func (r *Reachability) Summary() (trueObs int, falseObs int, comparison *TruthTable)
- type TestCase
- type TestData
- func (data *TestData) BuildService(svcName, svcNS string, port, targetPort int, selector map[string]string, ...) *v1.Service
- func (data *TestData) BuildServiceAccount(name, ns string, labels map[string]string) *v1.ServiceAccount
- func (data *TestData) CleanACNPs() error
- func (data *TestData) CleanANNPs(namespaces []string) error
- func (data *TestData) CleanCGs() error
- func (data *TestData) CleanNetworkPolicies(namespaces map[string]TestNamespaceMeta) error
- func (data *TestData) CleanServices(namespaces map[string]string) error
- func (data *TestData) CreateClient(kubeconfigPath string) error
- func (data *TestData) CreateConfigMap(configMap *v1.ConfigMap) (*v1.ConfigMap, error)
- func (data *TestData) CreateNamespace(namespace string, mutateFunc func(*corev1.Namespace)) error
- func (data *TestData) CreateOrUpdateACNP(cnp *crdv1beta1.ClusterNetworkPolicy) (*crdv1beta1.ClusterNetworkPolicy, error)
- func (data *TestData) CreateOrUpdateANNP(annp *crdv1beta1.NetworkPolicy) (*crdv1beta1.NetworkPolicy, error)
- func (data *TestData) CreateOrUpdateCG(cg *crdv1beta1.ClusterGroup) (*crdv1beta1.ClusterGroup, error)
- func (data *TestData) CreateOrUpdateDeployment(ns string, deploymentName string, replicas int32, labels map[string]string, ...) (*appsv1.Deployment, error)
- func (data *TestData) CreateOrUpdateNamespace(n string, labels map[string]string) (*v1.Namespace, error)
- func (data *TestData) CreateOrUpdateNetworkPolicy(netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)
- func (data *TestData) CreateOrUpdateService(svc *v1.Service) (*v1.Service, error)
- func (data *TestData) CreateOrUpdateServiceAccount(sa *v1.ServiceAccount) (*v1.ServiceAccount, error)
- func (data *TestData) CreateService(serviceName, namespace string, port, targetPort int32, ...) (*corev1.Service, error)
- func (data *TestData) CreateServiceWithAnnotations(serviceName, namespace string, port, targetPort int32, ...) (*corev1.Service, error)
- func (data *TestData) CreateTier(name string, tierPriority int32) (*crdv1beta1.Tier, error)
- func (data *TestData) DeleteACNP(name string) error
- func (data *TestData) DeleteANNP(ns, name string) error
- func (data *TestData) DeleteCG(name string) error
- func (data *TestData) DeleteNamespace(namespace string, timeout time.Duration) error
- func (data *TestData) DeleteNetworkPolicy(ns, name string) error
- func (data *TestData) DeletePod(namespace, name string) error
- func (data *TestData) DeletePodAndWait(timeout time.Duration, name string, ns string) error
- func (data *TestData) DeleteService(ns, name string) error
- func (data *TestData) DeleteServiceAccount(ns, name string) error
- func (data *TestData) DeleteTier(name string) error
- func (data *TestData) GetACNP(name string) (*crdv1beta1.ClusterNetworkPolicy, error)
- func (data *TestData) GetANNP(namespace, name string) (*crdv1beta1.NetworkPolicy, error)
- func (data *TestData) GetAntreaAgentConf() (*agentconfig.AgentConfig, error)
- func (data *TestData) GetAntreaConfigMap(antreaNamespace string) (*corev1.ConfigMap, error)
- func (data *TestData) GetAntreaWindowsConfigMap(antreaNamespace string) (*corev1.ConfigMap, error)
- func (data *TestData) GetConfigMap(namespace, name string) (*v1.ConfigMap, error)
- func (data *TestData) GetEncapMode() (config.TrafficEncapModeType, error)
- func (data *TestData) GetEncryptionnMode() (config.TrafficEncryptionModeType, error)
- func (data *TestData) GetFlowAggregatorConfigMap(o flowVisibilityTestOptions) (*corev1.ConfigMap, error)
- func (data *TestData) GetGatewayInterfaceName(antreaNamespace string) (string, error)
- func (data *TestData) GetMulticastInterfaces(antreaNamespace string) ([]string, error)
- func (data *TestData) GetNetworkPolicy(namespace, name string) (*v1net.NetworkPolicy, error)
- func (data *TestData) GetNodeMACAddress(node, device string) (string, error)
- func (data *TestData) GetPodInterfaceMTU(namespace string, podName string, containerName string) (int, error)
- func (data *TestData) GetPodLogs(ctx context.Context, namespace, name, container string) (string, error)
- func (data *TestData) GetService(namespace, name string) (*v1.Service, error)
- func (data *TestData) GetTestNamespace() string
- func (data *TestData) GetTier(name string) (*crdv1beta1.Tier, error)
- func (data *TestData) GetTransportInterfaceForNode(nodeIdx int) (string, *net.IPNet, *net.IPNet, error)
- func (data *TestData) GetTransportInterfaceName() (string, error)
- func (data *TestData) InitProvider(providerName, providerConfigPath string) error
- func (data *TestData) PatchPod(namespace, name string, patch []byte) error
- func (data *TestData) PodWaitFor(timeout time.Duration, name, namespace string, condition PodCondition) (*corev1.Pod, error)
- func (data *TestData) RestartAntreaAgentPods(timeout time.Duration) error
- func (data *TestData) RunCommandFromAntreaPodOnNode(nodeName string, cmd []string) (string, string, error)
- func (data *TestData) RunCommandFromPod(podNamespace string, podName string, containerName string, cmd []string) (stdout string, stderr string, err error)
- func (data *TestData) RunCommandOnNode(nodeName string, cmd string) (code int, stdout string, stderr string, err error)
- func (data *TestData) RunCommandOnNodeExt(nodeName, cmd string, envs map[string]string, stdin string, sudo bool) (code int, stdout, stderr string, err error)
- func (data *TestData) RunPingCommandFromTestPod(podInfo PodInfo, ns string, targetPodIPs *PodIPs, ctrName string, count int, ...) error
- func (data *TestData) RunProbeCommand(podNamespace, podName, containerName string, srcName string, dstName string, ...) PodConnectivityMark
- func (data *TestData) SetupLogDirectoryForTest(testName string) error
- func (data *TestData) UpdateConfigMap(configMap *v1.ConfigMap) error
- func (data *TestData) UpdateNamespace(namespace string, mutateFunc func(*corev1.Namespace)) error
- func (data *TestData) UpdatePod(namespace, name string, mutateFunc func(*corev1.Pod)) error
- func (data *TestData) UpdateTier(tier *crdv1beta1.Tier) (*crdv1beta1.Tier, error)
- func (data *TestData) WaitForACNPCreationAndRealization(t *testing.T, name string, timeout time.Duration) error
- func (data *TestData) WaitForANNPCreationAndRealization(t *testing.T, namespace string, name string, timeout time.Duration) error
- type TestNamespaceMeta
- type TestOptions
- type TestStep
- type TruthTable
Constants ¶
const (
ToolboxImage = "antrea/toolbox:1.5-1"
)
Variables ¶
var AntreaConfigMap *corev1.ConfigMap
var ErrPodNotFound = errors.New("pod not found")
Functions ¶
func GetAgentFeatures ¶
func GetAgentFeatures() (featuregate.FeatureGate, error)
func GetControllerFeatures ¶
func GetControllerFeatures() (featuregate.FeatureGate, error)
func IsDirEmpty ¶
IsDirEmpty checks whether a directory is empty or not.
func ProbeCommand ¶
ProbeCommand generates a command to probe the provider url. The executor parameter can be used to change where the prober will run. For example, it could be "ip netns exec NAME" to run the prober in another namespace.
func SkipIfIPv6Cluster ¶
func SkipIfNotAntreaIPAMTest ¶
func SkipIfNotIPv4Cluster ¶
func SkipIfNotIPv6Cluster ¶
func TeardownTest ¶
Types ¶
type ClusterInfo ¶
type ClusterInfo struct {
// contains filtered or unexported fields
}
type ClusterNode ¶
type ClusterNode struct {
// contains filtered or unexported fields
}
type Connectivity ¶
type Connectivity struct {
From Pod
To Pod
Connectivity PodConnectivityMark
}
type ConnectivityTable ¶
type ConnectivityTable struct {
Items []string
Values map[string]map[string]PodConnectivityMark
// contains filtered or unexported fields
}
func NewConnectivityTable ¶
func NewConnectivityTable(items []string, defaultValue *PodConnectivityMark) *ConnectivityTable
func (*ConnectivityTable) Compare ¶
func (ct *ConnectivityTable) Compare(other *ConnectivityTable) *TruthTable
func (*ConnectivityTable) Get ¶
func (ct *ConnectivityTable) Get(from string, to string) PodConnectivityMark
func (*ConnectivityTable) PrettyPrint ¶
func (ct *ConnectivityTable) PrettyPrint(indent string) string
func (*ConnectivityTable) Set ¶
func (ct *ConnectivityTable) Set(from string, to string, value PodConnectivityMark)
func (*ConnectivityTable) SetAllFrom ¶
func (ct *ConnectivityTable) SetAllFrom(from string, value PodConnectivityMark)
func (*ConnectivityTable) SetAllTo ¶
func (ct *ConnectivityTable) SetAllTo(to string, value PodConnectivityMark)
type CustomProbe ¶
type CustomProbe struct {
// Create or update a source Pod.
SourcePod CustomPod
// Create or update a destination Pod.
DestPod CustomPod
// Port on which the probe will be made.
Port int32
// Set the expected connectivity.
ExpectConnectivity PodConnectivityMark
}
CustomProbe will spin up (or update) SourcePod and DestPod such that Add event of Pods can be tested against expected connectivity among those Pods.
type ExternalInfo ¶
type ExternalInfo struct {
// contains filtered or unexported fields
}
type KubernetesUtils ¶
type KubernetesUtils struct {
*TestData
// contains filtered or unexported fields
}
func NewKubernetesUtils ¶
func NewKubernetesUtils(data *TestData) (*KubernetesUtils, error)
func (*KubernetesUtils) CleanGroups ¶
func (k *KubernetesUtils) CleanGroups(namespace string) error
CleanGroups is a convenience function for deleting all Groups in the namespace.
func (*KubernetesUtils) Cleanup ¶
func (k *KubernetesUtils) Cleanup(namespaces map[string]TestNamespaceMeta)
func (*KubernetesUtils) CreateOrUpdateGroup ¶
func (k *KubernetesUtils) CreateOrUpdateGroup(g *crdv1beta1.Group) (*crdv1beta1.Group, error)
CreateOrUpdateGroup is a convenience function for idempotent setup of crd/v1beta1 Groups
func (*KubernetesUtils) DeleteGroup ¶
func (k *KubernetesUtils) DeleteGroup(namespace, name string) error
DeleteGroup is a convenience function for deleting core/v1beta1 Group by namespace and name.
func (*KubernetesUtils) GetCG ¶
func (k *KubernetesUtils) GetCG(name string) (*crdv1beta1.ClusterGroup, error)
GetCG is a convenience function for getting ClusterGroups
func (*KubernetesUtils) GetClusterSearchDomain ¶
func (k *KubernetesUtils) GetClusterSearchDomain() (string, error)
func (*KubernetesUtils) GetGroup ¶
func (k *KubernetesUtils) GetGroup(namespace, name string) (*crdv1beta1.Group, error)
GetGroup is a convenience function for getting Groups
func (*KubernetesUtils) GetPodByLabel ¶
GetPodByLabel returns a Pod with the matching Namespace and "pod" label if it's found. If the pod is not found, GetPodByLabel returns "ErrPodNotFound".
func (*KubernetesUtils) GetPodsByLabel ¶
GetPodsByLabel returns an array of all Pods in the given Namespace having a k/v label pair.
func (*KubernetesUtils) LabelPod ¶
func (k *KubernetesUtils) LabelPod(ns, name, key, value string) (*v1.Pod, error)
func (*KubernetesUtils) Probe ¶
func (k *KubernetesUtils) Probe(ns1, pod1, ns2, pod2 string, port int32, protocol utils.AntreaPolicyProtocol, remoteCluster *KubernetesUtils, expectedResult *PodConnectivityMark) (PodConnectivityMark, error)
Probe execs into a Pod and checks its connectivity to another Pod. It assumes that the target Pod is serving on the input port, and also that agnhost is installed. The connectivity from source Pod to all IPs of the target Pod should be consistent. Otherwise, Error PodConnectivityMark will be returned.
func (*KubernetesUtils) ProbeAddr ¶
func (k *KubernetesUtils) ProbeAddr(ns, podLabelKey, podLabelValue, dstAddr string, port int32, protocol utils.AntreaPolicyProtocol, expectedResult *PodConnectivityMark) (PodConnectivityMark, error)
ProbeAddr execs into a Pod and checks its connectivity to an arbitrary destination address.
func (*KubernetesUtils) Validate ¶
func (k *KubernetesUtils) Validate(allPods []Pod, reachability *Reachability, ports []int32, protocol utils.AntreaPolicyProtocol)
Validate checks the connectivity between all Pods in both directions with a list of ports and a protocol. The connectivity from a Pod to another Pod should be consistent across all provided ports. Otherwise, this connectivity will be treated as Error.
func (*KubernetesUtils) ValidateRemoteCluster ¶
func (k *KubernetesUtils) ValidateRemoteCluster(remoteCluster *KubernetesUtils, allPods []Pod, reachability *Reachability, port int32, protocol utils.AntreaPolicyProtocol)
type NPEvalActionType ¶
type NPEvalActionType string
const ( NPEvalNone NPEvalActionType = "<NONE>" NPEvalAllow NPEvalActionType = "Allow" NPEvalDrop NPEvalActionType = "Drop" NPEvalIsolate NPEvalActionType = "Isolate" NPEvalReject NPEvalActionType = "Reject" )
type NPEvaluation ¶
type NPEvaluation struct {
Assertions []*NPEvaluationSpec
// contains filtered or unexported fields
}
func NewNPEvaluation ¶
func NewNPEvaluation(pods []Pod) *NPEvaluation
func (*NPEvaluation) Expect ¶
func (e *NPEvaluation) Expect(from, to Pod, npName string, action NPEvalActionType) *NPEvaluation
func (*NPEvaluation) ExpectNone ¶
func (e *NPEvaluation) ExpectNone(from Pod, to Pod) *NPEvaluation
type NPEvaluationSpec ¶
type NPEvaluationSpec struct {
Source Pod
Destination Pod
NPName string
Action NPEvalActionType
}
type PodBuilder ¶
type PodBuilder struct {
Name string
Namespace string
VolumeMounts []corev1.VolumeMount
Volumes []corev1.Volume
Image string
ContainerName string
Command []string
Args []string
Env []corev1.EnvVar
Ports []corev1.ContainerPort
HostNetwork bool
IsPrivileged bool
ServiceAccountName string
Annotations map[string]string
Labels map[string]string
NodeName string
MutateFunc func(*corev1.Pod)
ResourceRequests corev1.ResourceList
ResourceLimits corev1.ResourceList
ReadinessProbe *corev1.Probe
DnsConfig *corev1.PodDNSConfig
}
func NewPodBuilder ¶
func NewPodBuilder(name, ns, image string) *PodBuilder
func (*PodBuilder) AddVolume ¶
func (b *PodBuilder) AddVolume(volume corev1.Volume) *PodBuilder
func (*PodBuilder) AddVolumeMount ¶
func (b *PodBuilder) AddVolumeMount(volumeMount corev1.VolumeMount) *PodBuilder
func (*PodBuilder) Create ¶
func (b *PodBuilder) Create(data *TestData) error
func (*PodBuilder) InHostNetwork ¶
func (b *PodBuilder) InHostNetwork() *PodBuilder
func (*PodBuilder) MountConfigMap ¶
func (b *PodBuilder) MountConfigMap(configMapName string, mountPath string, volumeName string) *PodBuilder
func (*PodBuilder) MountHostPath ¶
func (b *PodBuilder) MountHostPath(hostPath string, hostPathType corev1.HostPathType, mountPath string, volumeName string) *PodBuilder
func (*PodBuilder) MountSecret ¶
func (b *PodBuilder) MountSecret(secretName string, mountPath string, volumeName string) *PodBuilder
func (*PodBuilder) OnNode ¶
func (b *PodBuilder) OnNode(nodeName string) *PodBuilder
func (*PodBuilder) Privileged ¶
func (b *PodBuilder) Privileged() *PodBuilder
func (*PodBuilder) WithAnnotations ¶
func (b *PodBuilder) WithAnnotations(annotations map[string]string) *PodBuilder
func (*PodBuilder) WithArgs ¶
func (b *PodBuilder) WithArgs(args []string) *PodBuilder
func (*PodBuilder) WithCommand ¶
func (b *PodBuilder) WithCommand(command []string) *PodBuilder
func (*PodBuilder) WithContainerName ¶
func (b *PodBuilder) WithContainerName(ctrName string) *PodBuilder
func (*PodBuilder) WithCustomDNSConfig ¶
func (b *PodBuilder) WithCustomDNSConfig(dnsConfig *corev1.PodDNSConfig) *PodBuilder
WithCustomDNSConfig adds a custom DNS Configuration to the Pod spec. It ensures that the DNSPolicy is set to 'None' and assigns the provided DNSConfig.
func (*PodBuilder) WithEnv ¶
func (b *PodBuilder) WithEnv(env []corev1.EnvVar) *PodBuilder
func (*PodBuilder) WithHostNetwork ¶
func (b *PodBuilder) WithHostNetwork(v bool) *PodBuilder
func (*PodBuilder) WithLabels ¶
func (b *PodBuilder) WithLabels(labels map[string]string) *PodBuilder
func (*PodBuilder) WithMutateFunc ¶
func (b *PodBuilder) WithMutateFunc(f func(*corev1.Pod)) *PodBuilder
func (*PodBuilder) WithPorts ¶
func (b *PodBuilder) WithPorts(ports []corev1.ContainerPort) *PodBuilder
func (*PodBuilder) WithReadinessProbe ¶
func (b *PodBuilder) WithReadinessProbe(probe *corev1.Probe) *PodBuilder
func (*PodBuilder) WithResources ¶
func (b *PodBuilder) WithResources(ResourceRequests, ResourceLimits corev1.ResourceList) *PodBuilder
func (*PodBuilder) WithServiceAccountName ¶
func (b *PodBuilder) WithServiceAccountName(name string) *PodBuilder
type PodConnectivityMark ¶
type PodConnectivityMark string
const ( Connected PodConnectivityMark = "Con" Unknown PodConnectivityMark = "Unk" Error PodConnectivityMark = "Err" Dropped PodConnectivityMark = "Drp" Rejected PodConnectivityMark = "Rej" )
type PodInfo ¶
PodInfo combines OS info with a Pod name. It is useful when choosing commands and options on Pods of different OS (Windows, Linux).
type Reachability ¶
type Reachability struct {
Expected *ConnectivityTable
Observed *ConnectivityTable
Pods []Pod
PodsByNamespace map[string][]Pod
}
func NewReachability ¶
func NewReachability(pods []Pod, defaultExpectation PodConnectivityMark) *Reachability
func (*Reachability) Expect ¶
func (r *Reachability) Expect(pod1 Pod, pod2 Pod, connectivity PodConnectivityMark)
func (*Reachability) ExpectAllEgress ¶
func (r *Reachability) ExpectAllEgress(pod Pod, connectivity PodConnectivityMark)
ExpectAllEgress defines that any traffic going out of the pod will be allowed/dropped/rejected
func (*Reachability) ExpectAllIngress ¶
func (r *Reachability) ExpectAllIngress(pod Pod, connectivity PodConnectivityMark)
ExpectAllIngress defines that any traffic going into the pod will be allowed/dropped/rejected
func (*Reachability) ExpectAllSelfNamespace ¶
func (r *Reachability) ExpectAllSelfNamespace(connectivity PodConnectivityMark)
func (*Reachability) ExpectConn ¶
func (r *Reachability) ExpectConn(spec *Connectivity)
ExpectConn is an experimental way to describe connectivity with named fields
func (*Reachability) ExpectEgressToNamespace ¶
func (r *Reachability) ExpectEgressToNamespace(pod Pod, namespace string, connectivity PodConnectivityMark)
func (*Reachability) ExpectIngressFromNamespace ¶
func (r *Reachability) ExpectIngressFromNamespace(pod Pod, namespace string, connectivity PodConnectivityMark)
func (*Reachability) ExpectNamespaceEgressToNamespace ¶
func (r *Reachability) ExpectNamespaceEgressToNamespace(srcNamespace, dstNamespace string, connectivity PodConnectivityMark)
func (*Reachability) ExpectNamespaceIngressFromNamespace ¶
func (r *Reachability) ExpectNamespaceIngressFromNamespace(dstNamespace, srcNamespace string, connectivity PodConnectivityMark)
func (*Reachability) ExpectSelf ¶
func (r *Reachability) ExpectSelf(allPods []Pod, connectivity PodConnectivityMark)
func (*Reachability) ExpectSelfNamespace ¶
func (r *Reachability) ExpectSelfNamespace(namespace string, connectivity PodConnectivityMark)
func (*Reachability) NewReachabilityWithSameExpectations ¶
func (r *Reachability) NewReachabilityWithSameExpectations() *Reachability
func (*Reachability) Observe ¶
func (r *Reachability) Observe(pod1 Pod, pod2 Pod, connectivity PodConnectivityMark)
func (*Reachability) PrintSummary ¶
func (r *Reachability) PrintSummary(printExpected bool, printObserved bool, printComparison bool)
func (*Reachability) Summary ¶
func (r *Reachability) Summary() (trueObs int, falseObs int, comparison *TruthTable)
type TestData ¶
type TestData struct {
ClusterName string
KubeConfig *restclient.Config
CRDClient crdclientset.Interface
// contains filtered or unexported fields
}
TestData stores the state required for each test case.
func (*TestData) BuildService ¶
func (data *TestData) BuildService(svcName, svcNS string, port, targetPort int, selector map[string]string, serviceType *v1.ServiceType) *v1.Service
BuildService is a convenience function for building a corev1.Service spec.
func (*TestData) BuildServiceAccount ¶
func (data *TestData) BuildServiceAccount(name, ns string, labels map[string]string) *v1.ServiceAccount
BuildServiceAccount is a convenience function for building a corev1.SerivceAccount spec.
func (*TestData) CleanACNPs ¶
CleanACNPs is a convenience function for deleting all Antrea ClusterNetworkPolicies in the cluster.
func (*TestData) CleanANNPs ¶
CleanANNPs is a convenience function for deleting all Antrea NetworkPolicies in provided namespaces.
func (*TestData) CleanCGs ¶
CleanCGs is a convenience function for deleting all ClusterGroups in the cluster.
func (*TestData) CleanNetworkPolicies ¶
func (data *TestData) CleanNetworkPolicies(namespaces map[string]TestNamespaceMeta) error
CleanNetworkPolicies is a convenience function for deleting NetworkPolicies in the provided namespaces.
func (*TestData) CleanServices ¶
CleanServices is a convenience function for deleting Services in the cluster.
func (*TestData) CreateClient ¶
CreateClient initializes the K8s clientset in the TestData structure.
func (*TestData) CreateConfigMap ¶
func (*TestData) CreateNamespace ¶
CreateNamespace creates the provided namespace.
func (*TestData) CreateOrUpdateACNP ¶
func (data *TestData) CreateOrUpdateACNP(cnp *crdv1beta1.ClusterNetworkPolicy) (*crdv1beta1.ClusterNetworkPolicy, error)
CreateOrUpdateACNP is a convenience function for updating/creating AntreaClusterNetworkPolicies.
func (*TestData) CreateOrUpdateANNP ¶
func (data *TestData) CreateOrUpdateANNP(annp *crdv1beta1.NetworkPolicy) (*crdv1beta1.NetworkPolicy, error)
CreateOrUpdateANNP is a convenience function for updating/creating Antrea NetworkPolicies.
func (*TestData) CreateOrUpdateCG ¶
func (data *TestData) CreateOrUpdateCG(cg *crdv1beta1.ClusterGroup) (*crdv1beta1.ClusterGroup, error)
CreateOrUpdateCG is a convenience function for idempotent setup of crd/v1beta1 ClusterGroups
func (*TestData) CreateOrUpdateDeployment ¶
func (data *TestData) CreateOrUpdateDeployment(ns string, deploymentName string, replicas int32, labels map[string]string, nodeName string, hostNetwork bool) (*appsv1.Deployment, error)
CreateOrUpdateDeployment is a convenience function for idempotent setup of deployments
func (*TestData) CreateOrUpdateNamespace ¶
func (data *TestData) CreateOrUpdateNamespace(n string, labels map[string]string) (*v1.Namespace, error)
CreateOrUpdateNamespace is a convenience function for idempotent setup of Namespaces
func (*TestData) CreateOrUpdateNetworkPolicy ¶
func (data *TestData) CreateOrUpdateNetworkPolicy(netpol *v1net.NetworkPolicy) (*v1net.NetworkPolicy, error)
CreateOrUpdateNetworkPolicy is a convenience function for updating/creating netpols. Updating is important since some tests update a network policy to confirm that mutation works with a CNI.
func (*TestData) CreateOrUpdateService ¶
CreateOrUpdateService is a convenience function for updating/creating Services.
func (*TestData) CreateOrUpdateServiceAccount ¶
func (data *TestData) CreateOrUpdateServiceAccount(sa *v1.ServiceAccount) (*v1.ServiceAccount, error)
CreateOrUpdateServiceAccount is a convenience function for updating/creating ServiceAccount.
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, mutators ...func(service *corev1.Service)) (*corev1.Service, error)
CreateServiceWithAnnotations creates a service with Annotation
func (*TestData) CreateTier ¶
CreateTier is a convenience function for creating an Antrea Policy Tier by name and priority.
func (*TestData) DeleteACNP ¶
DeleteACNP is a convenience function for deleting ACNP by name.
func (*TestData) DeleteANNP ¶
DeleteANNP is a convenience function for deleting ANNP by name and Namespace.
func (*TestData) DeleteCG ¶
DeleteCG is a convenience function for deleting core/v1beta1 ClusterGroup by name.
func (*TestData) DeleteNamespace ¶
DeleteNamespace deletes the provided Namespace, and waits for deletion to actually complete if timeout>=0
func (*TestData) DeleteNetworkPolicy ¶
DeleteNetworkPolicy is a convenience function for deleting NetworkPolicy by name and Namespace.
func (*TestData) DeletePodAndWait ¶
Deletes a Pod in the test namespace then waits us to timeout for the Pod not to be visible to the client anymore.
func (*TestData) DeleteService ¶
DeleteService is a convenience function for deleting a Service by Namespace and name.
func (*TestData) DeleteServiceAccount ¶
DeleteServiceAccount is a convenience function for deleting a ServiceAccount by Namespace and name.
func (*TestData) DeleteTier ¶
DeleteTier is a convenience function for deleting an Antrea Policy Tier with specific name. To avoid flakes caused by antrea-controller not in sync with kube-apiserver, it retries a few times if the failure is because the Tier is still referenced.
func (*TestData) GetACNP ¶
func (data *TestData) GetACNP(name string) (*crdv1beta1.ClusterNetworkPolicy, error)
GetACNP is a convenience function for getting AntreaClusterNetworkPolicies.
func (*TestData) GetANNP ¶
func (data *TestData) GetANNP(namespace, name string) (*crdv1beta1.NetworkPolicy, error)
GetANNP is a convenience function for getting AntreaNetworkPolicies.
func (*TestData) GetAntreaAgentConf ¶
func (data *TestData) GetAntreaAgentConf() (*agentconfig.AgentConfig, error)
func (*TestData) GetAntreaConfigMap ¶
func (*TestData) GetAntreaWindowsConfigMap ¶
func (*TestData) GetConfigMap ¶
func (*TestData) GetEncapMode ¶
func (data *TestData) GetEncapMode() (config.TrafficEncapModeType, error)
func (*TestData) GetEncryptionnMode ¶
func (data *TestData) GetEncryptionnMode() (config.TrafficEncryptionModeType, error)
func (*TestData) GetFlowAggregatorConfigMap ¶
func (*TestData) GetGatewayInterfaceName ¶
func (*TestData) GetMulticastInterfaces ¶
func (*TestData) GetNetworkPolicy ¶
func (data *TestData) GetNetworkPolicy(namespace, name string) (*v1net.NetworkPolicy, error)
GetNetworkPolicy is a convenience function for getting k8s NetworkPolicies.
func (*TestData) GetNodeMACAddress ¶
func (*TestData) GetPodInterfaceMTU ¶
func (*TestData) GetPodLogs ¶
func (data *TestData) GetPodLogs(ctx context.Context, namespace, name, container string) (string, error)
GetPodLogs returns the current logs for the specified Pod container. If container is empty, it defaults to only container when there is one container in the Pod.
func (*TestData) GetService ¶
GetService is a convenience function for getting Service
func (*TestData) GetTestNamespace ¶
func (*TestData) GetTier ¶
func (data *TestData) GetTier(name string) (*crdv1beta1.Tier, error)
GetTier is a convenience function for getting Tier.
func (*TestData) GetTransportInterfaceForNode ¶
func (*TestData) GetTransportInterfaceName ¶
GetTransportInterfaceName returns the transport interface name for cluster Nodes, assuming all Nodes have the same one.
func (*TestData) InitProvider ¶
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) RestartAntreaAgentPods ¶
RestartAntreaAgentPods deletes all the antrea-agent Pods to force them to be re-scheduled. It then waits for the new Pods to become available.
func (*TestData) RunCommandFromAntreaPodOnNode ¶
func (*TestData) RunCommandFromPod ¶
func (data *TestData) RunCommandFromPod(podNamespace string, podName string, containerName string, cmd []string) (stdout string, stderr string, err error)
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) RunCommandOnNodeExt ¶
func (*TestData) RunPingCommandFromTestPod ¶
func (data *TestData) RunPingCommandFromTestPod(podInfo PodInfo, ns string, targetPodIPs *PodIPs, ctrName string, count int, size int, dontFragment bool) error
RunPingCommandFromTestPod uses ping to check connectivity between the Pod and the given target Pod IPs. If dontFragment is true and size is 0, it will set the size to the maximum value allowed by the Pod's MTU.
func (*TestData) RunProbeCommand ¶
func (data *TestData) RunProbeCommand( podNamespace, podName, containerName string, srcName string, dstName string, cmd []string, expectedResult *PodConnectivityMark, ) PodConnectivityMark
func (*TestData) SetupLogDirectoryForTest ¶
func (*TestData) UpdateConfigMap ¶
func (*TestData) UpdateNamespace ¶
func (*TestData) UpdateTier ¶
func (data *TestData) UpdateTier(tier *crdv1beta1.Tier) (*crdv1beta1.Tier, error)
UpdateTier is a convenience function for updating an Antrea Policy Tier.
func (*TestData) WaitForACNPCreationAndRealization ¶
type TestNamespaceMeta ¶
TestNamespaceMeta holds the relevant metadata of a test Namespace during initialization.
type TestOptions ¶
type TestOptions struct {
// contains filtered or unexported fields
}
type TestStep ¶
type TestStep struct {
Name string
Reachability *Reachability
NPEvaluation *NPEvaluation
TestResources []metav1.Object
Ports []int32
Protocol utils.AntreaPolicyProtocol
Duration time.Duration
CustomProbes []*CustomProbe
CustomSetup func()
CustomTeardown func()
}
TestStep is a single unit of testing spec. It includes the policy specs that need to be applied for this test, the port to test traffic on and the expected Reachability matrix.
type TruthTable ¶
type TruthTable struct {
Items []string
Values map[string]map[string]bool
// contains filtered or unexported fields
}
func (*TruthTable) IsComplete ¶
func (tt *TruthTable) IsComplete() bool
IsComplete returns true if there's a value set for every single pair of items, otherwise it returns false.
func (*TruthTable) PrettyPrint ¶
func (tt *TruthTable) PrettyPrint(indent string) string