integrationtest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SINGLEPORTSVC       = "testsvc"                            // single port service name
	MULTIPORTSVC        = "testsvcmulti"                       // multi port service name
	NAMESPACE           = "red-ns"                             // namespace
	AVINAMESPACE        = "admin"                              // avi namespace
	AKOTENANT           = "akotenant"                          // ako tenant where TENANTS_PER_CLUSTER is enabled
	SINGLEPORTMODEL     = "admin/cluster--red-ns-testsvc"      // single port model name
	MULTIPORTMODEL      = "admin/cluster--red-ns-testsvcmulti" // multi port model name
	RANDOMUUID          = "random-uuid"                        // random avi object uuid
	DefaultIngressClass = "avi-lb"
	SSOTypeOAuth        = "OAuth"
	SSOTypeSAML         = "SAML"
	SHAREDVIPKEY        = "shared-vip-key"
	SHAREDVIPSVC01      = "shared-vip-svc-01"
	SHAREDVIPSVC02      = "shared-vip-svc-02"
	EXTDNSANNOTATION    = "custom-fqdn.com"
	EXTDNSSVC           = "custom-fqdn-svc"
	INVALID_LB_CLASS    = "not-ako-lb"
)

constants to be used for creating K8s objs and verifying Avi objs

Variables

View Source
var AllModels = []string{
	"admin/cluster--Shared-L7-0",
	"admin/cluster--Shared-L7-1",
	"admin/cluster--Shared-L7-2",
	"admin/cluster--Shared-L7-3",
	"admin/cluster--Shared-L7-4",
	"admin/cluster--Shared-L7-5",
	"admin/cluster--Shared-L7-6",
	"admin/cluster--Shared-L7-7",
	"admin/cluster--Shared-L7-EVH-0",
	"admin/cluster--Shared-L7-EVH-1",
	"admin/cluster--Shared-L7-EVH-2",
	"admin/cluster--Shared-L7-EVH-3",
	"admin/cluster--Shared-L7-EVH-4",
	"admin/cluster--Shared-L7-EVH-5",
	"admin/cluster--Shared-L7-EVH-6",
	"admin/cluster--Shared-L7-EVH-7",
}
View Source
var AviFakeClientInstance *httptest.Server
View Source
var CRDClient *crdfake.Clientset
View Source
var FakeAviObjects = []string{
	"cloud",
	"ipamdnsproviderprofile",
	"ipamdnsproviderprofiledomainlist",
	"network",
	"pool",
	"poolgroup",
	"virtualservice",
	"vrfcontext",
	"vsdatascriptset",
	"serviceenginegroup",
	"tenant",
	"vsvip",
	"l4policyset",
}
View Source
var KubeClient *k8sfake.Clientset

Functions

func AddConfigMap

func AddConfigMap(client *k8sfake.Clientset)

func AddDefaultIngressClass

func AddDefaultIngressClass()

func AddDefaultNamespace

func AddDefaultNamespace(ns ...string)

func AddIngressClassWithName

func AddIngressClassWithName(name string)

func AddMiddleware

func AddMiddleware(exec InjectFault)

func AddNamespace

func AddNamespace(t *testing.T, nsName string, labels map[string]string) error

func AddSecret

func AddSecret(secretName string, namespace string, cert string, key string)

func AnnotateAKONamespaceWithInfraSetting

func AnnotateAKONamespaceWithInfraSetting(t *testing.T, ns, infraSettingName string)

func ClearAllCache

func ClearAllCache(cacheObj *cache.AviObjCache)

func ConstructService

func ConstructService(ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool, selectors map[string]string, LBClass string, multiProtocol ...corev1.Protocol) *corev1.Service

func CreateEP

func CreateEP(t *testing.T, ns string, Name string, multiPort bool, multiAddress bool, addressPrefix string, multiProtocol ...corev1.Protocol)

CreateEP creates a sample Endpoint object if multiPort: False and multiAddress: False

1.1.1.1:8080

if multiPort: True and multiAddress: False

1.1.1.1:8080,
1.1.1.2:8081,
1.1.1.3:8082

if multiPort: False and multiAddress: True

1.1.1.1:8080, 1.1.1.2:8080, 1.1.1.2:8080

if multiPort: True and multiAddress: True

1.1.1.1:8080, 1.1.1.2:8080, 1.1.1.3:8080,
1.1.1.4:8081, 1.1.1.5:8081,
1.1.1.6:8082

func CreateNode

func CreateNode(t *testing.T, nodeName string, nodeIP string)

func CreateOrUpdateLease

func CreateOrUpdateLease(ns, podName string) error

func CreateSVC

func CreateSVC(t *testing.T, ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool, multiProtocol ...corev1.Protocol)

CreateSVC creates a sample service of type: Type if multiPort: True, the service gets created with 3 ports as follows ServicePorts: [

{Name: "foo0", Port: 8080, Protocol: "TCP", TargetPort: 8080},
{Name: "foo1", Port: 8081, Protocol: "TCP", TargetPort: 8081},
{Name: "foo2", Port: 8082, Protocol: "TCP", TargetPort: 8082},

]

func CreateSVCWithValidOrInvalidLBClass

func CreateSVCWithValidOrInvalidLBClass(t *testing.T, ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool, LBClass string, multiProtocol ...corev1.Protocol)

func CreateServiceWithSelectors

func CreateServiceWithSelectors(t *testing.T, ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool, selectors map[string]string, multiProtocol ...corev1.Protocol)

func DelEP

func DelEP(t *testing.T, ns string, Name string)

func DelSVC

func DelSVC(t *testing.T, ns string, Name string)

func DeleteConfigMap

func DeleteConfigMap(kubeClient *k8sfake.Clientset, t *testing.T)

func DeleteLease

func DeleteLease(ns string) error

func DeleteNamespace

func DeleteNamespace(nsName string)

func DeleteNode

func DeleteNode(t *testing.T, nodeName string)

func DeleteSecret

func DeleteSecret(secretName string, namespace string)

func DetectModelChecksumChange

func DetectModelChecksumChange(t *testing.T, key string, counter int) interface{}

func FeedMockCollectionData

func FeedMockCollectionData(w http.ResponseWriter, r *http.Request, mockFilePath string)

FeedMockCollectionData reads data from avimockobjects/*.json files and returns mock data for GET objects list API. GET /api/virtualservice returns from virtualservice_mock.json and so on

func GetShardVSNumber

func GetShardVSNumber(s string) string

s: namespace or hostname

func GetStaticRoute

func GetStaticRoute(nodeAddr, prefixAddr, routeID string, mask int32) *models.StaticRoute

func InitializeFakeAKOAPIServer

func InitializeFakeAKOAPIServer() *api.FakeApiServer

func NewAviFakeClientInstance

func NewAviFakeClientInstance(kubeclient *k8sfake.Clientset, skipCachePopulation ...bool)

func NormalControllerServer

func NormalControllerServer(w http.ResponseWriter, r *http.Request, args ...string)

func PollForCompletion

func PollForCompletion(t *testing.T, key string, counter int) interface{}

func PollForSyncStart

func PollForSyncStart(ctrl *k8s.AviController, counter int) bool

func RemoveAnnotateAKONamespaceWithInfraSetting

func RemoveAnnotateAKONamespaceWithInfraSetting(t *testing.T, ns string)

func RemoveDefaultIngressClass

func RemoveDefaultIngressClass()

func RemoveIngressClassWithName

func RemoveIngressClassWithName(ingClassName string)

func ResetAkoTenant

func ResetAkoTenant()

func ResetMiddleware

func ResetMiddleware()

func ScaleCreateEP

func ScaleCreateEP(t *testing.T, ns string, Name string)

func SetAkoTenant

func SetAkoTenant()

func SetClusterIPMode

func SetClusterIPMode()

func SetNodePortMode

func SetNodePortMode()

func SetUpOAuthSecret

func SetUpOAuthSecret() (err error)

func SetupAviInfraSetting

func SetupAviInfraSetting(t *testing.T, infraSettingName, shardSize string)

func SetupHTTPRule

func SetupHTTPRule(t *testing.T, rrname, fqdn, path string)

func SetupHostRule

func SetupHostRule(t *testing.T, hrname, fqdn string, secure bool, gslbHost ...string)

func SetupIngressClass

func SetupIngressClass(t *testing.T, ingclassName, controller, infraSetting string)

func SetupL4Rule

func SetupL4Rule(t *testing.T, name, namespace string, port []int)

func SetupL4RuleSSL

func SetupL4RuleSSL(t *testing.T, name, namespace string, port []int, applicationProfileRef *string, networkProfileRef *string, sslProfileRef *string, sslKeyAndCertificateRefs ...string)

func SetupL7Rule

func SetupL7Rule(t *testing.T, name string, g *gomega.WithT)

func SetupSSORule

func SetupSSORule(t *testing.T, srname, fqdn string, ssoType string)

func TearDownHostRuleWithNoVerify

func TearDownHostRuleWithNoVerify(t *testing.T, g *gomega.WithT, hrname string)

func TearDownOAuthSecret

func TearDownOAuthSecret() (err error)

func TeardownAviInfraSetting

func TeardownAviInfraSetting(t *testing.T, infraSettingName string)

func TeardownHTTPRule

func TeardownHTTPRule(t *testing.T, rrname string)

func TeardownHostRule

func TeardownHostRule(t *testing.T, g *gomega.WithT, vskey cache.NamespaceName, hrname string)

func TeardownIngressClass

func TeardownIngressClass(t *testing.T, ingClassName string)

func TeardownL4Rule

func TeardownL4Rule(t *testing.T, name, namespace string)

func TeardownSSORule

func TeardownSSORule(t *testing.T, g *gomega.WithT, vskey cache.NamespaceName, srname string)

func UpdateNamespace

func UpdateNamespace(t *testing.T, nsName string, labels map[string]string) error

func UpdateSVC

func UpdateSVC(t *testing.T, ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool)

func UpdateServiceWithSelectors

func UpdateServiceWithSelectors(t *testing.T, ns string, Name string, protocol corev1.Protocol, Type corev1.ServiceType, multiPort bool, selectors map[string]string)

func VerifyMetadataHTTPRule

func VerifyMetadataHTTPRule(t *testing.T, g *gomega.WithT, poolKey cache.NamespaceName, httpruleNSNamePath string, active bool)

func VerifyMetadataHostRule

func VerifyMetadataHostRule(t *testing.T, g *gomega.WithT, vsKey cache.NamespaceName, hrnsname string, active bool)

func VerifyMetadataSSORule

func VerifyMetadataSSORule(t *testing.T, g *gomega.WithT, vsKey cache.NamespaceName, srnsname string, active bool)

func WaitTillNamespaceDelete

func WaitTillNamespaceDelete(nsName string, retry_count int)

Types

type FakeAviInfraSetting

type FakeAviInfraSetting struct {
	Name           string
	SeGroupName    string
	Networks       []string
	EnableRhi      bool
	EnablePublicIP bool
	ShardSize      string
	BGPPeerLabels  []string
	T1LR           string
}

func (FakeAviInfraSetting) AviInfraSetting

func (infraSetting FakeAviInfraSetting) AviInfraSetting() *akov1beta1.AviInfraSetting

type FakeHTTPRule

type FakeHTTPRule struct {
	Name           string
	Namespace      string
	Fqdn           string
	PathProperties []FakeHTTPRulePath
}

func (FakeHTTPRule) HTTPRule

func (rr FakeHTTPRule) HTTPRule() *akov1beta1.HTTPRule

type FakeHTTPRulePath

type FakeHTTPRulePath struct {
	Path           string
	SslProfile     string
	DestinationCA  string
	PkiProfile     string
	HealthMonitors []string
	LbAlgorithm    string
	Hash           string
}

type FakeHostRule

type FakeHostRule struct {
	Name                  string
	Namespace             string
	Fqdn                  string
	SslKeyCertificate     string
	SslProfile            string
	WafPolicy             string
	ApplicationProfile    string
	ICAPProfile           []string
	EnableVirtualHost     bool
	AnalyticsProfile      string
	ErrorPageProfile      string
	Datascripts           []string
	HttpPolicySets        []string
	GslbFqdn              string
	NetworkSecurityPolicy string
	L7Rule                string
}

HostRule/HTTPRule lib functions

func (FakeHostRule) HostRule

func (hr FakeHostRule) HostRule() *akov1beta1.HostRule

type FakeIngress

type FakeIngress struct {
	DnsNames  []string
	Paths     []string
	Ips       []string
	HostNames []string
	Namespace string
	Name      string
	ClassName string

	ServiceName  string
	TlsSecretDNS map[string][]string
	// contains filtered or unexported fields
}

Fake ingress

func (FakeIngress) Ingress

func (ing FakeIngress) Ingress(multiport ...bool) *networking.Ingress

func (FakeIngress) IngressMultiPath

func (ing FakeIngress) IngressMultiPath() *networking.Ingress

func (FakeIngress) IngressMultiPort

func (ing FakeIngress) IngressMultiPort() *networking.Ingress

func (FakeIngress) IngressNoHost

func (ing FakeIngress) IngressNoHost() *networking.Ingress

func (FakeIngress) IngressOnlyHostNoBackend

func (ing FakeIngress) IngressOnlyHostNoBackend() *networking.Ingress

func (FakeIngress) SecureIngress

func (ing FakeIngress) SecureIngress() *networking.Ingress

func (FakeIngress) UpdateIngress

func (ing FakeIngress) UpdateIngress() (*networking.Ingress, error)

UpdateIngress wrapper over ingress update call. internally calls Ingress() for fakeIngress object performs a get for ingress object so it will update only if ingress exists

type FakeIngressClass

type FakeIngressClass struct {
	Name            string
	Controller      string
	AviInfraSetting string
	Default         bool
}

func (FakeIngressClass) IngressClass

func (ingclass FakeIngressClass) IngressClass() *networking.IngressClass

type FakeL4Rule

type FakeL4Rule struct {
	Name       string
	Namespace  string
	Ports      []int
	SSLEnabled bool
}

L4Rule lib functions

func (FakeL4Rule) L4Rule

func (lr FakeL4Rule) L4Rule() *akov1alpha2.L4Rule

type FakeL7Rule

type FakeL7Rule struct {
	AllowInvalidClientCert        bool
	BotPolicyRef                  string
	CloseClientConnOnConfigUpdate bool
	HostNameXlate                 string
	IgnPoolNetReach               bool
	MinPoolsUp                    uint32
	RemoveListeningPortOnVsDown   bool
	SecurityPolicyRef             string
	SslSessCacheAvgSize           uint32
	Name                          string
	Namespace                     string
}

func (FakeL7Rule) L7Rule

func (l7 FakeL7Rule) L7Rule() *akov1alpha2.L7Rule

type FakeMultiClusterIngress

type FakeMultiClusterIngress struct {
	HostName string
	Name     string

	Clusters     []string
	Weights      []int
	Paths        []string
	ServiceNames []string
	Ports        []int
	Namespaces   []string
	SecretName   string
	// contains filtered or unexported fields
}

Fake multi-cluster ingress

func (FakeMultiClusterIngress) Create

type FakeNamespace

type FakeNamespace struct {
	Name   string
	Labels map[string]string
}

Fake Namespace

func (FakeNamespace) Namespace

func (namespace FakeNamespace) Namespace() *corev1.Namespace

type FakeNode

type FakeNode struct {
	Name               string
	PodCIDR            string
	PodCIDRs           []string
	NodeIP             string
	Version            string
	PodCIDRsAnnotation string
}

func (FakeNode) Node

func (node FakeNode) Node() *corev1.Node

func (FakeNode) NodeCalico

func (node FakeNode) NodeCalico() *corev1.Node

func (FakeNode) NodeOVN

func (node FakeNode) NodeOVN() *corev1.Node

type FakeSSORule

type FakeSSORule struct {
	Name      string
	Namespace string
	Fqdn      string
	// SSOType valid values currently are OAuth and SAML
	SSOType string
}

func (FakeSSORule) SSORule

func (sr FakeSSORule) SSORule() *akov1alpha2.SSORule

type FakeSecret

type FakeSecret struct {
	Cert      string
	Key       string
	Name      string
	Namespace string
}

Fake Secret

func (FakeSecret) Secret

func (secret FakeSecret) Secret() *corev1.Secret

type FakeService

type FakeService struct {
	Namespace         string
	Name              string
	Labels            map[string]string
	Type              corev1.ServiceType
	LoadBalancerIP    string
	ServicePorts      []Serviceport
	Selectors         map[string]string
	Annotations       map[string]string
	LoadBalancerClass string
}

func (FakeService) Service

func (svc FakeService) Service() *corev1.Service

type FakeServiceImport

type FakeServiceImport struct {
	Name          string
	Cluster       string
	Namespace     string
	ServiceName   string
	EndPointIPs   []string
	EndPointPorts []int32
}

Fake service import

func (FakeServiceImport) Create

type InjectFault

type InjectFault func(w http.ResponseWriter, r *http.Request)
var FakeServerMiddleware InjectFault

type Serviceport

type Serviceport struct {
	PortName   string
	PortNumber int32
	NodePort   int32
	Protocol   corev1.Protocol
	TargetPort intstr.IntOrString
}

Jump to

Keyboard shortcuts

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