From dc4de02df3ddc426edff8b524cbc633b35fb7927 Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Mon, 28 Mar 2022 19:57:17 +0900 Subject: [PATCH] Fix unit test --- pkg/reconciler/autoscaling/config/store_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/reconciler/autoscaling/config/store_test.go b/pkg/reconciler/autoscaling/config/store_test.go index 4afa9f2e86ae..f9761be177f6 100644 --- a/pkg/reconciler/autoscaling/config/store_test.go +++ b/pkg/reconciler/autoscaling/config/store_test.go @@ -24,6 +24,7 @@ import ( "github.com/google/go-cmp/cmp" logtesting "knative.dev/pkg/logging/testing" + network "knative.dev/networking/pkg" . "knative.dev/pkg/configmap/testing" autoscalerconfig "knative.dev/serving/pkg/autoscaler/config" "knative.dev/serving/pkg/deployment" @@ -34,8 +35,10 @@ func TestStoreLoadWithContext(t *testing.T) { autoscalerConfig := ConfigMapFromTestFile(t, autoscalerconfig.ConfigName) depConfig := ConfigMapFromTestFile(t, deployment.ConfigName, deployment.DeprecatedQueueSidecarImageKey) + netConfig := ConfigMapFromTestFile(t, network.ConfigName) store.OnConfigChanged(autoscalerConfig) store.OnConfigChanged(depConfig) + store.OnConfigChanged(netConfig) config := FromContext(store.ToContext(context.Background())) wantAS, _ := autoscalerconfig.NewConfigFromConfigMap(autoscalerConfig) @@ -46,6 +49,10 @@ func TestStoreLoadWithContext(t *testing.T) { if !cmp.Equal(wantD, config.Deployment) { t.Error("Deployment ConfigMap mismatch (-want, +got):", cmp.Diff(wantD, config.Deployment)) } + wantNet, _ := network.NewConfigFromConfigMap(netConfig) + if !cmp.Equal(wantNet, config.Network) { + t.Error("Network ConfigMap mismatch (-want, +got):", cmp.Diff(wantNet, config.Network)) + } } func TestStoreImmutableConfig(t *testing.T) { @@ -54,16 +61,22 @@ func TestStoreImmutableConfig(t *testing.T) { store.OnConfigChanged(ConfigMapFromTestFile(t, autoscalerconfig.ConfigName)) store.OnConfigChanged(ConfigMapFromTestFile(t, deployment.ConfigName, deployment.DeprecatedQueueSidecarImageKey)) + store.OnConfigChanged(ConfigMapFromTestFile(t, network.ConfigName)) config := store.Load() config.Autoscaler.MaxScaleUpRate = 100.0 config.Deployment.ProgressDeadline = 3 * time.Minute + config.Network.ActivatorCA = "activator-ca" + config.Network.ActivatorSAN = "activator-san" newConfig := store.Load() if newConfig.Autoscaler.MaxScaleUpRate == 100.0 { t.Error("Autoscaler config is not immuable") } if newConfig.Deployment.ProgressDeadline == 3*time.Minute { - t.Error("Autoscaler config is not immuable") + t.Error("Deployment config is not immuable") + } + if newConfig.Network.ActivatorCA == "activator-ca" || newConfig.Network.ActivatorSAN == "activator-san" { + t.Error("Network config is not immuable") } }