-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[e2e] Emit a duration-scoped grafana link for each test (#3340)
Signed-off-by: marun <maru.newby@avalabs.org> Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
- Loading branch information
1 parent
ccf2612
commit ca0228a
Showing
5 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package e2e | ||
|
||
import ( | ||
"strconv" | ||
"time" | ||
|
||
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet" | ||
|
||
ginkgo "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
// The ginkgo event handlers defined in this file will be automatically | ||
// applied to all ginkgo suites importing this package. | ||
|
||
// Whether a spec-scoped metrics link should be emitted after the current | ||
// spec finishes executing. | ||
var EmitMetricsLink bool | ||
|
||
// This event handler ensures that by default a spec-scoped metrics link | ||
// will be emitted at the end of spec execution. If the test uses a | ||
// private network, it can disable this behavior by setting | ||
// EmitMetricsLink to false. | ||
// | ||
// TODO(marun) Make this conditional on metrics collection being enabled | ||
var _ = ginkgo.BeforeEach(func() { | ||
EmitMetricsLink = true | ||
}) | ||
|
||
// This event handler attempts to emit a metrics link scoped to the duration | ||
// of the current spec. | ||
// | ||
// TODO(marun) Make this conditional on metrics collection being enabled | ||
var _ = ginkgo.AfterEach(func() { | ||
tc := NewTestContext() | ||
env := GetEnv(tc) | ||
if env == nil || !EmitMetricsLink { | ||
return | ||
} | ||
|
||
specReport := ginkgo.CurrentSpecReport() | ||
startTime := specReport.StartTime.UnixMilli() | ||
// Extend the end time by the shutdown delay (a proxy for the metrics | ||
// scrape interval) to maximize the chances of the specified duration | ||
// including all metrics relevant to the current spec. | ||
endTime := time.Now().Add(networkShutdownDelay).UnixMilli() | ||
metricsLink := tmpnet.MetricsLinkForNetwork( | ||
env.GetNetwork().UUID, | ||
strconv.FormatInt(startTime, 10), | ||
strconv.FormatInt(endTime, 10), | ||
) | ||
tc.Outf("Test Metrics: %s\n", metricsLink) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters