9
9
"github.com/stretchr/testify/assert"
10
10
"github.com/stretchr/testify/require"
11
11
"go.opentelemetry.io/collector/component"
12
+ "go.opentelemetry.io/collector/config/configgrpc"
12
13
"go.opentelemetry.io/collector/confmap/confmaptest"
13
14
14
15
"github.com/open-telemetry/opentelemetry-lambda/collector/extension/solarwindsapmsettingsextension/internal/metadata"
@@ -28,183 +29,229 @@ func TestLoadConfig(t *testing.T) {
28
29
{
29
30
id : component .NewIDWithName (metadata .Type , "1" ),
30
31
expected : & Config {
31
- Endpoint : "apm.collector.na-01.cloud.solarwinds.com:443" ,
32
+ ClientConfig : configgrpc.ClientConfig {
33
+ Endpoint : "apm.collector.na-01.cloud.solarwinds.com:443" ,
34
+ },
32
35
Key : "something:name" ,
33
36
Interval : time .Duration (10 ) * time .Second ,
34
37
},
35
38
},
36
39
{
37
40
id : component .NewIDWithName (metadata .Type , "2" ),
38
41
expected : & Config {
39
- Endpoint : "apm.collector.na-02.cloud.solarwinds.com:443" ,
42
+ ClientConfig : configgrpc.ClientConfig {
43
+ Endpoint : "apm.collector.na-02.cloud.solarwinds.com:443" ,
44
+ },
40
45
Key : "something:name" ,
41
46
Interval : time .Duration (10 ) * time .Second ,
42
47
},
43
48
},
44
49
{
45
50
id : component .NewIDWithName (metadata .Type , "3" ),
46
51
expected : & Config {
47
- Endpoint : "apm.collector.eu-01.cloud.solarwinds.com:443" ,
52
+ ClientConfig : configgrpc.ClientConfig {
53
+ Endpoint : "apm.collector.eu-01.cloud.solarwinds.com:443" ,
54
+ },
48
55
Key : "something:name" ,
49
56
Interval : time .Duration (10 ) * time .Second ,
50
57
},
51
58
},
52
59
{
53
60
id : component .NewIDWithName (metadata .Type , "4" ),
54
61
expected : & Config {
55
- Endpoint : "apm.collector.apj-01.cloud.solarwinds.com:443" ,
62
+ ClientConfig : configgrpc.ClientConfig {
63
+ Endpoint : "apm.collector.apj-01.cloud.solarwinds.com:443" ,
64
+ },
56
65
Key : "something:name" ,
57
66
Interval : time .Duration (10 ) * time .Second ,
58
67
},
59
68
},
60
69
{
61
70
id : component .NewIDWithName (metadata .Type , "5" ),
62
71
expected : & Config {
63
- Endpoint : "apm.collector.na-01.st-ssp.solarwinds.com:443" ,
72
+ ClientConfig : configgrpc.ClientConfig {
73
+ Endpoint : "apm.collector.na-01.st-ssp.solarwinds.com:443" ,
74
+ },
64
75
Key : "something:name" ,
65
76
Interval : time .Duration (10 ) * time .Second ,
66
77
},
67
78
},
68
79
{
69
80
id : component .NewIDWithName (metadata .Type , "6" ),
70
81
expected : & Config {
71
- Endpoint : "apm.collector.na-01.dev-ssp.solarwinds.com:443" ,
82
+ ClientConfig : configgrpc.ClientConfig {
83
+ Endpoint : "apm.collector.na-01.dev-ssp.solarwinds.com:443" ,
84
+ },
72
85
Key : "something:name" ,
73
86
Interval : time .Duration (10 ) * time .Second ,
74
87
},
75
88
},
76
89
{
77
90
id : component .NewIDWithName (metadata .Type , "7" ),
78
91
expected : & Config {
79
- Endpoint : DefaultEndpoint ,
92
+ ClientConfig : configgrpc.ClientConfig {
93
+ Endpoint : DefaultEndpoint ,
94
+ },
80
95
Key : "something:name" ,
81
96
Interval : time .Duration (10 ) * time .Second ,
82
97
},
83
98
},
84
99
{
85
100
id : component .NewIDWithName (metadata .Type , "8" ),
86
101
expected : & Config {
87
- Endpoint : DefaultEndpoint ,
102
+ ClientConfig : configgrpc.ClientConfig {
103
+ Endpoint : DefaultEndpoint ,
104
+ },
88
105
Key : "something:name" ,
89
106
Interval : time .Duration (10 ) * time .Second ,
90
107
},
91
108
},
92
109
{
93
110
id : component .NewIDWithName (metadata .Type , "9" ),
94
111
expected : & Config {
95
- Endpoint : DefaultEndpoint ,
112
+ ClientConfig : configgrpc.ClientConfig {
113
+ Endpoint : DefaultEndpoint ,
114
+ },
96
115
Key : "something:name" ,
97
116
Interval : time .Duration (10 ) * time .Second ,
98
117
},
99
118
},
100
119
{
101
120
id : component .NewIDWithName (metadata .Type , "10" ),
102
121
expected : & Config {
103
- Endpoint : DefaultEndpoint ,
122
+ ClientConfig : configgrpc.ClientConfig {
123
+ Endpoint : DefaultEndpoint ,
124
+ },
104
125
Key : "something:name" ,
105
126
Interval : time .Duration (10 ) * time .Second ,
106
127
},
107
128
},
108
129
{
109
130
id : component .NewIDWithName (metadata .Type , "11" ),
110
131
expected : & Config {
111
- Endpoint : DefaultEndpoint ,
132
+ ClientConfig : configgrpc.ClientConfig {
133
+ Endpoint : DefaultEndpoint ,
134
+ },
112
135
Key : "something:name" ,
113
136
Interval : time .Duration (10 ) * time .Second ,
114
137
},
115
138
},
116
139
{
117
140
id : component .NewIDWithName (metadata .Type , "12" ),
118
141
expected : & Config {
119
- Endpoint : DefaultEndpoint ,
142
+ ClientConfig : configgrpc.ClientConfig {
143
+ Endpoint : DefaultEndpoint ,
144
+ },
120
145
Key : "something:name" ,
121
146
Interval : time .Duration (10 ) * time .Second ,
122
147
},
123
148
},
124
149
{
125
150
id : component .NewIDWithName (metadata .Type , "13" ),
126
151
expected : & Config {
127
- Endpoint : DefaultEndpoint ,
152
+ ClientConfig : configgrpc.ClientConfig {
153
+ Endpoint : DefaultEndpoint ,
154
+ },
128
155
Key : "something:name" ,
129
156
Interval : time .Duration (10 ) * time .Second ,
130
157
},
131
158
},
132
159
{
133
160
id : component .NewIDWithName (metadata .Type , "14" ),
134
161
expected : & Config {
135
- Endpoint : DefaultEndpoint ,
162
+ ClientConfig : configgrpc.ClientConfig {
163
+ Endpoint : DefaultEndpoint ,
164
+ },
136
165
Key : "something:name" ,
137
166
Interval : time .Duration (10 ) * time .Second ,
138
167
},
139
168
},
140
169
{
141
170
id : component .NewIDWithName (metadata .Type , "15" ),
142
171
expected : & Config {
143
- Endpoint : DefaultEndpoint ,
172
+ ClientConfig : configgrpc.ClientConfig {
173
+ Endpoint : DefaultEndpoint ,
174
+ },
144
175
Key : "something:name" ,
145
176
Interval : time .Duration (10 ) * time .Second ,
146
177
},
147
178
},
148
179
{
149
180
id : component .NewIDWithName (metadata .Type , "16" ),
150
181
expected : & Config {
151
- Endpoint : DefaultEndpoint ,
182
+ ClientConfig : configgrpc.ClientConfig {
183
+ Endpoint : DefaultEndpoint ,
184
+ },
152
185
Key : "" ,
153
186
Interval : time .Duration (10 ) * time .Second ,
154
187
},
155
188
},
156
189
{
157
190
id : component .NewIDWithName (metadata .Type , "17" ),
158
191
expected : & Config {
159
- Endpoint : DefaultEndpoint ,
192
+ ClientConfig : configgrpc.ClientConfig {
193
+ Endpoint : DefaultEndpoint ,
194
+ },
160
195
Key : ":" ,
161
196
Interval : time .Duration (10 ) * time .Second ,
162
197
},
163
198
},
164
199
{
165
200
id : component .NewIDWithName (metadata .Type , "18" ),
166
201
expected : & Config {
167
- Endpoint : DefaultEndpoint ,
202
+ ClientConfig : configgrpc.ClientConfig {
203
+ Endpoint : DefaultEndpoint ,
204
+ },
168
205
Key : "::" ,
169
206
Interval : time .Duration (10 ) * time .Second ,
170
207
},
171
208
},
172
209
{
173
210
id : component .NewIDWithName (metadata .Type , "19" ),
174
211
expected : & Config {
175
- Endpoint : DefaultEndpoint ,
212
+ ClientConfig : configgrpc.ClientConfig {
213
+ Endpoint : DefaultEndpoint ,
214
+ },
176
215
Key : ":name" ,
177
216
Interval : time .Duration (10 ) * time .Second ,
178
217
},
179
218
},
180
219
{
181
220
id : component .NewIDWithName (metadata .Type , "20" ),
182
221
expected : & Config {
183
- Endpoint : DefaultEndpoint ,
222
+ ClientConfig : configgrpc.ClientConfig {
223
+ Endpoint : DefaultEndpoint ,
224
+ },
184
225
Key : "token:" ,
185
226
Interval : time .Duration (10 ) * time .Second ,
186
227
},
187
228
},
188
229
{
189
230
id : component .NewIDWithName (metadata .Type , "21" ),
190
231
expected : & Config {
191
- Endpoint : DefaultEndpoint ,
232
+ ClientConfig : configgrpc.ClientConfig {
233
+ Endpoint : DefaultEndpoint ,
234
+ },
192
235
Key : "token:name" ,
193
236
Interval : MinimumInterval ,
194
237
},
195
238
},
196
239
{
197
240
id : component .NewIDWithName (metadata .Type , "22" ),
198
241
expected : & Config {
199
- Endpoint : DefaultEndpoint ,
242
+ ClientConfig : configgrpc.ClientConfig {
243
+ Endpoint : DefaultEndpoint ,
244
+ },
200
245
Key : "token:name" ,
201
246
Interval : MaximumInterval ,
202
247
},
203
248
},
204
249
{
205
250
id : component .NewIDWithName (metadata .Type , "23" ),
206
251
expected : & Config {
207
- Endpoint : DefaultEndpoint ,
252
+ ClientConfig : configgrpc.ClientConfig {
253
+ Endpoint : DefaultEndpoint ,
254
+ },
208
255
Key : "token:name" ,
209
256
Interval : MinimumInterval ,
210
257
},
@@ -218,7 +265,7 @@ func TestLoadConfig(t *testing.T) {
218
265
cfg := factory .CreateDefaultConfig ()
219
266
sub , err := cm .Sub (tt .id .String ())
220
267
require .NoError (t , err )
221
- require .NoError (t , component . UnmarshalConfig ( sub , cfg ))
268
+ require .NoError (t , sub . Unmarshal ( cfg ))
222
269
assert .NoError (t , component .ValidateConfig (cfg ))
223
270
assert .Equal (t , tt .expected , cfg )
224
271
})
0 commit comments