| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package e2e |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
"time" |
| 9 |
|
| 10 |
"github.com/stretchr/testify/assert" |
| 11 |
"github.com/stretchr/testify/require" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/config/configgrpc" |
| 14 |
"go.opentelemetry.io/collector/config/confignet" |
| 15 |
"go.opentelemetry.io/collector/confmap" |
| 16 |
) |
| 17 |
|
| 18 |
func TestConfmapMarshalConfigGRPC(t *testing.T) { |
| 19 |
keepaliveClientConfig := map[string]any{ |
| 20 |
"time": time.Second * 10, |
| 21 |
"timeout": time.Second * 10, |
| 22 |
} |
| 23 |
keepaliveServerConfig := map[string]any{ |
| 24 |
"server_parameters": map[string]any{}, |
| 25 |
"enforcement_policy": map[string]any{}, |
| 26 |
} |
| 27 |
|
| 28 |
conf := confmap.New() |
| 29 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultClientConfig())) |
| 30 |
assert.Equal(t, map[string]any{ |
| 31 |
"keepalive": keepaliveClientConfig, |
| 32 |
"balancer_name": "round_robin", |
| 33 |
}, conf.ToStringMap()) |
| 34 |
|
| 35 |
conf = confmap.New() |
| 36 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultKeepaliveClientConfig())) |
| 37 |
assert.Equal(t, keepaliveClientConfig, conf.ToStringMap()) |
| 38 |
|
| 39 |
conf = confmap.New() |
| 40 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultKeepaliveEnforcementPolicy())) |
| 41 |
assert.Equal(t, map[string]any{}, conf.ToStringMap()) |
| 42 |
|
| 43 |
conf = confmap.New() |
| 44 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultKeepaliveServerConfig())) |
| 45 |
assert.Equal(t, keepaliveServerConfig, conf.ToStringMap()) |
| 46 |
|
| 47 |
conf = confmap.New() |
| 48 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultKeepaliveServerParameters())) |
| 49 |
assert.Equal(t, map[string]any{}, conf.ToStringMap()) |
| 50 |
|
| 51 |
conf = confmap.New() |
| 52 |
require.NoError(t, conf.Marshal(configgrpc.NewDefaultServerConfig())) |
| 53 |
assert.Equal(t, map[string]any{ |
| 54 |
"keepalive": keepaliveServerConfig, |
| 55 |
"transport": confignet.TransportType("tcp"), |
| 56 |
}, conf.ToStringMap()) |
| 57 |
} |