From 44898bcc4ba5305c34294537a1c2590c1ad88151 Mon Sep 17 00:00:00 2001 From: SAGNIK PAL Date: Fri, 10 Jan 2025 01:55:40 +0530 Subject: [PATCH 1/2] Make count of config pipeline dynamic Signed-off-by: SAGNIK PAL --- internal/config/crd_config_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/config/crd_config_test.go b/internal/config/crd_config_test.go index 57609b7d..e3517045 100644 --- a/internal/config/crd_config_test.go +++ b/internal/config/crd_config_test.go @@ -99,18 +99,22 @@ func TestBlackListResources(t *testing.T) { expectedBlackList := []string{"namespaces.v1.", "pods.v1."} if !reflect.DeepEqual(meshsyncConfig.BlackList, expectedBlackList) { - t.Error("WhiteListed resources not equal") + t.Error("BlackListed resources not equal") } // now we assertain the global and local pipelines have been correctly configured // excempted global pipelines: namespaces // excempted local pipelines: pods, replicasets - if len(meshsyncConfig.Pipelines["global"]) != 5 { + // counting expected pipelines after blacklist + expectedGlobalCount := len(meshsyncConfig.Pipelines["global"]) - 1 //excluding namespaces + expectedLocalCount := len(meshsyncConfig.Pipelines["local"]) - 2 //excluding pods, replicasets + + if len(meshsyncConfig.Pipelines["global"]) != expectedGlobalCount { t.Error("global pipelines not well configured expected 5") } - if len(meshsyncConfig.Pipelines["local"]) != 14 { - t.Error("global pipelines not well configured expected 15") + if len(meshsyncConfig.Pipelines["local"]) != expectedLocalCount { + t.Error("local pipelines not well configured expected 15") } } From 2da3d19f6bcbc68289d71e84db62c19323bc864d Mon Sep 17 00:00:00 2001 From: SAGNIK PAL Date: Fri, 10 Jan 2025 02:01:21 +0530 Subject: [PATCH 2/2] Remove hardcoded static values Signed-off-by: SAGNIK PAL --- internal/config/crd_config_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/config/crd_config_test.go b/internal/config/crd_config_test.go index e3517045..14002f09 100644 --- a/internal/config/crd_config_test.go +++ b/internal/config/crd_config_test.go @@ -111,10 +111,10 @@ func TestBlackListResources(t *testing.T) { expectedLocalCount := len(meshsyncConfig.Pipelines["local"]) - 2 //excluding pods, replicasets if len(meshsyncConfig.Pipelines["global"]) != expectedGlobalCount { - t.Error("global pipelines not well configured expected 5") + t.Errorf("global pipelines not well configured expected %d", expectedGlobalCount) } if len(meshsyncConfig.Pipelines["local"]) != expectedLocalCount { - t.Error("local pipelines not well configured expected 15") + t.Errorf("local pipelines not well configured expected %d", expectedLocalCount) } }