Skip to content

Commit

Permalink
Add setup function (DependencyDoesNotExist)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul-Kumar-prog committed May 30, 2024
1 parent 2a11bb8 commit d5104e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/rekt/features/trigger/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TriggerDependencyAnnotation() *feature.Feature {
// trigger won't go ready until after the pingsource exists, because of the dependency annotation
f.Requirement("trigger goes ready", trigger.IsReady(triggerName))

f.Setup("Trigger not ready with reason DependencyDoesNotExist", trigger.IsDependencyDoesNotExist(triggerName))

f.Requirement("install pingsource", func(ctx context.Context, t feature.T) {
brokeruri, err := broker.Address(ctx, brokerName)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions test/rekt/resources/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ func IsReady(name string, timing ...time.Duration) feature.StepFn {
return k8s.IsReady(GVR(), name, timing...)
}

// IsDependencyDoesNotExist tests to see if a Trigger not become ready with Dependency.
func IsDependencyDoesNotExist(name string, timing ...time.Duration) feature.StepFn {
return k8s.IsDependencyDoesNotExist(GVR(), name, timing...)
}

func WithNewFilters(filters []eventingv1.SubscriptionsAPIFilter) manifest.CfgFn {
jsonBytes, err := json.Marshal(filters)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions vendor/knative.dev/reconciler-test/pkg/k8s/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ func IsNotReady(gvr schema.GroupVersionResource, name string, timing ...time.Dur
}
}

// IsDependencyDoesNotExist return a reusable feature.StepFn to assert if a dependency in not ready.
// within the time given. Timing is optional but if provided is [interval, timeout].
func IsDependencyDoesNotExist(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn {
return func(ctx context.Context, t feature.T) {
interval, timeout := PollTimings(ctx, timing)
env := environment.FromContext(ctx)
if err := WaitForResourceNotReady(ctx, t, env.Namespace(), name, gvr, interval, timeout); err != nil {
t.Error(gvr, "DependencyDoesNotExist,", err)
}
}
}

// IsAddressable tests to see if a resource becomes Addressable within the time
// given. Timing is optional but if provided is [interval, timeout].
func IsAddressable(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn {
Expand Down

0 comments on commit d5104e6

Please sign in to comment.