Skip to content

Commit e5d81d6

Browse files
committed
receiver/azuremonitor - added config check and unit test cases
1 parent 7686447 commit e5d81d6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

receiver/azuremonitorreceiver/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var (
2828
errMissingClientSecret = errors.New(`"ClientSecret" is not specified in config`)
2929
errMissingFedTokenFile = errors.New(`"FederatedTokenFile" is not specified in config`)
3030
errInvalidCloud = errors.New(`"Cloud" is invalid`)
31+
errInvalidMaxResPerBatch = errors.New(`"MaximumResourcesPerBatch" should be greater than 0`)
3132

3233
monitorServices = []string{
3334
"Microsoft.EventGrid/eventSubscriptions",
@@ -332,5 +333,9 @@ func (c Config) Validate() (err error) {
332333
err = multierr.Append(err, errInvalidCloud)
333334
}
334335

336+
if c.UseBatchAPI && c.MaximumResourcesPerBatch < 0 {
337+
err = multierr.Append(err, errInvalidMaxResPerBatch)
338+
}
339+
335340
return
336341
}

receiver/azuremonitorreceiver/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func TestLoadConfig(t *testing.T) {
109109
return cfg
110110
}(),
111111
},
112+
{
113+
id: component.NewIDWithName(metadata.Type, "max_resources_per_batch_negative_value"),
114+
expectedErr: errInvalidMaxResPerBatch.Error(),
115+
},
112116
}
113117

114118
for _, tt := range tests {

receiver/azuremonitorreceiver/testdata/config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ azuremonitor/valid_authenticator_2:
3939
discover_subscriptions: true
4040
auth:
4141
authenticator: azureauth
42-
credentials: does-not-matter
42+
credentials: does-not-matter
43+
44+
azuremonitor/max_resources_per_batch_negative_value:
45+
discover_subscriptions: true
46+
auth:
47+
authenticator: azureauth
48+
credentials: does-not-matter
49+
use_batch_api: true
50+
maximum_resources_per_batch: -1

0 commit comments

Comments
 (0)