diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_norace.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_norace.go new file mode 100644 index 00000000000..8cf063b1ee0 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_norace.go @@ -0,0 +1,22 @@ +// +build !race + +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package roundtrip + +// in non-race-detection mode, a higher number of iterations is reasonable +const defaultFuzzIters = 20 diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_race.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_race.go new file mode 100644 index 00000000000..1ec3366ae4f --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/fuzz_race.go @@ -0,0 +1,22 @@ +// +build race + +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package roundtrip + +// in race-detection mode, lower the number of iterations to keep reasonable runtimes in CI +const defaultFuzzIters = 5 diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go index f7961043ac5..89c1d1ca8e0 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go @@ -85,7 +85,7 @@ func RoundTripProtobufTestForScheme(t *testing.T, scheme *runtime.Scheme, fuzzin RoundTripTypes(t, scheme, codecFactory, fuzzer, nil) } -var FuzzIters = flag.Int("fuzz-iters", 20, "How many fuzzing iterations to do.") +var FuzzIters = flag.Int("fuzz-iters", defaultFuzzIters, "How many fuzzing iterations to do.") // globalNonRoundTrippableTypes are kinds that are effectively reserved across all GroupVersions // They don't roundtrip