Documentation ¶
Index ¶
- Constants
- Variables
- func AsOwner(obj metav1.ObjectMeta) genruntime.KnownResourceReference
- func CreateTestResourceGroupDefaultTags() map[string]string
- func NewTestLogger(t *testing.T) logr.Logger
- func SetupTeardownTestMain(m *testing.M, skipSlowTests bool, setup func() error, teardown func() error) int
- func WaitFor(ctx context.Context, timeout time.Duration, ...) error
- type ArmMatcher
- type AzureBeDeletedMatcher
- func (m *AzureBeDeletedMatcher) FailureMessage(actual interface{}) string
- func (m *AzureBeDeletedMatcher) Match(actual interface{}) (bool, error)
- func (m *AzureBeDeletedMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
- func (m *AzureBeDeletedMatcher) NegatedFailureMessage(actual interface{}) string
- type AzureBeProvisionedMatcher
- func (m *AzureBeProvisionedMatcher) FailureMessage(actual interface{}) string
- func (m *AzureBeProvisionedMatcher) Match(actual interface{}) (bool, error)
- func (m *AzureBeProvisionedMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
- func (m *AzureBeProvisionedMatcher) NegatedFailureMessage(actual interface{}) string
- type BeDeletedMatcher
- type DesiredStateMatcher
- func (m *DesiredStateMatcher) FailureMessage(actual interface{}) string
- func (m *DesiredStateMatcher) Match(actual interface{}) (bool, error)
- func (m *DesiredStateMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
- func (m *DesiredStateMatcher) NegatedFailureMessage(actual interface{}) string
- type KubeBaseTestContext
- type KubeGlobalContext
- type KubeMatcher
- type KubePerTestContext
- func (tc *KubePerTestContext) CreateResourceAndWait(obj client.Object)
- func (tc *KubePerTestContext) CreateResourceAndWaitForFailure(obj client.Object)
- func (tc KubePerTestContext) CreateResourceGroup(rg *resources.ResourceGroup) (*resources.ResourceGroup, error)
- func (tc KubePerTestContext) CreateResourceGroupAndWait(rg *resources.ResourceGroup) *resources.ResourceGroup
- func (tc *KubePerTestContext) CreateResourcesAndWait(objs ...client.Object)
- func (tc *KubePerTestContext) CreateTestResourceGroupAndWait() *v1alpha1api20200601.ResourceGroup
- func (tc *KubePerTestContext) DefaultTimeout() time.Duration
- func (tc *KubePerTestContext) DeleteResourceAndWait(obj client.Object)
- func (tc *KubePerTestContext) DeleteResourcesAndWait(objs ...client.Object)
- func (tc *KubePerTestContext) Eventually(actual interface{}, intervals ...interface{}) gomega.AsyncAssertion
- func (tc *KubePerTestContext) Expect(actual interface{}) gomega.Assertion
- func (tc *KubePerTestContext) GetResource(key types.NamespacedName, obj client.Object)
- func (tc KubePerTestContext) MakeObjectMeta(prefix string) ctrl.ObjectMeta
- func (tc KubePerTestContext) MakeObjectMetaWithName(name string) ctrl.ObjectMeta
- func (tc KubePerTestContext) MakeReferenceFromResource(resource client.Object) genruntime.ResourceReference
- func (tc KubePerTestContext) MakeReferencePtrFromResource(resource client.Object) *genruntime.ResourceReference
- func (tc KubePerTestContext) NewTestResourceGroup() *resources.ResourceGroup
- func (tc *KubePerTestContext) Patch(old client.Object, new client.Object)
- func (tc *KubePerTestContext) PatchResourceAndWaitAfter(old client.Object, new client.Object, ...)
- func (tc *KubePerTestContext) PollingInterval() time.Duration
- func (tc *KubePerTestContext) RemainingTime() time.Duration
- func (tc *KubePerTestContext) RunParallelSubtests(tests ...Subtest)
- func (tc KubePerTestContext) Subtest(t *testing.T) KubePerTestContext
- func (tc *KubePerTestContext) UpdateResource(obj client.Object)
- type PerTestContext
- type ResourceNameConfig
- type ResourceNamer
- type Subtest
- type TestContext
- type TestLogger
- func (t *TestLogger) Enabled() bool
- func (t *TestLogger) Error(err error, msg string, keysAndValues ...interface{})
- func (t *TestLogger) Info(msg string, keysAndValues ...interface{})
- func (t *TestLogger) V(level int) logr.Logger
- func (t *TestLogger) WithName(name string) logr.Logger
- func (t *TestLogger) WithValues(keysAndValues ...interface{}) logr.Logger
- type Verify
- func (e *Verify) AllDeleted(ctx context.Context, objs []client.Object) (bool, error)
- func (e *Verify) Deleted(ctx context.Context, obj client.Object) (bool, error)
- func (e *Verify) Failed(ctx context.Context, obj client.Object) (bool, error)
- func (e *Verify) HasState(ctx context.Context, obj client.Object, desiredState metav1.ConditionStatus, ...) (bool, error)
- func (e *Verify) Provisioned(ctx context.Context, obj client.Object) (bool, error)
- type WaitCondition
Constants ¶
const ResourcePrefix = "asotest"
If you modify this make sure to modify the cleanup-test-azure-resources target in the Makefile too
Variables ¶
var COUNT_HEADER string = "TEST-REQUEST-ATTEMPT"
var DefaultTestRegion = "westus2" // Could make this an env variable if we wanted
Use WestUS2 as some things (such as VM quota) are hard to get in West US.
var DefaultTimeoutRecording = 15 * time.Minute
DefaultTimeoutRecording is the default timeout for a single operation when recording. This is so high primarily because deleting an AKS cluster takes a long time.
var DefaultTimeoutReplaying = 2 * time.Minute
DefaultTimeoutReplaying is the default timeout for a single operation when replaying.
var LogLevel = 5
TODO: I'm not sure the best way to configure this so for now I'm just going to set it to 5
var PollingIntervalRecording = 5 * time.Second
PollingIntervalRecording is the polling interval to use when recording.
var PollingIntervalReplaying = 1 * time.Second
PollingIntervalReplaying is the polling interval to use when replaying. TODO: Setting this really low sometimes seems to cause TODO: updating resource: Operation cannot be fulfilled: the object has been modified; please apply your changes to the latest version and try again. TODO: This happens when the test sees a Status update and makes an update to the resource while racing with the Spec update TODO: in azure_deployment_reconciler CommitUpdate. If we fix https://github.com/Azure/azure-service-operator/issues/1744 we can TODO: shorten this interval.
Functions ¶
func AsOwner ¶
func AsOwner(obj metav1.ObjectMeta) genruntime.KnownResourceReference
func SetupTeardownTestMain ¶
Types ¶
type ArmMatcher ¶
type ArmMatcher struct {
// contains filtered or unexported fields
}
func NewArmMatcher ¶
func NewArmMatcher(armClient armclient.Applier) *ArmMatcher
func (*ArmMatcher) BeDeleted ¶
func (m *ArmMatcher) BeDeleted(ctx context.Context) types.GomegaMatcher
func (*ArmMatcher) BeProvisioned ¶
func (m *ArmMatcher) BeProvisioned(ctx context.Context) types.GomegaMatcher
type AzureBeDeletedMatcher ¶
type AzureBeDeletedMatcher struct {
// contains filtered or unexported fields
}
func (*AzureBeDeletedMatcher) FailureMessage ¶
func (m *AzureBeDeletedMatcher) FailureMessage(actual interface{}) string
func (*AzureBeDeletedMatcher) Match ¶
func (m *AzureBeDeletedMatcher) Match(actual interface{}) (bool, error)
func (*AzureBeDeletedMatcher) MatchMayChangeInTheFuture ¶
func (m *AzureBeDeletedMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
MatchMayChangeInTheFuture implements OracleMatcher which of course isn't exported so we can't type-assert we implement it
func (*AzureBeDeletedMatcher) NegatedFailureMessage ¶
func (m *AzureBeDeletedMatcher) NegatedFailureMessage(actual interface{}) string
type AzureBeProvisionedMatcher ¶
type AzureBeProvisionedMatcher struct {
// contains filtered or unexported fields
}
func (*AzureBeProvisionedMatcher) FailureMessage ¶
func (m *AzureBeProvisionedMatcher) FailureMessage(actual interface{}) string
func (*AzureBeProvisionedMatcher) Match ¶
func (m *AzureBeProvisionedMatcher) Match(actual interface{}) (bool, error)
func (*AzureBeProvisionedMatcher) MatchMayChangeInTheFuture ¶
func (m *AzureBeProvisionedMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
MatchMayChangeInTheFuture implements OracleMatcher which of course isn't exported so we can't type-assert we implement it
func (*AzureBeProvisionedMatcher) NegatedFailureMessage ¶
func (m *AzureBeProvisionedMatcher) NegatedFailureMessage(actual interface{}) string
type BeDeletedMatcher ¶
type BeDeletedMatcher struct {
// contains filtered or unexported fields
}
func (*BeDeletedMatcher) FailureMessage ¶
func (m *BeDeletedMatcher) FailureMessage(actual interface{}) string
func (*BeDeletedMatcher) Match ¶
func (m *BeDeletedMatcher) Match(actual interface{}) (bool, error)
func (*BeDeletedMatcher) MatchMayChangeInTheFuture ¶
func (m *BeDeletedMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
MatchMayChangeInTheFuture implements OracleMatcher which of course isn't exported so we can't type-assert we implement it
func (*BeDeletedMatcher) NegatedFailureMessage ¶
func (m *BeDeletedMatcher) NegatedFailureMessage(actual interface{}) string
type DesiredStateMatcher ¶
type DesiredStateMatcher struct {
// contains filtered or unexported fields
}
func (*DesiredStateMatcher) FailureMessage ¶
func (m *DesiredStateMatcher) FailureMessage(actual interface{}) string
func (*DesiredStateMatcher) Match ¶
func (m *DesiredStateMatcher) Match(actual interface{}) (bool, error)
func (*DesiredStateMatcher) MatchMayChangeInTheFuture ¶
func (m *DesiredStateMatcher) MatchMayChangeInTheFuture(actual interface{}) bool
MatchMayChangeInTheFuture implements OracleMatcher which of course isn't exported so we can't type-assert we implement it
func (*DesiredStateMatcher) NegatedFailureMessage ¶
func (m *DesiredStateMatcher) NegatedFailureMessage(actual interface{}) string
type KubeBaseTestContext ¶
type KubeBaseTestContext struct { PerTestContext KubeConfig *rest.Config }
type KubeGlobalContext ¶
type KubeGlobalContext struct { TestContext // contains filtered or unexported fields }
TODO: State Annotation parameter should be removed once the interface for Status determined and promoted TODO: to genruntime. Same for errorAnnotation
func NewKubeContext ¶
func NewKubeContext( useEnvTest bool, recordReplay bool, namespace string, region string) KubeGlobalContext
func (KubeGlobalContext) ForTest ¶
func (ctx KubeGlobalContext) ForTest(t *testing.T) KubePerTestContext
func (KubeGlobalContext) Namespace ¶
func (ctx KubeGlobalContext) Namespace() string
type KubeMatcher ¶
type KubeMatcher struct {
// contains filtered or unexported fields
}
TODO: Would we rather these just be on testcontext? Might read better
func NewKubeMatcher ¶
func NewKubeMatcher(verify *Verify, ctx context.Context) *KubeMatcher
func (*KubeMatcher) BeDeleted ¶
func (m *KubeMatcher) BeDeleted() types.GomegaMatcher
func (*KubeMatcher) BeFailed ¶
func (m *KubeMatcher) BeFailed() types.GomegaMatcher
func (*KubeMatcher) BeProvisioned ¶
func (m *KubeMatcher) BeProvisioned() types.GomegaMatcher
func (*KubeMatcher) BeProvisionedAfter ¶
func (m *KubeMatcher) BeProvisionedAfter(previousReadyCondition conditions.Condition) types.GomegaMatcher
type KubePerTestContext ¶
type KubePerTestContext struct { *KubeGlobalContext KubeBaseTestContext Ctx context.Context KubeClient client.Client G gomega.Gomega Verify *Verify Match *KubeMatcher // contains filtered or unexported fields }
func (*KubePerTestContext) CreateResourceAndWait ¶
func (tc *KubePerTestContext) CreateResourceAndWait(obj client.Object)
CreateResourceAndWait creates the resource in K8s and waits for it to change into the Provisioned state.
func (*KubePerTestContext) CreateResourceAndWaitForFailure ¶
func (tc *KubePerTestContext) CreateResourceAndWaitForFailure(obj client.Object)
CreateResourceAndWaitForFailure creates the resource in K8s and waits for it to change into the Failed state.
func (KubePerTestContext) CreateResourceGroup ¶
func (tc KubePerTestContext) CreateResourceGroup(rg *resources.ResourceGroup) (*resources.ResourceGroup, error)
CreateResourceGroup creates a new resource group and registers it to be deleted up when the context is cleaned up
func (KubePerTestContext) CreateResourceGroupAndWait ¶
func (tc KubePerTestContext) CreateResourceGroupAndWait(rg *resources.ResourceGroup) *resources.ResourceGroup
CreateResourceGroupAndWait creates the specified resource group, registers it to be deleted when the context is cleaned up, and waits for it to finish being created.
func (*KubePerTestContext) CreateResourcesAndWait ¶
func (tc *KubePerTestContext) CreateResourcesAndWait(objs ...client.Object)
CreateResourcesAndWait creates the resources in K8s and waits for them to change into the Provisioned state.
func (*KubePerTestContext) CreateTestResourceGroupAndWait ¶
func (tc *KubePerTestContext) CreateTestResourceGroupAndWait() *v1alpha1api20200601.ResourceGroup
func (*KubePerTestContext) DefaultTimeout ¶
func (tc *KubePerTestContext) DefaultTimeout() time.Duration
func (*KubePerTestContext) DeleteResourceAndWait ¶
func (tc *KubePerTestContext) DeleteResourceAndWait(obj client.Object)
DeleteResourceAndWait deletes the given resource in K8s and waits for it to update to the Deleted state.
func (*KubePerTestContext) DeleteResourcesAndWait ¶
func (tc *KubePerTestContext) DeleteResourcesAndWait(objs ...client.Object)
DeleteResourcesAndWait deletes the resources in K8s and waits for them to be deleted
func (*KubePerTestContext) Eventually ¶
func (tc *KubePerTestContext) Eventually(actual interface{}, intervals ...interface{}) gomega.AsyncAssertion
func (*KubePerTestContext) Expect ¶
func (tc *KubePerTestContext) Expect(actual interface{}) gomega.Assertion
func (*KubePerTestContext) GetResource ¶
func (tc *KubePerTestContext) GetResource(key types.NamespacedName, obj client.Object)
GetResource retrieves the current state of the resource from K8s (not from Azure).
func (KubePerTestContext) MakeObjectMeta ¶
func (tc KubePerTestContext) MakeObjectMeta(prefix string) ctrl.ObjectMeta
func (KubePerTestContext) MakeObjectMetaWithName ¶
func (tc KubePerTestContext) MakeObjectMetaWithName(name string) ctrl.ObjectMeta
func (KubePerTestContext) MakeReferenceFromResource ¶
func (tc KubePerTestContext) MakeReferenceFromResource(resource client.Object) genruntime.ResourceReference
func (KubePerTestContext) MakeReferencePtrFromResource ¶
func (tc KubePerTestContext) MakeReferencePtrFromResource(resource client.Object) *genruntime.ResourceReference
func (KubePerTestContext) NewTestResourceGroup ¶
func (tc KubePerTestContext) NewTestResourceGroup() *resources.ResourceGroup
func (*KubePerTestContext) Patch ¶
func (tc *KubePerTestContext) Patch(old client.Object, new client.Object)
func (*KubePerTestContext) PatchResourceAndWaitAfter ¶
func (tc *KubePerTestContext) PatchResourceAndWaitAfter(old client.Object, new client.Object, previousReadyCondition conditions.Condition)
PatchResourceAndWaitAfter patches the resource in K8s and waits for it to change into the Provisioned state from the provided previousState.
func (*KubePerTestContext) PollingInterval ¶
func (tc *KubePerTestContext) PollingInterval() time.Duration
PollingInterval returns the polling interval to use for Gomega Eventually
func (*KubePerTestContext) RemainingTime ¶
func (tc *KubePerTestContext) RemainingTime() time.Duration
RemainingTime returns how long is left until test timeout, and can be used with gomega.Eventually to get better failure behaviour
(If you hit the deadline 'go test' aborts everything and dumps the current task stacks to output. If gomega.Eventually hits its timeout it will produce a nicer error message and stack trace.)
func (*KubePerTestContext) RunParallelSubtests ¶
func (tc *KubePerTestContext) RunParallelSubtests(tests ...Subtest)
RunParallelSubtests runs the given tests in parallel. They are given their own KubePerTestContext.
func (KubePerTestContext) Subtest ¶
func (tc KubePerTestContext) Subtest(t *testing.T) KubePerTestContext
Subtest replaces any testing.T-specific types with new values
func (*KubePerTestContext) UpdateResource ¶
func (tc *KubePerTestContext) UpdateResource(obj client.Object)
UpdateResource updates the given resource in K8s.
type PerTestContext ¶
type PerTestContext struct { TestContext T *testing.T AzureClientRecorder *recorder.Recorder AzureClient armclient.Applier AzureSubscription string AzureMatch *ArmMatcher Namer ResourceNamer TestName string // contains filtered or unexported fields }
func (PerTestContext) GenerateSSHKey ¶
func (tc PerTestContext) GenerateSSHKey(size int) (*string, error)
GenerateSSHKey generates an SSH key.
func (PerTestContext) MakeARMId ¶
func (tc PerTestContext) MakeARMId(resourceGroup string, provider string, params ...string) string
func (PerTestContext) NewTestResourceGroup ¶
func (tc PerTestContext) NewTestResourceGroup() *resources.ResourceGroup
type ResourceNameConfig ¶
type ResourceNameConfig struct {
// contains filtered or unexported fields
}
func NewResourceNameConfig ¶
func NewResourceNameConfig(prefix string, separator string, randomChars int) *ResourceNameConfig
func (ResourceNameConfig) NewResourceNamer ¶
func (rnc ResourceNameConfig) NewResourceNamer(testName string) ResourceNamer
NewResourceNamer returns a ResourceNamer that generates random suffixes based upon the test name
type ResourceNamer ¶
type ResourceNamer struct { ResourceNameConfig // contains filtered or unexported fields }
func (ResourceNamer) GenerateName ¶
func (n ResourceNamer) GenerateName(prefix string) string
func (ResourceNamer) GeneratePassword ¶
func (n ResourceNamer) GeneratePassword() string
func (ResourceNamer) WithNumRandomChars ¶
func (n ResourceNamer) WithNumRandomChars(num int) ResourceNamer
WithNumRandomChars returns a copy of the ResourceNamer which will generate names with a random string of the given length included
func (ResourceNamer) WithSeparator ¶
func (n ResourceNamer) WithSeparator(separator string) ResourceNamer
WithSeparator returns a copy of the ResourceNamer with the given separator
type Subtest ¶
type Subtest struct { Name string Test func(testContext KubePerTestContext) }
type TestContext ¶
type TestContext struct { AzureRegion string NameConfig *ResourceNameConfig RecordReplay bool }
func NewTestContext ¶
func NewTestContext(region string, recordReplay bool) TestContext
func (TestContext) ForTest ¶
func (tc TestContext) ForTest(t *testing.T) (PerTestContext, error)
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is a logr.Logger wrapper around t.Log, so that we can use it in the controller
func (*TestLogger) Enabled ¶
func (t *TestLogger) Enabled() bool
func (*TestLogger) Error ¶
func (t *TestLogger) Error(err error, msg string, keysAndValues ...interface{})
func (*TestLogger) Info ¶
func (t *TestLogger) Info(msg string, keysAndValues ...interface{})
func (*TestLogger) WithValues ¶
func (t *TestLogger) WithValues(keysAndValues ...interface{}) logr.Logger
type Verify ¶
type Verify struct {
// contains filtered or unexported fields
}
func (*Verify) AllDeleted ¶
AllDeleted verifies that all of the specified objects are deleted
func (*Verify) HasState ¶
func (e *Verify) HasState(ctx context.Context, obj client.Object, desiredState metav1.ConditionStatus, desiredSeverity conditions.ConditionSeverity) (bool, error)
HasState verifies that the provisioning state of the resource the target state.
type WaitCondition ¶
type WaitCondition bool
const ( WaitForCreation WaitCondition = true DoNotWait WaitCondition = false )
Source Files ¶
- arm_matcher.go
- authorizer.go
- azure_be_deleted_matcher.go
- azure_be_provisioned_matcher.go
- be_deleted_matcher.go
- be_provisioned_matcher.go
- counting_roundtripper.go
- error_translating_roundtripper.go
- kube_matcher.go
- kube_per_test_context.go
- kube_test_context.go
- kube_test_context_envtest.go
- kube_test_context_real.go
- resource_namer.go
- test_context.go
- test_logger.go
- verify.go
- wait.go