@@ -18,20 +18,25 @@ package v1
1818
1919import (
2020 "context"
21+ "strconv"
2122 "testing"
2223
2324 "github.com/google/go-cmp/cmp"
25+ "go.uber.org/zap"
2426 authv1 "k8s.io/api/authentication/v1"
2527 corev1 "k8s.io/api/core/v1"
2628 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2729
2830 "knative.dev/pkg/apis"
31+ logtesting "knative.dev/pkg/logging/testing"
2932 "knative.dev/pkg/ptr"
30-
3133 "knative.dev/serving/pkg/apis/config"
3234 "knative.dev/serving/pkg/apis/serving"
35+ cconfig "knative.dev/serving/pkg/reconciler/configuration/config"
3336)
3437
38+ const someTimeoutSeconds = 400
39+
3540func TestConfigurationDefaulting (t * testing.T ) {
3641 tests := []struct {
3742 name string
@@ -156,6 +161,53 @@ func TestConfigurationDefaulting(t *testing.T) {
156161 },
157162 },
158163 },
164+ }, {
165+ name : "run latest with identical timeout defaults" ,
166+ in : & Configuration {
167+ Spec : ConfigurationSpec {
168+ Template : RevisionTemplateSpec {
169+ Spec : RevisionSpec {
170+ PodSpec : corev1.PodSpec {
171+ EnableServiceLinks : ptr .Bool (true ),
172+ Containers : []corev1.Container {{
173+ Image : "busybox" ,
174+ }},
175+ },
176+ ContainerConcurrency : ptr .Int64 (config .DefaultContainerConcurrency ),
177+ },
178+ },
179+ },
180+ },
181+ want : & Configuration {
182+ Spec : ConfigurationSpec {
183+ Template : RevisionTemplateSpec {
184+ Spec : RevisionSpec {
185+ PodSpec : corev1.PodSpec {
186+ EnableServiceLinks : ptr .Bool (true ),
187+ Containers : []corev1.Container {{
188+ Name : config .DefaultUserContainerName ,
189+ Image : "busybox" ,
190+ Resources : defaultResources ,
191+ ReadinessProbe : defaultProbe ,
192+ }},
193+ },
194+ TimeoutSeconds : ptr .Int64 (someTimeoutSeconds ),
195+ ContainerConcurrency : ptr .Int64 (config .DefaultContainerConcurrency ),
196+ },
197+ },
198+ },
199+ },
200+ ctx : defaultConfigurationContextWithStore (logtesting .TestLogger (t ), corev1.ConfigMap {ObjectMeta : metav1.ObjectMeta {Name : config .FeaturesConfigName }},
201+ corev1.ConfigMap {
202+ ObjectMeta : metav1.ObjectMeta {
203+ Name : config .DefaultsConfigName ,
204+ },
205+ Data : map [string ]string {
206+ "revision-timeout-seconds" : strconv .Itoa (someTimeoutSeconds ),
207+ "revision-response-start-timeout-seconds" : strconv .Itoa (someTimeoutSeconds ),
208+ "revision-idle-timeout-seconds" : strconv .Itoa (someTimeoutSeconds ),
209+ },
210+ })(context .Background ()),
159211 }}
160212
161213 for _ , test := range tests {
@@ -328,3 +380,13 @@ func TestConfigurationUserInfo(t *testing.T) {
328380 })
329381 }
330382}
383+
384+ func defaultConfigurationContextWithStore (logger * zap.SugaredLogger , cms ... corev1.ConfigMap ) func (ctx context.Context ) context.Context {
385+ return func (ctx context.Context ) context.Context {
386+ s := cconfig .NewStore (logger )
387+ for _ , cm := range cms {
388+ s .OnConfigChanged (& cm )
389+ }
390+ return s .ToContext (ctx )
391+ }
392+ }
0 commit comments