Skip to content

Commit

Permalink
[Metricbeat] gcp: fix integration tests (#28364)
Browse files Browse the repository at this point in the history
  • Loading branch information
endorama committed Oct 13, 2021
1 parent 19e5d5f commit e8066e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Update Go version to 1.16.5. {issue}26182[26182] {pull}26186[26186]
- Introduce `libbeat/beat.Beat.OutputConfigReloader` {pull}28048[28048]
- Update Go version to 1.17.1. {pull}27543[27543]
- Whitelist `GCP_*` environment variables in dev tools {pull}28364[28364]

==== Deprecated

- Deprecated the `common.Float` type. {issue}28279[28279] {pull}28280[28280]
1 change: 1 addition & 0 deletions dev-tools/mage/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ func IntegrationTestEnvVars() []string {
prefixes := []string{
"AWS_",
"AZURE_",
"GCP_",

// Accepted by terraform, but not by many clients, including Beats
"GOOGLE_",
Expand Down
7 changes: 7 additions & 0 deletions x-pack/metricbeat/module/gcp/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ Run `make update` to update `fields.go` from each metricset `fields.yml`

The implementation is within `metrics` metricset. That metricset allows other metricsets to use it
as a "parent module" and implement the light-weigth module pattern.

# Running integration tests

Golang integration tests may be run with: `TEST_TAGS=gcp MODULE=gcp mage goIntegTest`

This command will exclude `gcp.billing` metricset, as without access to a Billing Account it will always return an empty set of metrics.
TODO: mock data so tests are not coupled with real GCP infrastructure.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build integration && gcp
// +build integration,gcp
//go:build integration && gcp && billing
// +build integration,gcp,billing

package billing

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

metricSet := mbtest.NewReportingMetricSetV2Error(t, config)
events, errs := mbtest.ReportingFetchV2Error(metricSet)
metricSet := mbtest.NewReportingMetricSetV2WithContext(t, config)
events, errs := mbtest.ReportingFetchV2WithContext(metricSet)
if len(errs) > 0 {
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
}
Expand Down

0 comments on commit e8066e9

Please sign in to comment.