Documentation ¶
Overview ¶
Package testutil contains some methods useful to mock components while testing
Index ¶
- Constants
- Variables
- func BeNotFound() types.GomegaMatcher
- func FailBecauseNotFound() types.GomegaMatcher
- func FakeClusterIDConfigMap(namespace, clusterID string) *corev1.ConfigMap
- func FakeConfiguration(remoteClusterID, podCIDR, extCIDR, remotePodCIDR, remoteExtCIDR, ... string) *networkingv1beta1.Configuration
- func FakeConnection(remoteClusterID string) *networkingv1beta1.Connection
- func FakeControllerManagerDeployment(argsClusterLabels []string, networkEnabled bool) *appv1.Deployment
- func FakeEventRecorder(bufferSize int) *record.FakeRecorder
- func FakeForeignCluster(clusterID liqov1beta1.ClusterID, modules *liqov1beta1.Modules) *liqov1beta1.ForeignCluster
- func FakeForgingOpts() *forge.ForgingOpts
- func FakeGatewayClient(remoteClusterID string) *networkingv1beta1.GatewayClient
- func FakeGatewayServer(remoteClusterID string) *networkingv1beta1.GatewayServer
- func FakeIPAM(namespace string) *ipamv1alpha1.IpamStorage
- func FakeIdentity(clusterID liqov1beta1.ClusterID, identityType authv1beta1.IdentityType) *authv1beta1.Identity
- func FakeLiqoNamespace(name string) *corev1.Namespace
- func FakeNetworkExternalCIDR() *ipamv1alpha1.Network
- func FakeNetworkInternalCIDR() *ipamv1alpha1.Network
- func FakeNetworkPodCIDR() *ipamv1alpha1.Network
- func FakeNetworkReservedSubnet(i int) *ipamv1alpha1.Network
- func FakeNetworkServiceCIDR() *ipamv1alpha1.Network
- func FakeNode() *corev1.Node
- func FakeNodeWithNameAndLabels(name string, labels map[string]string) *corev1.Node
- func FakePodWithSingleContainer(namespace, name, image string) *corev1.Pod
- func FakeResourceSlice(name string, consumerClusterID, providerClusterID liqov1beta1.ClusterID, ...) *authv1beta1.ResourceSlice
- func FakeSecret(namespace, name string, data map[string]string) *corev1.Secret
- func FakeSelfSignedCertificate(commonName string) (certificate []byte, err error)
- func FakeServiceClusterIP(namespace, name, clusterIP string, protocol corev1.Protocol, port int32) *corev1.Service
- func FakeServiceLoadBalancer(namespace, name, externalIP string, labels map[string]string, ...) *corev1.Service
- func FakeServiceNodePort(namespace, name string, labels map[string]string, ...) *corev1.Service
- func FakeVirtualNode(name string, clusterID liqov1beta1.ClusterID, ...) *offloadingv1beta1.VirtualNode
- func LogsToGinkgoWriter()
- func SqueezeWhitespaces(s string) string
- type Cluster
- type DnsServer
- type IsNotFoundErrorMatcher
- type MatchObject
Constants ¶
const ( // EndpointIP simulate a node or a load balancer IP. EndpointIP = "1.0.0.1" // PodCIDR is the CIDR of the pod network used for testing. PodCIDR = "fake pod CIDR" // ServiceCIDR is the CIDR of the service network used for testing. ServiceCIDR = "fake service CIDR" // ExternalCIDR is the external CIDR used for testing. ExternalCIDR = "fake external CIDR" // InternalCIDR is the internal CIDR used for testing. InternalCIDR = "fake internal CIDR" // OverrideAPIAddress is the overrided address of the API server used for testing. OverrideAPIAddress = "1.0.0.2:6443" // ForeignAuthURL is the URL of the foreign cluster used for testing. ForeignAuthURL = "https://fake-auth-url:32407" // ForeignAPIServerURL is the URL of the foreign cluster used for testing. ForeignAPIServerURL = "https://fake-apiserver-url:6443" // ForeignProxyURL is the URL of the foreign cluster used for testing. ForeignProxyURL = "https://fake-proxy-url:32408" // VPNGatewayPort is the port of the liqo-gateway service used for testing. VPNGatewayPort = 32406 // AuthenticationPort is the port of the liqo-auth service used for testing. AuthenticationPort = 32407 // FakeNotReflectedLabelKey is the key of the fake not reflected label used for testing. FakeNotReflectedLabelKey = "not-reflected-label" // FakeNotReflectedAnnotKey is the key of the fake not reflected annotation used for testing. FakeNotReflectedAnnotKey = "not-reflected-annot" // FakeLiqoVersion is the version of Liqo used for testing. FakeLiqoVersion = "fake-version" )
Variables ¶
var ( // ReservedSubnets is the list of reserved subnets used for testing. ReservedSubnets = []string{ "reserved subnet 1", "reserved subnet 2", "reserved subnet 3", "reserved subnet 4", } // ClusterLabels is the map of labels used for testing. ClusterLabels = map[string]string{ "liqo.io/testLabel": "fake label", } )
Functions ¶
func BeNotFound ¶ added in v0.3.1
func BeNotFound() types.GomegaMatcher
BeNotFound returns a new IsNotFoundErrorMatcher to catch k8s not-found errors.
func FailBecauseNotFound ¶ added in v0.3.1
func FailBecauseNotFound() types.GomegaMatcher
FailBecauseNotFound returns a new IsNotFoundErrorMatcher to catch k8s not-found errors.
func FakeClusterIDConfigMap ¶ added in v0.5.0
FakeClusterIDConfigMap returns a fake ClusterID ConfigMap.
func FakeConfiguration ¶
func FakeConfiguration(remoteClusterID, podCIDR, extCIDR, remotePodCIDR, remoteExtCIDR, remoteRemappedPodCIDR, remoteRemappedExtCIDR string) *networkingv1beta1.Configuration
FakeConfiguration returns a fake Configuration.
func FakeConnection ¶
func FakeConnection(remoteClusterID string) *networkingv1beta1.Connection
FakeConnection returns a fake Connection.
func FakeControllerManagerDeployment ¶ added in v0.7.1
func FakeControllerManagerDeployment(argsClusterLabels []string, networkEnabled bool) *appv1.Deployment
FakeControllerManagerDeployment returns a fake liqo-controller-manager deployment.
func FakeEventRecorder ¶
func FakeEventRecorder(bufferSize int) *record.FakeRecorder
FakeEventRecorder returns an event recorder that can be used to capture events.
func FakeForeignCluster ¶ added in v0.8.0
func FakeForeignCluster( clusterID liqov1beta1.ClusterID, modules *liqov1beta1.Modules) *liqov1beta1.ForeignCluster
FakeForeignCluster returns a fake ForeignCluster.
func FakeForgingOpts ¶ added in v0.9.0
func FakeForgingOpts() *forge.ForgingOpts
FakeForgingOpts returns a fake ForgingOpts.
func FakeGatewayClient ¶
func FakeGatewayClient(remoteClusterID string) *networkingv1beta1.GatewayClient
FakeGatewayClient returns a fake GatewayClient.
func FakeGatewayServer ¶
func FakeGatewayServer(remoteClusterID string) *networkingv1beta1.GatewayServer
FakeGatewayServer returns a fake GatewayServer.
func FakeIPAM ¶ added in v0.5.0
func FakeIPAM(namespace string) *ipamv1alpha1.IpamStorage
FakeIPAM returns an IPAM with the specified namespace and name.
func FakeIdentity ¶
func FakeIdentity(clusterID liqov1beta1.ClusterID, identityType authv1beta1.IdentityType) *authv1beta1.Identity
FakeIdentity returns a fake Identity.
func FakeLiqoNamespace ¶
FakeLiqoNamespace returns a fake Liqo namespace.
func FakeNetworkExternalCIDR ¶
func FakeNetworkExternalCIDR() *ipamv1alpha1.Network
FakeNetworkExternalCIDR returns a fake Network of type ExternalCIDR.
func FakeNetworkInternalCIDR ¶
func FakeNetworkInternalCIDR() *ipamv1alpha1.Network
FakeNetworkInternalCIDR returns a fake Network of type InternalCIDR.
func FakeNetworkPodCIDR ¶
func FakeNetworkPodCIDR() *ipamv1alpha1.Network
FakeNetworkPodCIDR returns a fake Network of type PodCIDR.
func FakeNetworkReservedSubnet ¶
func FakeNetworkReservedSubnet(i int) *ipamv1alpha1.Network
FakeNetworkReservedSubnet returns a fake Network of type Reserved Subnet.
func FakeNetworkServiceCIDR ¶
func FakeNetworkServiceCIDR() *ipamv1alpha1.Network
FakeNetworkServiceCIDR returns a fake Network of type ServiceCIDR.
func FakeNodeWithNameAndLabels ¶ added in v0.9.0
FakeNodeWithNameAndLabels returns a node with the specified name and labels.
func FakePodWithSingleContainer ¶
FakePodWithSingleContainer returns a pod with the specified namespace and name, and having a single container with the specified image.
func FakeResourceSlice ¶
func FakeResourceSlice(name string, consumerClusterID, providerClusterID liqov1beta1.ClusterID, status authv1beta1.ResourceSliceConditionStatus, resoucesList corev1.ResourceList) *authv1beta1.ResourceSlice
FakeResourceSlice returns a fake ResourceSlice.
func FakeSecret ¶
FakeSecret returns a secret with the specified namespace, name and data.
func FakeSelfSignedCertificate ¶
FakeSelfSignedCertificate returns the content of a self-signed certificate for testing purposes.
func FakeServiceClusterIP ¶ added in v0.7.1
func FakeServiceClusterIP(namespace, name, clusterIP string, protocol corev1.Protocol, port int32) *corev1.Service
FakeServiceClusterIP returns a ClusterIP service with the specified namespace, name and service info.
func FakeServiceLoadBalancer ¶ added in v0.7.1
func FakeServiceLoadBalancer(namespace, name, externalIP string, labels map[string]string, annotations map[string]string, protocol corev1.Protocol, port int32, portName string) *corev1.Service
FakeServiceLoadBalancer returns a LoadBalancer service with the specified namespace, name and service info.
func FakeServiceNodePort ¶ added in v0.7.1
func FakeServiceNodePort(namespace, name string, labels map[string]string, annotations map[string]string, protocol corev1.Protocol, port int32, portName string, nodePort int32) *corev1.Service
FakeServiceNodePort returns a NodePort service with the specified namespace, name and service info.
func FakeVirtualNode ¶
func FakeVirtualNode(name string, clusterID liqov1beta1.ClusterID, status offloadingv1beta1.VirtualNodeConditionStatusType, resoucesList corev1.ResourceList) *offloadingv1beta1.VirtualNode
FakeVirtualNode returns a fake VirtualNode.
func LogsToGinkgoWriter ¶ added in v0.4.0
func LogsToGinkgoWriter()
LogsToGinkgoWriter configures klog to output the logs to GinkgoWriter, instead of stdout. This allows to output the logs only in case of failing tests, simplifying troubleshooting.
func SqueezeWhitespaces ¶ added in v0.7.0
SqueezeWhitespaces squeezes a string replacing multiple whitespaces with a single one.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func (*Cluster) GetClient ¶
func (c *Cluster) GetClient() kubernetes.Interface
GetClient returns the crd client.
func (*Cluster) GetEnv ¶
func (c *Cluster) GetEnv() *envtest.Environment
GetEnv returns the test environment.
type IsNotFoundErrorMatcher ¶ added in v0.3.1
type IsNotFoundErrorMatcher struct{}
IsNotFoundErrorMatcher is a custom matcher to check when kubernetes resources do not exist.
func (*IsNotFoundErrorMatcher) FailureMessage ¶ added in v0.3.1
func (s *IsNotFoundErrorMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage is called when the matcher fails positively.
func (*IsNotFoundErrorMatcher) Match ¶ added in v0.3.1
func (s *IsNotFoundErrorMatcher) Match(actual interface{}) (success bool, err error)
Match is a GomegaMatcher interface method to actually run the matcher.
func (*IsNotFoundErrorMatcher) NegatedFailureMessage ¶ added in v0.3.1
func (s *IsNotFoundErrorMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage is called when the matcher fails negatively.
type MatchObject ¶ added in v0.4.0
MatchObject is a matcher that matches an object with a given name and namespace.
func (*MatchObject) FailureMessage ¶ added in v0.4.0
func (m *MatchObject) FailureMessage(actual interface{}) (message string)
FailureMessage returns a failure message.
func (*MatchObject) Match ¶ added in v0.4.0
func (m *MatchObject) Match(actual interface{}) (success bool, err error)
Match checks if it matches an object with a given name and namespace.
func (*MatchObject) NegatedFailureMessage ¶ added in v0.4.0
func (m *MatchObject) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage returns a negated failure message.