Repository: knative/pkg
Pull request #1870 (2020-10-28 11:33:23)

Skip flaky OpenCensus exporter test until fixed
Ref https://github.com/knative/pkg/issues/1672

This seriously impacts developer productivity, so let's skip until fixed.

/assign @julz @vaikas 

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1870#" title="Author self-approved">markusthoemmes</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[metrics/OWNERS](https://github.com/knative/pkg/blob/master/metrics/OWNERS)~~ [markusthoemmes]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1870#pullrequestreview-518573169" title="LGTM">julz</a>*, *<a href="https://github.com/knative/pkg/pull/1870#" title="Author self-approved">markusthoemmes</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[metrics/OWNERS](https://github.com/knative/pkg/blob/master/metrics/OWNERS)~~ [markusthoemmes]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/configmap/parse.go b/configmap/parse.go
index d4fa5e875..4c280757b 100644
--- a/configmap/parse.go
+++ b/configmap/parse.go
@@ -81,6 +81,20 @@ func AsInt64(key string, target *int64) ParseFunc {
 	}
 }
 
+// AsInt parses the value at key as an int into the target, if it exists.
+func AsInt(key string, target *int) ParseFunc {
+	return func(data map[string]string) error {
+		if raw, ok := data[key]; ok {
+			val, err := strconv.Atoi(raw)
+			if err != nil {
+				return fmt.Errorf("failed to parse %q: %w", key, err)
+			}
+			*target = val
+		}
+		return nil
+	}
+}
+
 // AsUint32 parses the value at key as an uint32 into the target, if it exists.
 func AsUint32(key string, target *uint32) ParseFunc {
 	return func(data map[string]string) error {
diff --git a/signals/signal.go b/signals/signal.go
index b9ba9eaf3..65bab4253 100644
--- a/signals/signal.go
+++ b/signals/signal.go
@@ -18,7 +18,6 @@ package signals
 
 import (
 	"context"
-	"errors"
 	"os"
 	"os/signal"
 	"time"
@@ -65,12 +64,14 @@ func (scc *signalContext) Done() <-chan struct{} {
 	return scc.stopCh
 }
 
-// Err implements context.Context
+// Err implements context.Context. If the underlying stop channel is closed, Err
+// always returns context.Canceled, and nil otherwise.
 func (scc *signalContext) Err() error {
 	select {
 	case _, ok := <-scc.Done():
 		if !ok {
-			return errors.New("received a termination signal")
+			// TODO: revisit this behavior when Deadline() implementation is changed
+			return context.Canceled
 		}
 	default:
 	}


Test patch:
diff --git a/configmap/parse_test.go b/configmap/parse_test.go
index c7706c87e..0f3878c7f 100644
--- a/configmap/parse_test.go
+++ b/configmap/parse_test.go
@@ -32,6 +32,7 @@ type testConfig struct {
 	i32    int32
 	i64    int64
 	u32    uint32
+	i      int
 	f64    float64
 	dur    time.Duration
 	set    sets.String
@@ -57,6 +58,7 @@ func TestParse(t *testing.T) {
 			"test-int32":    "1",
 			"test-int64":    "2",
 			"test-uint32":   "3",
+			"test-int":      "4",
 			"test-float64":  "1.0",
 			"test-duration": "1m",
 			"test-set":      "a,b,c",
@@ -72,6 +74,7 @@ func TestParse(t *testing.T) {
 			i64:    2,
 			u32:    3,
 			f64:    1.0,
+			i:      4,
 			dur:    time.Minute,
 			set:    sets.NewString("a", "b", "c"),
 			qua:    &fiveHundredM,
@@ -92,6 +95,7 @@ func TestParse(t *testing.T) {
 			i32:    1,
 			i64:    2,
 			f64:    1.0,
+			i:      4,
 			dur:    time.Minute,
 			qua:    &fiveHundredM,
 		},
@@ -101,6 +105,7 @@ func TestParse(t *testing.T) {
 			i32:    1,
 			i64:    2,
 			f64:    1.0,
+			i:      4,
 			dur:    time.Minute,
 			qua:    &fiveHundredM,
 		},
@@ -128,6 +133,12 @@ func TestParse(t *testing.T) {
 			"test-uint32": "foo",
 		},
 		expectErr: true,
+	}, {
+		name: "int error",
+		data: map[string]string{
+			"test-int": "foo",
+		},
+		expectErr: true,
 	}, {
 		name: "float64 error",
 		data: map[string]string{
@@ -168,6 +179,7 @@ func TestParse(t *testing.T) {
 				AsInt32("test-int32", &test.conf.i32),
 				AsInt64("test-int64", &test.conf.i64),
 				AsUint32("test-uint32", &test.conf.u32),
+				AsInt("test-int", &test.conf.i),
 				AsFloat64("test-float64", &test.conf.f64),
 				AsDuration("test-duration", &test.conf.dur),
 				AsStringSet("test-set", &test.conf.set),
diff --git a/metrics/resource_view_test.go b/metrics/resource_view_test.go
index 421d02c0f..8dc006ccf 100644
--- a/metrics/resource_view_test.go
+++ b/metrics/resource_view_test.go
@@ -404,6 +404,8 @@ testComponent_testing_value{project="p1",revision="r2"} 1
 			return UpdateExporter(context.Background(), configForBackend(openCensus), logtesting.TestLogger(t))
 		},
 		validate: func(t *testing.T) {
+			t.Skip("Skipped because of excessive flakiness, see: https://github.com/knative/pkg/issues/1672")
+
 			// We unregister the views because this is one of two ways to flush
 			// the internal aggregation buffers; the other is to have the
 			// internal reporting period duration tick, which is at least