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)