From 4ed7777b892835c8955a81752924f36739935f28 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Santos Date: Fri, 15 Nov 2024 17:54:41 +0000 Subject: [PATCH] Fix imports --- .../clusterchecks/dispatcher_isolate_test.go | 8 ++-- .../clusterchecks/dispatcher_main.go | 2 +- .../dispatcher_rebalance_test.go | 10 ++--- .../clusterchecks/dispatcher_test.go | 40 +++++++++---------- pkg/clusteragent/clusterchecks/handler.go | 2 +- .../clusterchecks/handler_test.go | 4 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pkg/clusteragent/clusterchecks/dispatcher_isolate_test.go b/pkg/clusteragent/clusterchecks/dispatcher_isolate_test.go index 073aed42c8d55..bd2cfbb276f83 100644 --- a/pkg/clusteragent/clusterchecks/dispatcher_isolate_test.go +++ b/pkg/clusteragent/clusterchecks/dispatcher_isolate_test.go @@ -13,14 +13,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" - "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl" + "github.com/DataDog/datadog-agent/comp/core/tagger/mock" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" ) func TestIsolateCheckSuccessful(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) testDispatcher.store.nodes["A"] = newNodeStore("A", "") testDispatcher.store.nodes["A"].workers = pkgconfigsetup.DefaultNumWorkers @@ -101,7 +101,7 @@ func TestIsolateCheckSuccessful(t *testing.T) { } func TestIsolateNonExistentCheckFails(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) testDispatcher.store.nodes["A"] = newNodeStore("A", "") testDispatcher.store.nodes["A"].workers = pkgconfigsetup.DefaultNumWorkers @@ -180,7 +180,7 @@ func TestIsolateNonExistentCheckFails(t *testing.T) { } func TestIsolateCheckOnlyOneRunnerFails(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) testDispatcher.store.nodes["A"] = newNodeStore("A", "") testDispatcher.store.nodes["A"].workers = pkgconfigsetup.DefaultNumWorkers diff --git a/pkg/clusteragent/clusterchecks/dispatcher_main.go b/pkg/clusteragent/clusterchecks/dispatcher_main.go index bd1fbcd5ccd65..6f1a894f4e354 100644 --- a/pkg/clusteragent/clusterchecks/dispatcher_main.go +++ b/pkg/clusteragent/clusterchecks/dispatcher_main.go @@ -13,7 +13,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" - "github.com/DataDog/datadog-agent/comp/core/tagger" + tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" "github.com/DataDog/datadog-agent/comp/core/tagger/types" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" "github.com/DataDog/datadog-agent/pkg/status/health" diff --git a/pkg/clusteragent/clusterchecks/dispatcher_rebalance_test.go b/pkg/clusteragent/clusterchecks/dispatcher_rebalance_test.go index 5e7d9c9ddfc4f..2c073bab0670b 100644 --- a/pkg/clusteragent/clusterchecks/dispatcher_rebalance_test.go +++ b/pkg/clusteragent/clusterchecks/dispatcher_rebalance_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" - "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl" + "github.com/DataDog/datadog-agent/comp/core/tagger/mock" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" @@ -1378,7 +1378,7 @@ func TestRebalance(t *testing.T) { checkMetricSamplesWeight = originalMetricSamplesWeight }() - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // prepare store @@ -1435,7 +1435,7 @@ func TestMoveCheck(t *testing.T) { }, } { t.Run(fmt.Sprintf("case %d", i), func(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // setup check id @@ -1480,7 +1480,7 @@ func TestCalculateAvg(t *testing.T) { checkMetricSamplesWeight = originalMetricSamplesWeight }() - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) // The busyness of this node is 3 (1 + 2) @@ -1522,7 +1522,7 @@ func TestRebalanceUsingUtilization(t *testing.T) { // other tests specific for the checksDistribution struct that test more // complex scenarios. - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) testDispatcher.store.active = true diff --git a/pkg/clusteragent/clusterchecks/dispatcher_test.go b/pkg/clusteragent/clusterchecks/dispatcher_test.go index 15df20323f4f9..ff348a025ed58 100644 --- a/pkg/clusteragent/clusterchecks/dispatcher_test.go +++ b/pkg/clusteragent/clusterchecks/dispatcher_test.go @@ -16,7 +16,7 @@ import ( "gopkg.in/yaml.v2" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" - "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl" + "github.com/DataDog/datadog-agent/comp/core/tagger/mock" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" "github.com/DataDog/datadog-agent/pkg/config/env" configmock "github.com/DataDog/datadog-agent/pkg/config/mock" @@ -50,7 +50,7 @@ func extractCheckNames(configs []integration.Config) []string { } func TestScheduleUnschedule(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) stored, err := dispatcher.getAllConfigs() assert.NoError(t, err) @@ -82,7 +82,7 @@ func TestScheduleUnschedule(t *testing.T) { } func TestScheduleUnscheduleEndpoints(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config1 := generateIntegration("cluster-check") @@ -99,7 +99,7 @@ func TestScheduleUnscheduleEndpoints(t *testing.T) { } func TestExcludeEndpoint(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config1 := generateEndpointsIntegration("endpoints-check1", "node1", true) @@ -113,7 +113,7 @@ func TestExcludeEndpoint(t *testing.T) { } func TestScheduleReschedule(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config := generateIntegration("cluster-check") @@ -146,7 +146,7 @@ func TestScheduleReschedule(t *testing.T) { } func TestScheduleRescheduleEndpoints(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config := generateEndpointsIntegration("endpoints-check1", "node1", false) @@ -178,7 +178,7 @@ func TestScheduleRescheduleEndpoints(t *testing.T) { } func TestDescheduleRescheduleSameNode(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config := generateIntegration("cluster-check") @@ -212,7 +212,7 @@ func TestDescheduleRescheduleSameNode(t *testing.T) { } func TestProcessNodeStatus(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) status1 := types.NodeStatus{LastChange: 10} @@ -254,7 +254,7 @@ func TestProcessNodeStatus(t *testing.T) { } func TestGetNodeWithLessChecks(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // No node registered -> empty string @@ -279,7 +279,7 @@ func TestGetNodeWithLessChecks(t *testing.T) { } func TestExpireNodes(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // Node with no status (bug ?), handled by expiration @@ -312,7 +312,7 @@ func TestExpireNodes(t *testing.T) { func TestRescheduleDanglingFromExpiredNodes(t *testing.T) { // This test case can represent a rollout of the cluster check workers - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // Register a node with a correct status & schedule a Check @@ -363,7 +363,7 @@ func TestRescheduleDanglingFromExpiredNodes(t *testing.T) { } func TestDispatchFourConfigsTwoNodes(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // Register two nodes @@ -401,7 +401,7 @@ func TestDispatchFourConfigsTwoNodes(t *testing.T) { } func TestDanglingConfig(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config := integration.Config{ Name: "cluster-check", @@ -429,7 +429,7 @@ func TestDanglingConfig(t *testing.T) { } func TestUnscheduleDanglingConfig(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) testDispatcher := newDispatcher(fakeTagger) testConfig := integration.Config{ @@ -460,7 +460,7 @@ func TestUnscheduleDanglingConfig(t *testing.T) { } func TestReset(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) config := generateIntegration("cluster-check") @@ -495,7 +495,7 @@ func TestPatchConfiguration(t *testing.T) { } initialDigest := checkConfig.Digest() - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) mockConfig := configmock.New(t) mockConfig.SetWithoutSource("cluster_name", "testing") clustername.ResetClusterName() @@ -533,7 +533,7 @@ func TestPatchEndpointsConfiguration(t *testing.T) { LogsConfig: integration.Data("[{\"service\":\"any_service\",\"source\":\"any_source\"}]"), } - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) mockConfig := configmock.New(t) mockConfig.SetWithoutSource("cluster_name", "testing") clustername.ResetClusterName() @@ -572,7 +572,7 @@ func TestExtraTags(t *testing.T) { {[]string{"one", "two"}, "mycluster", "custom_name", []string{"one", "two", "custom_name:mycluster", "kube_cluster_name:mycluster"}}, } { t.Run("", func(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) mockConfig := configmock.New(t) fakeTagger.SetGlobalTags(tc.extraTagsConfig, []string{}, []string{}, []string{}) mockConfig.SetWithoutSource("cluster_name", tc.clusterNameConfig) @@ -586,7 +586,7 @@ func TestExtraTags(t *testing.T) { } func TestGetAllEndpointsCheckConfigs(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) dispatcher := newDispatcher(fakeTagger) // Register configs to different nodes @@ -661,7 +661,7 @@ func (d *dummyClientStruct) GetRunnerWorkers(IP string) (types.Workers, error) { } func TestUpdateRunnersStats(t *testing.T) { - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := mock.SetupFakeTagger(t) mockConfig := configmock.New(t) mockConfig.SetWithoutSource("cluster_checks.rebalance_with_utilization", true) diff --git a/pkg/clusteragent/clusterchecks/handler.go b/pkg/clusteragent/clusterchecks/handler.go index 14f1e0654f362..27edab2ff6d43 100644 --- a/pkg/clusteragent/clusterchecks/handler.go +++ b/pkg/clusteragent/clusterchecks/handler.go @@ -14,7 +14,7 @@ import ( "time" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/scheduler" - "github.com/DataDog/datadog-agent/comp/core/tagger" + tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" "github.com/DataDog/datadog-agent/pkg/clusteragent/api" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" diff --git a/pkg/clusteragent/clusterchecks/handler_test.go b/pkg/clusteragent/clusterchecks/handler_test.go index 1debf05d7724c..c1b0c074e6aaf 100644 --- a/pkg/clusteragent/clusterchecks/handler_test.go +++ b/pkg/clusteragent/clusterchecks/handler_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/DataDog/datadog-agent/comp/core/autodiscovery/integration" - "github.com/DataDog/datadog-agent/comp/core/tagger/taggerimpl" + taggerMock "github.com/DataDog/datadog-agent/comp/core/tagger/mock" "github.com/DataDog/datadog-agent/pkg/clusteragent/api" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" "github.com/DataDog/datadog-agent/pkg/util/testutil" @@ -139,7 +139,7 @@ func TestUpdateLeaderIP(t *testing.T) { func TestHandlerRun(t *testing.T) { dummyT := &testing.T{} ac := &mockedPluggableAutoConfig{} - fakeTagger := taggerimpl.SetupFakeTagger(t) + fakeTagger := taggerMock.SetupFakeTagger(t) ac.Test(t) le := &fakeLeaderEngine{ err: errors.New("failing"),