Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Emit metric to track null build latency #337

Merged
merged 5 commits into from
Oct 5, 2018
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
4 changes: 3 additions & 1 deletion test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ kubectl delete --ignore-not-found=true buildtemplates --all
failed=0

header "Running Go e2e tests"
report_go_test -tags e2e ./test/e2e/... -count=1 || failed=1
options=""
(( EMIT_METRICS )) && options="-emitmetrics"
report_go_test -tags e2e ./test/e2e/... -count=1 ${options} || failed=1

header "Running YAML e2e tests"
if ! run_yaml_tests; then
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ limitations under the License.
package e2e

import (
"context"
"flag"
"os"
"testing"
"time"

"github.com/knative/pkg/test"
"github.com/knative/pkg/test/logging"
"go.opencensus.io/trace"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand All @@ -39,6 +41,10 @@ func TestMain(m *testing.M) {
flag.Parse()
logging.InitializeLogger(test.Flags.LogVerbose)
logger := logging.GetContextLogger("TestSetup")
flag.Set("alsologtostderr", "true")
if test.Flags.EmitMetrics {
logging.InitializeMetricExporter()
}

clients := setup(logger)
test.CleanupOnInterrupt(func() { teardownNamespace(clients, logger) }, logger)
Expand All @@ -59,6 +65,12 @@ func TestMain(m *testing.M) {
func TestSimpleBuild(t *testing.T) {
logger := logging.GetContextLogger("TestSimpleBuild")
clients := buildClients(logger)

// Emit a metric for null-build latency (i.e., time to schedule and execute
// and finish watching a build).
_, span := trace.StartSpan(context.Background(), "NullBuildLatency")
defer span.End()

buildName := "simple-build"

test.CleanupOnInterrupt(func() { teardownBuild(clients, logger, buildName) }, logger)
Expand Down