From 869e38ebdcbfae1d9610180aaee062f20a15d471 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 5 Sep 2018 16:17:18 -0700 Subject: [PATCH 1/5] Emit metric to track null build latency --- test/e2e/simple_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index dd16c291..3fd8eef0 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -19,6 +19,7 @@ limitations under the License. package e2e import ( + "context" "flag" "os" "testing" @@ -26,6 +27,7 @@ import ( "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" @@ -59,6 +61,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) From e276ee316b39c89f9ec02d4a98f10861b2454bb7 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Thu, 6 Sep 2018 07:45:50 -0700 Subject: [PATCH 2/5] Support EMIT_METRICS in e2e-tests.sh --- test/e2e-tests.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index 77cfa538..67f39fe9 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -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 From a9cf54eb6b4233a770a376c36f987cb797a4a39f Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 5 Sep 2018 16:17:18 -0700 Subject: [PATCH 3/5] Emit metric to track null build latency --- test/e2e/simple_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 3fd8eef0..072bcacf 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -67,6 +67,11 @@ func TestSimpleBuild(t *testing.T) { _, span := trace.StartSpan(context.Background(), "NullBuildLatency") defer span.End() + // 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) From 8228c38084d4a8244f378f51ef3468f3ddd9f9c1 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 17 Sep 2018 14:29:37 -0400 Subject: [PATCH 4/5] Attempt to set up metrics flags --- test/e2e/simple_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 072bcacf..8dc15b6b 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -21,6 +21,7 @@ package e2e import ( "context" "flag" + "log" "os" "testing" "time" @@ -41,6 +42,15 @@ 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, err := newClients(test.Flags.Kubeconfig, test.Flags.Cluster, buildTestNamespace) + if err != nil { + log.Fatalf("newClients: %v", err) + } clients := setup(logger) test.CleanupOnInterrupt(func() { teardownNamespace(clients, logger) }, logger) From fdead4156bec3a51564d67a28460daf0357d61b5 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Fri, 5 Oct 2018 13:42:34 -0700 Subject: [PATCH 5/5] Fix metric setup --- test/e2e/simple_test.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 8dc15b6b..4d68ecb7 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -21,7 +21,6 @@ package e2e import ( "context" "flag" - "log" "os" "testing" "time" @@ -47,11 +46,6 @@ func TestMain(m *testing.M) { logging.InitializeMetricExporter() } - clients, err := newClients(test.Flags.Kubeconfig, test.Flags.Cluster, buildTestNamespace) - if err != nil { - log.Fatalf("newClients: %v", err) - } - clients := setup(logger) test.CleanupOnInterrupt(func() { teardownNamespace(clients, logger) }, logger) var code int @@ -77,11 +71,6 @@ func TestSimpleBuild(t *testing.T) { _, span := trace.StartSpan(context.Background(), "NullBuildLatency") defer span.End() - // 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)