framework

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package framework provides common functionalities for e2e tests.

Index

Constants

View Source
const (
	// PollInterval defines the interval time for a poll operation.
	PollInterval = 1 * time.Second
	// PollTimeout defines the time after which the poll operation times out.
	// Increase the poll timeout to capture the service export condition changes.
	PollTimeout = 60 * time.Second

	// MCSLBPollTimeout defines the time to wait a MCS to be assigned with LoadBalancer IP address.
	// As MCS depending on handling service related to cloud provider, more time is required.
	MCSLBPollTimeout = 240 * time.Second

	// TestNamespacePrefix defines the prefix of test namespaces.
	TestNamespacePrefix = "my-ns"
)

Variables

View Source
var (
	// SvcExportConditionCmpOptions configures comparison behaviors foo service export conditions.
	SvcExportConditionCmpOptions = []cmp.Option{
		cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime", "ObservedGeneration", "Message"),
		cmpopts.SortSlices(func(condition1, condition2 metav1.Condition) bool { return condition1.Type < condition2.Type }),
	}

	// MCSConditionCmpOptions configures comparison behaviors foo multi-cluster service conditions.
	MCSConditionCmpOptions = []cmp.Option{
		cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime", "ObservedGeneration", "Message"),
		cmpopts.SortSlices(func(condition1, condition2 metav1.Condition) bool { return condition1.Type < condition2.Type }),
	}
)

Functions

func ClusterIPServiceWithNoSelector added in v0.2.0

func ClusterIPServiceWithNoSelector(namespace, name, portName string, port, targetPort int) *corev1.Service

ClusterIPServiceWithNoSelector returns a Cluster IP type Service object with no selector specified.

func ManuallyManagedIPv4EndpointSlice added in v0.2.0

func ManuallyManagedIPv4EndpointSlice(namespace, name, svcName, portName string, port int32, addresses []string) *discoveryv1.EndpointSlice

ManuallyManagedIPv4EndpointSlice returns a manually managed EndpointSlice object.

func MultiClusterService added in v0.2.0

func MultiClusterService(namespace, name, svcName string) *fleetnetv1alpha1.MultiClusterService

MultiClusterService returns a MultiClusterService object.

func Namespace added in v0.2.0

func Namespace(name string) *corev1.Namespace

Namespace returns a Namespace object.

func NewPrometheusAPIClient added in v0.2.0

func NewPrometheusAPIClient(prometheusAPISvcAddr string) (prometheusapi.Client, error)

NewPrometheusAPIClient returns a client for Prometheus API server.

func QueryHistogramQuantileAggregated added in v0.2.0

func QueryHistogramQuantileAggregated(ctx context.Context, prometheusAPIClient prometheusapi.Client, phi float32, histogramName string) (float64, error)

QueryHistogramQuantileAggregated queries the Prometheus API server for the aggregated phi-quantile of a histogram.

func ServiceExport added in v0.2.0

func ServiceExport(namespace, name string) *fleetnetv1alpha1.ServiceExport

ServiceExport returns a ServiceExport object.

func UniqueTestNamespace added in v0.1.2

func UniqueTestNamespace() string

UniqueTestNamespace gives a unique namespace name.

Types

type Cluster

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

Cluster represents a Kubernetes cluster.

func NewCluster

func NewCluster(name string, scheme *runtime.Scheme) (*Cluster, error)

NewCluster creates a Cluster and initializes its Kubernetes client.

func NewClusterWithBurstQPS added in v0.2.1

func NewClusterWithBurstQPS(name string, scheme *runtime.Scheme, QPS, BurstQPS int) (*Cluster, error)

NewClusterWithBurstQPS creates a Cluster and initializes its Kubernetes client with custom QPS and Burst settings.

func (*Cluster) Client

func (c *Cluster) Client() client.Client

Client returns the kubernetes client.

func (*Cluster) Name

func (c *Cluster) Name() string

Name returns the cluster name.

func (*Cluster) PrometheusAPIServiceAddress added in v0.2.0

func (c *Cluster) PrometheusAPIServiceAddress() string

PrometheusAPIServiceAddress returns the address of the Prometheus API service.

func (*Cluster) SetupPrometheusAPIServiceAccess added in v0.2.0

func (c *Cluster) SetupPrometheusAPIServiceAccess(ctx context.Context, prometheusAPISvcNS, prometheusAPISvcName string) error

SetupPrometheusAPIServiceAccess retrieves address of the Prometheus API service.

type Fleet added in v0.1.2

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

Fleet is a collection of clusters for e2e tests.

func NewFleet added in v0.1.2

func NewFleet(memberClusters []*Cluster, mcsMemberCluster, hubCluster *Cluster) *Fleet

NewFleet returns a collection of clusters for e2e tests.

func (*Fleet) Clusters added in v0.1.2

func (c *Fleet) Clusters() []*Cluster

Clusters returns all clusters including both member and hub.

func (*Fleet) HubCluster added in v0.1.2

func (c *Fleet) HubCluster() *Cluster

HubCluster returns a hub cluster.

func (*Fleet) MCSMemberCluster added in v0.1.2

func (c *Fleet) MCSMemberCluster() *Cluster

MCSMemberCluster returns a member cluster on which MCS will be hosted.

func (*Fleet) MemberClusters added in v0.1.2

func (c *Fleet) MemberClusters() []*Cluster

MemberClusters returns all member clusters.

type WorkloadManager added in v0.1.2

type WorkloadManager struct {
	Fleet *Fleet
	// contains filtered or unexported fields
}

WorkloadManager represents a suite of variables of operations required to test exporting an service and more.

func NewWorkloadManager added in v0.1.2

func NewWorkloadManager(fleet *Fleet) *WorkloadManager

NewWorkloadManager returns a workload manager with default values.

func (*WorkloadManager) CreateMultiClusterService added in v0.1.2

func (wm *WorkloadManager) CreateMultiClusterService(ctx context.Context, mcs fleetnetv1alpha1.MultiClusterService) error

CreateMultiClusterService create a mcs from caller and wait until service import is found.

func (*WorkloadManager) DeleteMultiClusterService added in v0.1.2

func (wm *WorkloadManager) DeleteMultiClusterService(ctx context.Context, mcs fleetnetv1alpha1.MultiClusterService) error

DeleteMultiClusterService deletes the mcs specified from caller and wait until the mcs is not found.

func (*WorkloadManager) DeployWorkload added in v0.1.2

func (wm *WorkloadManager) DeployWorkload(ctx context.Context) error

DeployWorkload deploys workload(deployment and its service) to member clusters.

func (*WorkloadManager) Deployment added in v0.1.2

func (wm *WorkloadManager) Deployment(clusterName string) *appsv1.Deployment

Deployment returns an deployment definition base on the cluster name.

func (*WorkloadManager) ExportService added in v0.1.2

func (wm *WorkloadManager) ExportService(ctx context.Context, svcExport fleetnetv1alpha1.ServiceExport) error

ExportService exports the service by creating a service export.

func (*WorkloadManager) MultiClusterService added in v0.1.2

func (wm *WorkloadManager) MultiClusterService() fleetnetv1alpha1.MultiClusterService

ServiceExport returns the MultiClusterService definition from pre-defined service name and namespace.

func (*WorkloadManager) RemoveWorkload added in v0.1.2

func (wm *WorkloadManager) RemoveWorkload(ctx context.Context) error

DeployWorkload deletes workload(deployment and its service) from member clusters.

func (*WorkloadManager) Service added in v0.1.2

func (wm *WorkloadManager) Service() corev1.Service

Service returns the service which workload manager will deploy.

func (*WorkloadManager) ServiceExport added in v0.1.2

func (wm *WorkloadManager) ServiceExport() fleetnetv1alpha1.ServiceExport

ServiceExport returns the ServiceExport definition from pre-defined service name and namespace.

func (*WorkloadManager) UnexportService added in v0.1.2

func (wm *WorkloadManager) UnexportService(ctx context.Context, svcExport fleetnetv1alpha1.ServiceExport) error

UnexportService deletes the ServiceExport specified by caller and wait until the ServiceExport is not found.

Jump to

Keyboard shortcuts

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