Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] gcp: fix integration tests #28364

Merged
merged 5 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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