-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathstream_test.go
79 lines (58 loc) · 1.8 KB
/
stream_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package cloudfoundryreceiver
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.uber.org/zap"
)
// Ensure stream create works as expected
func TestValidMetricsStream(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedClientConfig,
cfg.UAA.Username,
string(cfg.UAA.Password))
require.NoError(t, err)
require.NotNil(t, uaa)
streamFactory, streamErr := newEnvelopeStreamFactory(
context.Background(),
componenttest.NewNopTelemetrySettings(),
uaa,
cfg.RLPGateway.ClientConfig,
componenttest.NewNopHost())
require.NoError(t, streamErr)
require.NotNil(t, streamFactory)
innerCtx, cancel := context.WithCancel(context.Background())
envelopeStream := streamFactory.CreateMetricsStream(innerCtx, cfg.RLPGateway.ShardID)
require.NotNil(t, envelopeStream)
cancel()
}
// Ensure stream create works as expected
func TestValidLogsStream(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedClientConfig,
cfg.UAA.Username,
string(cfg.UAA.Password))
require.NoError(t, err)
require.NotNil(t, uaa)
streamFactory, streamErr := newEnvelopeStreamFactory(
context.Background(),
componenttest.NewNopTelemetrySettings(),
uaa,
cfg.RLPGateway.ClientConfig,
componenttest.NewNopHost())
require.NoError(t, streamErr)
require.NotNil(t, streamFactory)
innerCtx, cancel := context.WithCancel(context.Background())
envelopeStream := streamFactory.CreateLogsStream(innerCtx, cfg.RLPGateway.ShardID)
require.NotNil(t, envelopeStream)
cancel()
}