common_tests

package
v3.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0, Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PodMockContainerName is used container name for pod container mock
	PodMockContainerName = "cni-tests-pod-mock"
	// PodMockImage is docker image used for pod mocking
	PodMockImage              = "calicovpp/vpp-test-pod-mock:latest"
	VPPContainerName          = "cni-tests-vpp"
	VppContainerExtraArgsName = "VPP_CONTAINER_EXTRA_ARGS"
	ThisNodeName              = "node1"
	UplinkIfName              = "uplink"
	UplinkIP                  = "10.0.100.1"
	UplinkIPv6                = "A::1:1"
	GatewayIP                 = "10.0.100.254"
	GatewayIPv6               = "A::1:254"
	ThisNodeIP                = UplinkIP
	ThisNodeIPv6              = UplinkIPv6

	AddedNodeName = "node2"
	AddedNodeIP   = "10.0.200.1"
	AddedNodeIPv6 = "A::2:1"
)

Variables

View Source
var (
	// VppImage is the name of docker image containing VPP binary
	VppImage string
	// VppBinary is the full path to VPP binary inside docker image
	VppBinary string
	// vppContainerExtraArgs is a list of additionnal cli parameters for the VPP `docker run ...`
	VppContainerExtraArgs []string = []string{}
)

Functions

func AddIPPoolForCalicoClient

func AddIPPoolForCalicoClient(client *calico.CalicoClientStub, poolName string, poolCIRD string) (
	*apiv3.IPPool, error)

AddIPPoolForCalicoClient is convenience function for adding IPPool to mocked Calico IPAM Stub used in Calico client stub. This function doesn't set anything for the watchers.IpamCache implementation.

func AddPaddingTo32Bytes

func AddPaddingTo32Bytes(value []byte) []byte

func AssertInterfaceGSO

func AssertInterfaceGSO(swIfIndex uint32, interfaceDescriptiveName string, vpp *vpplink.VppLink)

assertInterfaceGSOCNat check whether the given interface has properly set the GSO and CNAT attributes

func AssertInterfaceGSOCNat

func AssertInterfaceGSOCNat(swIfIndex uint32, interfaceDescriptiveName string, vpp *vpplink.VppLink)

AssertInterfaceGSOCNat check whether the given interface has properly set the GSO and CNAT attributes

func AssertNextNodeLink(node, linkedNextNode string, vpp *vpplink.VppLink) int

AssertNextNodeLink asserts that in VPP graph the given node has linked the linkedNextNode as one of its "next" nodes for processing. It returns to node specific index of the checked next node.

func AssertRPFRoutes

func AssertRPFRoutes(vpp *vpplink.VppLink, vrfID uint32, swifindex uint32, ipAddress string)

AssertRPFRoutes checks that a route to the pod is added in the RPFVRF and to addresses allowed to be spoofed

func AssertRPFVRFExistence

func AssertRPFVRFExistence(vpp *vpplink.VppLink, interfaceName string, netnsName string) uint32

AssertRPFVRFExistence checks that dedicated VRF for RPF is created for interface in VPP

func AssertTunInterfaceExistence

func AssertTunInterfaceExistence(vpp *vpplink.VppLink, newPod *cniproto.AddRequest) uint32

func AssertTunnelInterfaceIPAddress

func AssertTunnelInterfaceIPAddress(vpp *vpplink.VppLink, ifSwIfIndex uint32, expectedIPAddress string)

func AssertTunnelInterfaceMTU

func AssertTunnelInterfaceMTU(vpp *vpplink.VppLink, ifSwIfIndex uint32)

func AssertUnnumberedInterface

func AssertUnnumberedInterface(swIfIndex uint32, interfaceDescriptiveName string, vpp *vpplink.VppLink)

AssertUnnumberedInterface checks whether the provided interface is unnumbered and properly takes IP address from the correct interface (common.VppManagerInfo.GetMainSwIfIndex()).

func ConfigureBGPNodeIPAddresses

func ConfigureBGPNodeIPAddresses(connectivityServer *connectivity.ConnectivityServer)

func ConfigureVPP

func ConfigureVPP(log *logrus.Logger) (vpp *vpplink.VppLink, uplinkSwIfIndex uint32)

ConfigureVPP connects to VPP and configures it with common configuration needed for tests

func CreatePod

func CreatePod()

CreatePod creates docker container that will be used as pod for CNI testing

func DpoNetworkNameFieldName

func DpoNetworkNameFieldName() string

DpoNetworkNameFieldName extracts JSON field name for NetworkName used in proto.AddRequest.DataplaneOptions

func FirstIPinIPRange

func FirstIPinIPRange(ipRangeCIDR string) net.IP

FirstIPinIPRange computes first usable IPv4 address from the given subnet. The subnet definition IP address (ending with zero bits) is not considered as usable IPv4 address as it can have special meaning in certain situations.

func InterfaceTagForLocalMemifTunnel

func InterfaceTagForLocalMemifTunnel(interfaceName, netns string) string

InterfaceTagForLocalMemifTunnel constructs the tag for the VPP side of the memif tunnel the same way as cni server

func InterfaceTagForLocalTunTunnel

func InterfaceTagForLocalTunTunnel(interfaceName, netns string) string

InterfaceTagForLocalTunTunnel constructs the tag for the VPP side of the tap tunnel the same way as cni server

func InterfaceTagForLocalTunnel

func InterfaceTagForLocalTunnel(prefix, interfaceName, netns string) string

InterfaceTagForLocalTunnel constructs the tag for the VPP side of the local tunnel the same way as cni server

func IpFamilyIndex

func IpFamilyIndex(ipFamily vpplink.IpFamily) int

func IpNet

func IpNet(ipNetCIDRStr string) *net.IPNet

func IpNetWithIPInIPv6Format

func IpNetWithIPInIPv6Format(ipNetCIDRStr string) *net.IPNet

func IptypesIP6Address

func IptypesIP6Address(address string) ip_types.IP6Address

func Mac

func Mac(macStr string) net.HardwareAddr

func PodVRFs

func PodVRFs(podInterface, podNetNSName string, vpp *vpplink.VppLink) (vrf4ID, vrf6ID uint32, err error)

PodVRFs gets ids of IPv4 and IPv6 pod-specific VRFs from VPP

func RunInPod

func RunInPod(podNetNS string, runner func())

RunInPod runs runner function in provided pod network namespace. This is the same as running networking commands inside pod.

func SidArray

func SidArray(addresses ...ip_types.IP6Address) (sids [16]ip_types.IP6Address)

func StartVPP

func StartVPP()

StartVPP creates docker container and runs inside the VPP

func TeardownPod

func TeardownPod()

TeardownPod removes container that is used as Pod mock

func TeardownVPP

func TeardownVPP()

TeardownVPP removes container with running VPP to stop VPP and clean after it

Types

This section is empty.

Jump to

Keyboard shortcuts

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