diff --git a/go.mod b/go.mod index 7e48d99667a..8dbf13fdf39 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( knative.dev/hack v0.0.0-20230712131415-ddae80293c43 knative.dev/hack/schema v0.0.0-20230712131415-ddae80293c43 knative.dev/pkg v0.0.0-20231023150739-56bfe0dd9626 - knative.dev/reconciler-test v0.0.0-20231024065608-1f72fcb94bc1 + knative.dev/reconciler-test v0.0.0-20240118172306-00c4131cf6be sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 95817f58e8c..ce0d1b23392 100644 --- a/go.sum +++ b/go.sum @@ -945,8 +945,8 @@ knative.dev/hack/schema v0.0.0-20230712131415-ddae80293c43 h1:FqKKg9cUKc2I9bw27f knative.dev/hack/schema v0.0.0-20230712131415-ddae80293c43/go.mod h1:GeIb+PLd5mllawcpHEGF5J5fYTQrvgEO5liao8lUKUs= knative.dev/pkg v0.0.0-20231023150739-56bfe0dd9626 h1:qFE+UDBRg6cpF5LbA0sv1XK4XZ36Z7aTRCa+HcuxnNQ= knative.dev/pkg v0.0.0-20231023150739-56bfe0dd9626/go.mod h1:g+UCgSKQ2f15kHYu/V3CPtoKo5F1x/2Y1ot0NSK7gA0= -knative.dev/reconciler-test v0.0.0-20231024065608-1f72fcb94bc1 h1:4++EB9KPIz9c/EzENw7rJxK74WTdREviBSTywS+rfz8= -knative.dev/reconciler-test v0.0.0-20231024065608-1f72fcb94bc1/go.mod h1:Yw7Jkv+7PjDitG6CUkakWc/5SZa8Tm/sgXfaFy305Ng= +knative.dev/reconciler-test v0.0.0-20240118172306-00c4131cf6be h1:22QG+BjSX3LK5rE+ID3iy3OpJOyvGIE6F4FATnL/Zi8= +knative.dev/reconciler-test v0.0.0-20240118172306-00c4131cf6be/go.mod h1:Yw7Jkv+7PjDitG6CUkakWc/5SZa8Tm/sgXfaFy305Ng= pgregory.net/rapid v0.3.3 h1:jCjBsY4ln4Atz78QoBWxUEvAHaFyNDQg9+WU62aCn1U= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/flags.go b/vendor/knative.dev/reconciler-test/pkg/environment/flags.go index 59efc52e9a8..80fda986294 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/flags.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/flags.go @@ -21,8 +21,10 @@ import ( "fmt" "strconv" "strings" + "time" "knative.dev/reconciler-test/pkg/feature" + "knative.dev/reconciler-test/pkg/state" ) var ( @@ -34,6 +36,9 @@ var ( ipFilePath = new(string) teardownOnFail = new(bool) + + pollTimeout = new(time.Duration) + pollInterval = new(time.Duration) ) // InitFlags registers the requirement and state filter flags supported by the @@ -62,7 +67,8 @@ func InitFlags(fs *flag.FlagSet) { fs.StringVar(ipFilePath, "images.producer.file", "", "file path for file-based image producer") fs.StringVar(testNamespace, "environment.namespace", "", "Test namespace") - + fs.DurationVar(pollTimeout, "poll.timeout", state.DefaultPollTimeout, "Poll timeout") + fs.DurationVar(pollInterval, "poll.interval", state.DefaultPollInterval, "Poll interval") fs.BoolVar(teardownOnFail, "teardown.on.fail", false, "Set this flag to do teardown even if test fails.") } diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/magic.go b/vendor/knative.dev/reconciler-test/pkg/environment/magic.go index a1808d85601..a0400bcb224 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/magic.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/magic.go @@ -198,6 +198,7 @@ func (mr *MagicGlobalEnvironment) Environment(opts ...EnvOpts) (context.Context, } ctx := ContextWith(mr.c, env) + ctx = ContextWithPollTimings(ctx, *pollInterval, *pollTimeout) for _, opt := range opts { if nctx, err := opt(ctx, env); err != nil { diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/namespace.go b/vendor/knative.dev/reconciler-test/pkg/environment/namespace.go index 939f382eec3..a59bfa21731 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/namespace.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/namespace.go @@ -67,6 +67,10 @@ func (mr *MagicEnvironment) CreateNamespaceIfNeeded() error { ObjectMeta: metav1.ObjectMeta{ Name: mr.namespace, Annotations: map[string]string{}, + Labels: map[string]string{ + "app.kubernetes.io/component": "reconciler-test", + "app.kubernetes.io/name": "reconciler-test", + }, }, } diff --git a/vendor/knative.dev/reconciler-test/pkg/environment/timings.go b/vendor/knative.dev/reconciler-test/pkg/environment/timings.go index aac96e82813..bf4409b06c4 100644 --- a/vendor/knative.dev/reconciler-test/pkg/environment/timings.go +++ b/vendor/knative.dev/reconciler-test/pkg/environment/timings.go @@ -19,37 +19,26 @@ package environment import ( "context" "time" + + "knative.dev/reconciler-test/pkg/state" ) +// this has been moved to state pkg to break cycle between environment and feature package, +// keeping the consts here for backwards API compatibility const ( DefaultPollInterval = 3 * time.Second DefaultPollTimeout = 2 * time.Minute ) -type timingsKey struct{} -type timingsType struct { - interval time.Duration - timeout time.Duration -} - -// PollTimingsFromContext will get the previously set poll timing from context, -// or return the defaults if not found. -// - values from from context. -// - defaults. +// ContextWithPollTimings returns a context with poll timings set func ContextWithPollTimings(ctx context.Context, interval, timeout time.Duration) context.Context { - return context.WithValue(ctx, timingsKey{}, timingsType{ - interval: interval, - timeout: timeout, - }) + return state.ContextWithPollTimings(ctx, interval, timeout) } // PollTimingsFromContext will get the previously set poll timing from context, // or return the defaults if not found. -// - values from from context. +// - values from context. // - defaults. func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration) { - if t, ok := ctx.Value(timingsKey{}).(timingsType); ok { - return t.interval, t.timeout - } - return DefaultPollInterval, DefaultPollTimeout + return state.PollTimingsFromContext(ctx) } diff --git a/vendor/knative.dev/reconciler-test/pkg/eventshub/105-certificate-service.yaml b/vendor/knative.dev/reconciler-test/pkg/eventshub/105-certificate-service.yaml index c3e2fcc7932..96d8a868a26 100644 --- a/vendor/knative.dev/reconciler-test/pkg/eventshub/105-certificate-service.yaml +++ b/vendor/knative.dev/reconciler-test/pkg/eventshub/105-certificate-service.yaml @@ -48,6 +48,14 @@ spec: - 127.0.0.1 issuerRef: + {{ if .TLS_ISSUER_NAME }} + name: {{ .TLS_ISSUER_NAME }} + {{ else }} name: selfsigned-ca-issuer + {{ end }} + {{ if .TLS_ISSUER_KIND }} + kind: {{ .TLS_ISSUER_KIND }} + {{ else }} kind: Issuer + {{ end }} group: cert-manager.io diff --git a/vendor/knative.dev/reconciler-test/pkg/eventshub/options.go b/vendor/knative.dev/reconciler-test/pkg/eventshub/options.go index 6448bde960d..23b53b0741d 100644 --- a/vendor/knative.dev/reconciler-test/pkg/eventshub/options.go +++ b/vendor/knative.dev/reconciler-test/pkg/eventshub/options.go @@ -137,6 +137,13 @@ func StartSenderURLTLS(sink string, caCerts *string) EventsHubOption { }) } +func IssuerRef(kind, name string) EventsHubOption { + return compose( + envAdditive(tlsIssuerKind, kind), + envAdditive(tlsIssuerName, name), + ) +} + // --- Receiver options // EchoEvent is an option to let the eventshub reply with the received event diff --git a/vendor/knative.dev/reconciler-test/pkg/eventshub/resources.go b/vendor/knative.dev/reconciler-test/pkg/eventshub/resources.go index 59905c7b132..11f6646ff3e 100644 --- a/vendor/knative.dev/reconciler-test/pkg/eventshub/resources.go +++ b/vendor/knative.dev/reconciler-test/pkg/eventshub/resources.go @@ -114,6 +114,12 @@ func Install(name string, options ...EventsHubOption) feature.StepFn { "withEnforceTLS": isEnforceTLS, } + for k, v := range envs { + if strings.HasPrefix(k, "TLS_ISSUER") { + cfg[k] = v + } + } + // Install ServiceAccount, Role, RoleBinding eventshubrbac.Install(cfg)(ctx, t) diff --git a/vendor/knative.dev/reconciler-test/pkg/eventshub/utils.go b/vendor/knative.dev/reconciler-test/pkg/eventshub/utils.go index f8f376faf1a..fd2423686f5 100644 --- a/vendor/knative.dev/reconciler-test/pkg/eventshub/utils.go +++ b/vendor/knative.dev/reconciler-test/pkg/eventshub/utils.go @@ -38,7 +38,9 @@ const ( EventGeneratorsEnv = "EVENT_GENERATORS" EventLogsEnv = "EVENT_LOGS" - EnforceTLS = "ENFORCE_TLS" + EnforceTLS = "ENFORCE_TLS" + tlsIssuerKind = "TLS_ISSUER_KIND" + tlsIssuerName = "TLS_ISSUER_NAME" ) func ParseHeaders(serializedHeaders string) http.Header { diff --git a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go index 4113bc3d0d4..0d454c51723 100644 --- a/vendor/knative.dev/reconciler-test/pkg/feature/feature.go +++ b/vendor/knative.dev/reconciler-test/pkg/feature/feature.go @@ -23,7 +23,6 @@ import ( "runtime" "strings" "sync" - "time" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -32,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "knative.dev/pkg/apis" "knative.dev/pkg/injection/clients/dynamicclient" - "knative.dev/reconciler-test/pkg/state" ) @@ -229,7 +227,8 @@ func DeleteResources(ctx context.Context, t T, refs []corev1.ObjectReference) er var lastResource corev1.ObjectReference // One still present resource - err := wait.Poll(time.Second, 4*time.Minute, func() (bool, error) { + interval, timeout := state.PollTimingsFromContext(ctx) + err := wait.Poll(interval, timeout, func() (bool, error) { for _, ref := range refs { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { diff --git a/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go b/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go index 7680102cd80..9dc60a4da54 100644 --- a/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go +++ b/vendor/knative.dev/reconciler-test/pkg/milestone/emitter_tracing.go @@ -49,7 +49,6 @@ func NewTracingGatherer(ctx context.Context, namespace string, zipkinNamespace s kubeclient.Get(ctx), logging.FromContext(ctx).Infof, zipkinNamespace) - zipkin.ZipkinTracingEnabled = true return &tracingEmitter{ctx: ctx, namespace: namespace, t: t}, err } diff --git a/vendor/knative.dev/reconciler-test/pkg/resources/secret/secret.go b/vendor/knative.dev/reconciler-test/pkg/resources/secret/secret.go index 55ef0fb0fa4..0fb5009db77 100644 --- a/vendor/knative.dev/reconciler-test/pkg/resources/secret/secret.go +++ b/vendor/knative.dev/reconciler-test/pkg/resources/secret/secret.go @@ -53,6 +53,12 @@ func Install(name string, options ...manifest.CfgFn) feature.StepFn { type Assertion func(s *corev1.Secret) error func IsPresent(name string, assertions ...Assertion) feature.StepFn { + return func(ctx context.Context, t feature.T) { + IsPresentInNamespace(name, environment.FromContext(ctx).Namespace(), assertions...)(ctx, t) + } +} + +func IsPresentInNamespace(name string, ns string, assertions ...Assertion) feature.StepFn { return func(ctx context.Context, t feature.T) { ns := environment.FromContext(ctx).Namespace() interval, timeout := environment.PollTimingsFromContext(ctx) diff --git a/vendor/knative.dev/reconciler-test/pkg/state/timings.go b/vendor/knative.dev/reconciler-test/pkg/state/timings.go new file mode 100644 index 00000000000..5a79de9e102 --- /dev/null +++ b/vendor/knative.dev/reconciler-test/pkg/state/timings.go @@ -0,0 +1,52 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package state + +import ( + "context" + "time" +) + +const ( + DefaultPollInterval = 3 * time.Second + DefaultPollTimeout = 2 * time.Minute +) + +type timingsKey struct{} +type timingsType struct { + interval time.Duration + timeout time.Duration +} + +// ContextWithPollTimings returns a context with poll timings set +func ContextWithPollTimings(ctx context.Context, interval, timeout time.Duration) context.Context { + return context.WithValue(ctx, timingsKey{}, timingsType{ + interval: interval, + timeout: timeout, + }) +} + +// PollTimingsFromContext will get the previously set poll timing from context, +// or return the defaults if not found. +// - values from context. +// - defaults. +func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration) { + if t, ok := ctx.Value(timingsKey{}).(timingsType); ok { + return t.interval, t.timeout + } + panic("no poll timings found in context") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 475d60d72a1..28e0e4c1e21 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1311,7 +1311,7 @@ knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/conversion knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/reconciler-test v0.0.0-20231024065608-1f72fcb94bc1 +# knative.dev/reconciler-test v0.0.0-20240118172306-00c4131cf6be ## explicit; go 1.18 knative.dev/reconciler-test/cmd/eventshub knative.dev/reconciler-test/pkg/environment