Repository: knative/pkg
Pull request #1852 (2020-10-27 11:21:41)

move fuzzers
Signed-off-by: Ville Aikas <vaikas@vmware.com>

We currently ship fuzzers in our binaries, this is hoping to remove the last bits of them. Note that I did not inline them into the roundtrip_test because I was thinking that if downstream wants to test them, they can continue to do so.

Addresses:
https://github.com/knative/eventing/issues/4398
https://github.com/knative/serving/issues/9725


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

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1852#" title="Author self-approved">vaikas</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:

- ~~[apis/duck/OWNERS](https://github.com/knative/pkg/blob/master/apis/duck/OWNERS)~~ [vaikas]

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":[]} -->
vaikas: With this change, when I bring into eventing (my own branch), we now see:
vaikas@vaikas-a01 eventing % go build ./cmd/controller/main.go

```
vaikas@vaikas-a01 eventing % go tool nm -size  main  | grep fuzz | grep knative.dev
vaikas@vaikas-a01 eventing %
```

But the Google fuzzers are still there. But progress:
```
vaikas@vaikas-a01 eventing % go tool nm -size  main  | grep fuzz
 143dbe0         32 T github.com/google/gofuzz.(*Continue).ExpFloat64
 143dc00         32 T github.com/google/gofuzz.(*Continue).Float32
 143dc20         32 T github.com/google/gofuzz.(*Continue).Float64
 143dc40        128 T github.com/google/gofuzz.(*Continue).Fuzz
```

Also, down another 13kB ;)

Previously when moved the eventing fuzzers away, our resulting binary was:
61103260


```
vaikas@vaikas-a01 eventing % ls -l main
-rwxr-xr-x  1 vaikas  staff  61089612 Oct 27 13:26 main
```
vaikas@vaikas-a01 mink % echo '61103260 61089612 - p' | dc
13648
knative-prow-robot: @vaikas: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-pkg-unit-tests | 88c44d06a379722f69d379c279dcf145847aca93 | [link](https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_pkg/1852/pull-knative-pkg-unit-tests/1321052640456478723) | `/test pull-knative-pkg-unit-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_pkg/1852). [Your PR dashboard](https://gubernator.knative.dev/pr/vaikas).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
vaikas: UT failed with:
```
false}}; new config &{knative.dev/serving testComponent opencensus 1000000000 <nil> <nil> localhost:12345 false 0 false   {   false}}
    --- FAIL: TestMetricsExport/OpenCensus (4.04s)
        resource_view_test.go:439: Timeout reading input
        resource_view_test.go:445: Unexpected OpenCensus exports (-want +got):
              []metrics.metricExtract(Inverse(Sort, []string{
              	"knative.dev/serving/testComponent/global_export_counts<>:2",
              	"knative.dev/serving/testComponent/resource_global_export_count<>:2",
              	`knative.dev/serving/testComponent/testing/value<project="p1",rev`...,
            - 	`knative.dev/serving/testComponent/testing/value<project="p1",revision="r2">:1`,
              }))
    logger.go:130: 2020-10-27T11:42:23.560Z	INFO	metrics/exporter.go:155	Flushing the existing exporter before setting up the new exporter.
    logger.go:130: 2020-10-27T11:42:23.562Z	INFO	metrics/stackdriver_exporter.go:203	Created Opencensus Stackdriver exporter with config &{knative.dev/serving testComponent stackdriver 1000000000 0x22f01a0 <nil>  false 0 true knative.dev/serving/testComponent custom.googleapis.com/knative.dev/serving/testComponent {   false}}
    logger.go:130: 2020-10-27T11:42:23.562Z	INFO	metrics/exporter.go:168	Successfully updated the metrics exporter; old config: &{knative.dev/serving testComponent opencensus 1000000000 <nil> <nil> localhost:12345 false 0 false   {   false}}; new config &{knative.dev/serving testComponent stackdriver 1000000000 0x22f01a0 <nil>  false 0 true knative.dev/serving/testComponent custom.googleapis.com/knative.dev/serving/testComponent {   false}}
FAIL
```
I hae a hard time it's related to this, is this flaky test?
knative-prow-robot: @vaikas: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-pkg-unit-tests | f1f63343ae4bd468d0e175d1ecd9bc77f74b0f2a | [link](https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_pkg/1852/pull-knative-pkg-unit-tests/1321056037817552898) | `/test pull-knative-pkg-unit-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_pkg/1852). [Your PR dashboard](https://gubernator.knative.dev/pr/vaikas).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1852#pullrequestreview-517628922" title="Approved">markusthoemmes</a>*, *<a href="https://github.com/knative/pkg/pull/1852#" title="Author self-approved">vaikas</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:

- ~~[apis/duck/OWNERS](https://github.com/knative/pkg/blob/master/apis/duck/OWNERS)~~ [markusthoemmes,vaikas]

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":[]} -->
vaikas: /test pull-knative-pkg-unit-tests

Patch:
diff --git a/apis/duck/v1/fuzzer.go b/apis/duck/v1/test/fuzzer.go
similarity index 93%
rename from apis/duck/v1/fuzzer.go
rename to apis/duck/v1/test/fuzzer.go
index 4ef66e589..888ca9adb 100644
--- a/apis/duck/v1/fuzzer.go
+++ b/apis/duck/v1/test/fuzzer.go
@@ -14,13 +14,14 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package v1
+package test
 
 import (
 	fuzz "github.com/google/gofuzz"
 	"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
 	"k8s.io/apimachinery/pkg/runtime/serializer"
 	"knative.dev/pkg/apis"
+	v1 "knative.dev/pkg/apis/duck/v1"
 	pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer"
 )
 
@@ -34,7 +35,7 @@ var testConditions = apis.Conditions{{Type: apis.ConditionReady}, {Type: apis.Co
 var FuzzerFuncs = fuzzer.MergeFuzzerFuncs(
 	func(codecs serializer.CodecFactory) []interface{} {
 		return []interface{}{
-			func(status *Status, c fuzz.Continue) {
+			func(status *v1.Status, c fuzz.Continue) {
 				c.FuzzNoCustom(status) // fuzz the Status
 				status.SetConditions(testConditions)
 				pkgfuzzer.FuzzConditions(status, c)
diff --git a/apis/duck/v1beta1/fuzzer.go b/apis/duck/v1beta1/test/fuzzer.go
similarity index 93%
rename from apis/duck/v1beta1/fuzzer.go
rename to apis/duck/v1beta1/test/fuzzer.go
index efc8be973..a1564e273 100644
--- a/apis/duck/v1beta1/fuzzer.go
+++ b/apis/duck/v1beta1/test/fuzzer.go
@@ -14,13 +14,14 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package v1beta1
+package test
 
 import (
 	fuzz "github.com/google/gofuzz"
 	"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
 	"k8s.io/apimachinery/pkg/runtime/serializer"
 	"knative.dev/pkg/apis"
+	"knative.dev/pkg/apis/duck/v1beta1"
 	pkgfuzzer "knative.dev/pkg/apis/testing/fuzzer"
 )
 
@@ -33,7 +34,7 @@ var testConditions = apis.Conditions{{Type: apis.ConditionReady}, {Type: apis.Co
 var FuzzerFuncs = fuzzer.MergeFuzzerFuncs(
 	func(codecs serializer.CodecFactory) []interface{} {
 		return []interface{}{
-			func(status *Status, c fuzz.Continue) {
+			func(status *v1beta1.Status, c fuzz.Continue) {
 				c.FuzzNoCustom(status) // fuzz the Status
 				status.SetConditions(testConditions)
 				pkgfuzzer.FuzzConditions(status, c)


Test patch:
diff --git a/apis/duck/v1/roundtrip_test.go b/apis/duck/v1/test/roundtrip_test.go
similarity index 92%
rename from apis/duck/v1/roundtrip_test.go
rename to apis/duck/v1/test/roundtrip_test.go
index 25bca151b..8d2395de7 100644
--- a/apis/duck/v1/roundtrip_test.go
+++ b/apis/duck/v1/test/roundtrip_test.go
@@ -14,11 +14,12 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package v1
+package test
 
 import (
 	"testing"
 
+	v1 "k8s.io/api/apps/v1"
 	"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
 	"k8s.io/apimachinery/pkg/runtime"
 	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -28,7 +29,7 @@ import (
 
 func TestEventingRoundTripTypesToJSON(t *testing.T) {
 	scheme := runtime.NewScheme()
-	utilruntime.Must(AddToScheme(scheme))
+	utilruntime.Must(v1.AddToScheme(scheme))
 
 	fuzzerFuncs := fuzzer.MergeFuzzerFuncs(
 		pkgfuzzer.Funcs,
diff --git a/apis/duck/v1beta1/roundtrip_test.go b/apis/duck/v1beta1/test/roundtrip_test.go
similarity index 91%
rename from apis/duck/v1beta1/roundtrip_test.go
rename to apis/duck/v1beta1/test/roundtrip_test.go
index f727740ae..0d5c3c6d0 100644
--- a/apis/duck/v1beta1/roundtrip_test.go
+++ b/apis/duck/v1beta1/test/roundtrip_test.go
@@ -14,11 +14,13 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package v1beta1
+package test
 
 import (
 	"testing"
 
+	"knative.dev/pkg/apis/duck/v1beta1"
+
 	"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
 	"k8s.io/apimachinery/pkg/runtime"
 	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -28,7 +30,7 @@ import (
 
 func TestEventingRoundTripTypesToJSON(t *testing.T) {
 	scheme := runtime.NewScheme()
-	utilruntime.Must(AddToScheme(scheme))
+	utilruntime.Must(v1beta1.AddToScheme(scheme))
 
 	fuzzerFuncs := fuzzer.MergeFuzzerFuncs(
 		pkgfuzzer.Funcs,