From 11e7d5af87c5d74f4759d726385bb06d20d31e67 Mon Sep 17 00:00:00 2001 From: Jaganathan P <156800415+jagan2221@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:49:51 +0530 Subject: [PATCH] Update provider_test.go --- .../opampprovider/provider_test.go | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/pkg/configprovider/opampprovider/provider_test.go b/pkg/configprovider/opampprovider/provider_test.go index d43c566015..f49df7182b 100644 --- a/pkg/configprovider/opampprovider/provider_test.go +++ b/pkg/configprovider/opampprovider/provider_test.go @@ -148,7 +148,7 @@ func TestRemotelyManagedFlowDisabled(t *testing.T) { "processor": "someprocessor", "extensions::opamp::remote_configuration_directory": "../globprovider/testdata/mergefunc", "extensions::opamp::endpoint": "wss://example.com/v1/opamp", - "extensions::opamp::new_configmergeflow_disabled": false, + "extensions::opamp::new_configmergeflow_disabled": true, }) want := exp.ToStringMap() if diff := cmp.Diff(want, got); diff != "" { @@ -156,6 +156,40 @@ func TestRemotelyManagedFlowDisabled(t *testing.T) { } } +func TestRemotelyManagedFlowEnabled(t *testing.T) { + p := NewWithSettings(confmap.ProviderSettings{}) + defer func() { + if err := p.Shutdown(context.Background()); err != nil { + t.Error(err) + } + }() + + configPath := "opamp:" + absolutePath(t, filepath.Join("testdata", "configMergeEnabled.yaml")) + t.Logf("loading opamp config file: %s", configPath) + + ret, err := p.Retrieve(context.Background(), configPath, nil) + if err != nil { + t.Fatal(err) + } + conf, err := ret.AsConf() + if err != nil { + t.Fatal(err) + } + got := conf.ToStringMap() + exp := confmap.NewFromStringMap(map[string]any{ + "extensions::sumologic::childKey": "value", + "extensions::sumologic::collector_fields::zone": "eu", + "processor": "someprocessor", + "extensions::opamp::remote_configuration_directory": "../globprovider/testdata/mergefunc", + "extensions::opamp::endpoint": "wss://example.com/v1/opamp", + }) + want := exp.ToStringMap() + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Retrieve() mismatch (-want +got):\n%s", diff) + } +} + + func absolutePath(t *testing.T, relativePath string) string { t.Helper() pth, err := filepath.Abs(relativePath)