Documentation
¶
Index ¶
- Constants
- Variables
- func CreateFramework(ctx context.Context, scheme *runtime.Scheme) error
- func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectEmpty(actual interface{}, explain ...interface{})
- func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
- func ExpectError(err error, explain ...interface{})
- func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
- func ExpectMatchRegexp(actual string, regexp string, explain ...interface{})
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
- type Framework
- func (f *Framework) CreateCurlPod(ns string) (*corev1.Pod, error)
- func (f *Framework) CreateEgressNetworkPolicyForDNS(ns string) (*networkingv1.NetworkPolicy, error)
- func (f *Framework) CreateNginxPodAndService(ns string) (*corev1.Pod, *corev1.Service, error)
- func (f *Framework) DeleteTestNamespace(ns string, waitUntilDeleted bool) error
- func (f *Framework) GetDefaultSecurityContext() *corev1.SecurityContext
- func (f *Framework) TestServiceIsEventuallyReachable(curlPod *corev1.Pod, service *corev1.Service)
- func (f *Framework) TestServiceIsEventuallyUnreachable(curlPod *corev1.Pod, service *corev1.Service)
- func (f *Framework) WaitForPodRunning(podName string, ns string) error
- func (f *Framework) WaitForService(serviceName string, ns string) error
- func (f *Framework) WaitForServiceAccount(saName string, ns string) error
- func (f *Framework) WaitForServiceInSyncerCache(serviceName string, ns string) error
Constants ¶
const (
PollTimeout = time.Minute
DefaultVclusterName = "vcluster"
DefaultVclusterNamespace = "vcluster"
DefaultClientTimeout = 32 * time.Second // the default in client-go is 32
)
Variables ¶
var DefaultFramework = &Framework{}
Functions ¶
func CreateFramework ¶
func CreateFramework(ctx context.Context, scheme *runtime.Scheme) error
func ExpectConsistOf ¶
func ExpectConsistOf(actual interface{}, extra interface{}, explain ...interface{})
ExpectConsistOf expects actual contains precisely the extra elements. The ordering of the elements does not matter.
func ExpectEmpty ¶
func ExpectEmpty(actual interface{}, explain ...interface{})
ExpectEmpty expects actual is empty
func ExpectEqual ¶
func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectEqual expects the specified two are the same, otherwise an exception raises
func ExpectError ¶
func ExpectError(err error, explain ...interface{})
ExpectError expects an error happens, otherwise an exception raises
func ExpectHaveKey ¶
func ExpectHaveKey(actual interface{}, key interface{}, explain ...interface{})
ExpectHaveKey expects the actual map has the key in the keyset
func ExpectMatchRegexp ¶ added in v0.4.4
func ExpectMatchRegexp(actual string, regexp string, explain ...interface{})
ExpectMatchRegexp expects the the string to match the provided regular expression
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
func ExpectNoErrorWithOffset ¶
func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func ExpectNotEqual ¶
func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{})
ExpectNotEqual expects the specified two are not the same, otherwise an exception raises
Types ¶
type Framework ¶
type Framework struct {
// The context to use for testing
Context context.Context
// VclusterName is the name of the vcluster instance which we are testing
VclusterName string
// VclusterNamespace is the namespace in host cluster of the current
// vcluster instance which we are testing
VclusterNamespace string
// The suffix to append to the synced resources in the host namespace
Suffix string
// HostConfig is the kubernetes rest config of the
// host kubernetes cluster were we are testing in
HostConfig *rest.Config
// HostClient is the kubernetes client of the current
// host kubernetes cluster were we are testing in
HostClient *kubernetes.Clientset
// VclusterConfig is the kubernetes rest config of the current
// vcluster instance which we are testing
VclusterConfig *rest.Config
// VclusterClient is the kubernetes client of the current
// vcluster instance which we are testing
VclusterClient *kubernetes.Clientset
// Scheme is the global scheme to use
Scheme *runtime.Scheme
// Log is the logger that should be used
Log log.Logger
// ClientTimeout value used in the clients
ClientTimeout time.Duration
}
func (*Framework) CreateCurlPod ¶ added in v0.5.0
func (f *Framework) CreateCurlPod(ns string) (*corev1.Pod, error)
func (*Framework) CreateEgressNetworkPolicyForDNS ¶ added in v0.5.0
func (f *Framework) CreateEgressNetworkPolicyForDNS(ns string) (*networkingv1.NetworkPolicy, error)
func (*Framework) CreateNginxPodAndService ¶ added in v0.5.0
func (f *Framework) CreateNginxPodAndService(ns string) (*corev1.Pod, *corev1.Service, error)
func (*Framework) DeleteTestNamespace ¶ added in v0.4.4
func (f *Framework) DeleteTestNamespace(ns string, waitUntilDeleted bool) error
func (*Framework) GetDefaultSecurityContext ¶ added in v0.5.0
func (f *Framework) GetDefaultSecurityContext() *corev1.SecurityContext
func (*Framework) TestServiceIsEventuallyReachable ¶ added in v0.5.0
func (f *Framework) TestServiceIsEventuallyReachable(curlPod *corev1.Pod, service *corev1.Service)
func (*Framework) TestServiceIsEventuallyUnreachable ¶ added in v0.5.0
func (f *Framework) TestServiceIsEventuallyUnreachable(curlPod *corev1.Pod, service *corev1.Service)
func (*Framework) WaitForPodRunning ¶ added in v0.4.4
func (f *Framework) WaitForPodRunning(podName string, ns string) error
func (*Framework) WaitForService ¶ added in v0.5.0
func (f *Framework) WaitForService(serviceName string, ns string) error
func (*Framework) WaitForServiceAccount ¶ added in v0.4.4
func (f *Framework) WaitForServiceAccount(saName string, ns string) error
func (*Framework) WaitForServiceInSyncerCache ¶ added in v0.5.0
func (f *Framework) WaitForServiceInSyncerCache(serviceName string, ns string) error
Some vcluster operations list Service, e.g. pod translation. To ensure expected results of such operation we need to wait until newly created Service is in syncer controller cache, otherwise syncer will operate on slightly outdated resources, which is not good for test stability. This function ensures that Service is actually in controller cache by making an update and checking for it in physical service.