forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer_registry_integration_test.go
51 lines (45 loc) · 1.36 KB
/
container_registry_integration_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
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package container_registry
import (
"errors"
"os"
"testing"
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
)
func TestData(t *testing.T) {
config, err := getConfig()
if err != nil {
t.Skip("Skipping TestData: " + err.Error())
}
metricSet := mbtest.NewFetcher(t, config)
metricSet.WriteEvents(t, "/")
}
func getConfig() (map[string]interface{}, error) {
clientId, ok := os.LookupEnv("AZURE_CLIENT_ID")
if !ok {
return nil, errors.New("missing AZURE_CLIENT_ID key")
}
clientSecret, ok := os.LookupEnv("AZURE_CLIENT_SECRET")
if !ok {
return nil, errors.New("missing AZURE_CLIENT_SECRET key")
}
tenantId, ok := os.LookupEnv("AZURE_TENANT_ID")
if !ok {
return nil, errors.New("missing AZURE_TENANT_ID key")
}
subscriptionId, ok := os.LookupEnv("AZURE_SUBSCRIPTION_ID")
if !ok {
return nil, errors.New("missing AZURE_SUBSCRIPTION_ID key")
}
config := map[string]interface{}{
"module": "azure",
"metricsets": []string{"container_registry"},
"client_id": clientId,
"client_secret": clientSecret,
"tenant_id": tenantId,
"subscription_id": subscriptionId,
}
return config, nil
}