Skip to content

Commit e8066e9

Browse files
authored
[Metricbeat] gcp: fix integration tests (#28364)
1 parent 19e5d5f commit e8066e9

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

CHANGELOG-developer.next.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,8 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
124124
- Update Go version to 1.16.5. {issue}26182[26182] {pull}26186[26186]
125125
- Introduce `libbeat/beat.Beat.OutputConfigReloader` {pull}28048[28048]
126126
- Update Go version to 1.17.1. {pull}27543[27543]
127+
- Whitelist `GCP_*` environment variables in dev tools {pull}28364[28364]
128+
129+
==== Deprecated
130+
131+
- Deprecated the `common.Float` type. {issue}28279[28279] {pull}28280[28280]

dev-tools/mage/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ func IntegrationTestEnvVars() []string {
905905
prefixes := []string{
906906
"AWS_",
907907
"AZURE_",
908+
"GCP_",
908909

909910
// Accepted by terraform, but not by many clients, including Beats
910911
"GOOGLE_",

x-pack/metricbeat/module/gcp/DEVELOPMENT.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ Run `make update` to update `fields.go` from each metricset `fields.yml`
6868

6969
The implementation is within `metrics` metricset. That metricset allows other metricsets to use it
7070
as a "parent module" and implement the light-weigth module pattern.
71+
72+
# Running integration tests
73+
74+
Golang integration tests may be run with: `TEST_TAGS=gcp MODULE=gcp mage goIntegTest`
75+
76+
This command will exclude `gcp.billing` metricset, as without access to a Billing Account it will always return an empty set of metrics.
77+
TODO: mock data so tests are not coupled with real GCP infrastructure.

x-pack/metricbeat/module/gcp/billing/billing_integration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// or more contributor license agreements. Licensed under the Elastic License;
33
// you may not use this file except in compliance with the Elastic License.
44

5-
//go:build integration && gcp
6-
// +build integration,gcp
5+
//go:build integration && gcp && billing
6+
// +build integration,gcp,billing
77

88
package billing
99

@@ -21,8 +21,8 @@ func TestFetch(t *testing.T) {
2121
config["period"] = "24h"
2222
config["dataset_id"] = "master_gcp"
2323

24-
metricSet := mbtest.NewReportingMetricSetV2Error(t, config)
25-
events, errs := mbtest.ReportingFetchV2Error(metricSet)
24+
metricSet := mbtest.NewReportingMetricSetV2WithContext(t, config)
25+
events, errs := mbtest.ReportingFetchV2WithContext(metricSet)
2626
if len(errs) > 0 {
2727
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
2828
}

0 commit comments

Comments
 (0)