Use randfill, do API renames
Kubernetes-commit: e54719bb6674fac228671e0786d19c2cf27b08a3
This commit is contained in:
parent
c2e94ca503
commit
9641d30242
|
@ -22,16 +22,16 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
|
||||||
v1 "k8s.io/api/admissionregistration/v1"
|
v1 "k8s.io/api/admissionregistration/v1"
|
||||||
|
"sigs.k8s.io/randfill"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMutatingWebhookAccessor(t *testing.T) {
|
func TestMutatingWebhookAccessor(t *testing.T) {
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
||||||
orig := &v1.MutatingWebhook{}
|
orig := &v1.MutatingWebhook{}
|
||||||
f.Fuzz(orig)
|
f.Fill(orig)
|
||||||
|
|
||||||
// zero out any accessor type specific fields not included in the accessor
|
// zero out any accessor type specific fields not included in the accessor
|
||||||
orig.ReinvocationPolicy = nil
|
orig.ReinvocationPolicy = nil
|
||||||
|
@ -72,11 +72,11 @@ func TestMutatingWebhookAccessor(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidatingWebhookAccessor(t *testing.T) {
|
func TestValidatingWebhookAccessor(t *testing.T) {
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
||||||
orig := &v1.ValidatingWebhook{}
|
orig := &v1.ValidatingWebhook{}
|
||||||
f.Fuzz(orig)
|
f.Fill(orig)
|
||||||
uid := fmt.Sprintf("test.configuration.admission/%s/0", orig.Name)
|
uid := fmt.Sprintf("test.configuration.admission/%s/0", orig.Name)
|
||||||
accessor := NewValidatingWebhookAccessor(uid, "test.configuration.admission", orig)
|
accessor := NewValidatingWebhookAccessor(uid, "test.configuration.admission", orig)
|
||||||
if uid != accessor.GetUID() {
|
if uid != accessor.GetUID() {
|
||||||
|
|
|
@ -29,8 +29,8 @@ import (
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"sigs.k8s.io/randfill"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConversionRoundTrip(t *testing.T) {
|
func TestConversionRoundTrip(t *testing.T) {
|
||||||
|
@ -42,12 +42,12 @@ func TestConversionRoundTrip(t *testing.T) {
|
||||||
err = v2scheme.RegisterConversions(scheme)
|
err = v2scheme.RegisterConversions(scheme)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
fuzzer := fuzz.NewWithSeed(2374375)
|
fuzzer := randfill.NewWithSeed(2374375)
|
||||||
|
|
||||||
// v2 -> v2beta1 -> v2
|
// v2 -> v2beta1 -> v2
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
expected := &v2.APIGroupDiscoveryList{}
|
expected := &v2.APIGroupDiscoveryList{}
|
||||||
fuzzer.Fuzz(expected)
|
fuzzer.Fill(expected)
|
||||||
expected.TypeMeta = metav1.TypeMeta{
|
expected.TypeMeta = metav1.TypeMeta{
|
||||||
Kind: "APIGroupDiscoveryList",
|
Kind: "APIGroupDiscoveryList",
|
||||||
APIVersion: "apidiscovery.k8s.io/v2",
|
APIVersion: "apidiscovery.k8s.io/v2",
|
||||||
|
@ -68,7 +68,7 @@ func TestConversionRoundTrip(t *testing.T) {
|
||||||
// v2beta1 -> v2 -> v2beta1
|
// v2beta1 -> v2 -> v2beta1
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
expected := &v2beta1.APIGroupDiscoveryList{}
|
expected := &v2beta1.APIGroupDiscoveryList{}
|
||||||
fuzzer.Fuzz(expected)
|
fuzzer.Fill(expected)
|
||||||
expected.TypeMeta = metav1.TypeMeta{
|
expected.TypeMeta = metav1.TypeMeta{
|
||||||
Kind: "APIGroupDiscoveryList",
|
Kind: "APIGroupDiscoveryList",
|
||||||
APIVersion: "apidiscovery.k8s.io/v2beta1",
|
APIVersion: "apidiscovery.k8s.io/v2beta1",
|
||||||
|
|
|
@ -19,7 +19,7 @@ package fuzzer
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fuzz "github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
|
@ -29,9 +29,9 @@ import (
|
||||||
// Funcs returns the fuzzer functions for the audit api group.
|
// Funcs returns the fuzzer functions for the audit api group.
|
||||||
func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(e *audit.Event, c fuzz.Continue) {
|
func(e *audit.Event, c randfill.Continue) {
|
||||||
c.FuzzNoCustom(e)
|
c.FillNoCustom(e)
|
||||||
switch c.RandBool() {
|
switch c.Bool() {
|
||||||
case true:
|
case true:
|
||||||
e.RequestObject = nil
|
e.RequestObject = nil
|
||||||
case false:
|
case false:
|
||||||
|
@ -41,7 +41,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
ContentType: runtime.ContentTypeJSON,
|
ContentType: runtime.ContentTypeJSON,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch c.RandBool() {
|
switch c.Bool() {
|
||||||
case true:
|
case true:
|
||||||
e.ResponseObject = nil
|
e.ResponseObject = nil
|
||||||
case false:
|
case false:
|
||||||
|
@ -52,8 +52,8 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(o *audit.ObjectReference, c fuzz.Continue) {
|
func(o *audit.ObjectReference, c randfill.Continue) {
|
||||||
c.FuzzNoCustom(o)
|
c.FillNoCustom(o)
|
||||||
switch c.Intn(3) {
|
switch c.Intn(3) {
|
||||||
case 0:
|
case 0:
|
||||||
// core api group
|
// core api group
|
||||||
|
|
|
@ -19,7 +19,7 @@ package fuzzer
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
apitesting "k8s.io/apimachinery/pkg/api/apitesting"
|
apitesting "k8s.io/apimachinery/pkg/api/apitesting"
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
|
||||||
|
@ -33,9 +33,9 @@ import (
|
||||||
// values in a Kubernetes context.
|
// values in a Kubernetes context.
|
||||||
func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(j *runtime.Object, c fuzz.Continue) {
|
func(j *runtime.Object, c randfill.Continue) {
|
||||||
// TODO: uncomment when round trip starts from a versioned object
|
// TODO: uncomment when round trip starts from a versioned object
|
||||||
if true { //c.RandBool() {
|
if true { // c.Bool() {
|
||||||
*j = &runtime.Unknown{
|
*j = &runtime.Unknown{
|
||||||
// We do not set TypeMeta here because it is not carried through a round trip
|
// We do not set TypeMeta here because it is not carried through a round trip
|
||||||
Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`),
|
Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`),
|
||||||
|
@ -44,15 +44,15 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
} else {
|
} else {
|
||||||
types := []runtime.Object{&example.Pod{}}
|
types := []runtime.Object{&example.Pod{}}
|
||||||
t := types[c.Rand.Intn(len(types))]
|
t := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(t)
|
c.Fill(t)
|
||||||
*j = t
|
*j = t
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(r *runtime.RawExtension, c fuzz.Continue) {
|
func(r *runtime.RawExtension, c randfill.Continue) {
|
||||||
// Pick an arbitrary type and fuzz it
|
// Pick an arbitrary type and fuzz it
|
||||||
types := []runtime.Object{&example.Pod{}}
|
types := []runtime.Object{&example.Pod{}}
|
||||||
obj := types[c.Rand.Intn(len(types))]
|
obj := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(obj)
|
c.Fill(obj)
|
||||||
|
|
||||||
// Convert the object to raw bytes
|
// Convert the object to raw bytes
|
||||||
bytes, err := runtime.Encode(apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion), obj)
|
bytes, err := runtime.Encode(apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion), obj)
|
||||||
|
@ -68,11 +68,11 @@ func overrideMetaFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
|
|
||||||
func exampleFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
func exampleFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(s *example.PodSpec, c fuzz.Continue) {
|
func(s *example.PodSpec, c randfill.Continue) {
|
||||||
c.FuzzNoCustom(s)
|
c.FillNoCustom(s)
|
||||||
// has a default value
|
// has a default value
|
||||||
ttl := int64(30)
|
ttl := int64(30)
|
||||||
if c.RandBool() {
|
if c.Bool() {
|
||||||
ttl = int64(c.Uint32())
|
ttl = int64(c.Uint32())
|
||||||
}
|
}
|
||||||
s.TerminationGracePeriodSeconds = &ttl
|
s.TerminationGracePeriodSeconds = &ttl
|
||||||
|
@ -81,11 +81,11 @@ func exampleFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||||
s.SchedulerName = "default-scheduler"
|
s.SchedulerName = "default-scheduler"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(j *example.PodPhase, c fuzz.Continue) {
|
func(j *example.PodPhase, c randfill.Continue) {
|
||||||
statuses := []example.PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
statuses := []example.PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
||||||
*j = statuses[c.Rand.Intn(len(statuses))]
|
*j = statuses[c.Rand.Intn(len(statuses))]
|
||||||
},
|
},
|
||||||
func(rp *example.RestartPolicy, c fuzz.Continue) {
|
func(rp *example.RestartPolicy, c randfill.Continue) {
|
||||||
policies := []example.RestartPolicy{"Always", "Never", "OnFailure"}
|
policies := []example.RestartPolicy{"Always", "Never", "OnFailure"}
|
||||||
*rp = policies[c.Rand.Intn(len(policies))]
|
*rp = policies[c.Rand.Intn(len(policies))]
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
fuzz "github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestEscaping tests that property names are escaped as expected.
|
// TestEscaping tests that property names are escaped as expected.
|
||||||
|
@ -143,10 +143,10 @@ func TestUnescapeMalformed(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEscapingFuzz(t *testing.T) {
|
func TestEscapingFuzz(t *testing.T) {
|
||||||
fuzzer := fuzz.New()
|
fuzzer := randfill.New()
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
var unescaped string
|
var unescaped string
|
||||||
fuzzer.Fuzz(&unescaped)
|
fuzzer.Fill(&unescaped)
|
||||||
t.Run(fmt.Sprintf("%d - '%s'", i, unescaped), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d - '%s'", i, unescaped), func(t *testing.T) {
|
||||||
if len(unescaped) == 0 {
|
if len(unescaped) == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -4463,7 +4463,7 @@ func benchmarkItems(b *testing.B) []example.Pod {
|
||||||
clientapiObjectFuzzer := fuzzer.FuzzerFor(examplefuzzer.Funcs, rand.NewSource(benchmarkSeed), codecs)
|
clientapiObjectFuzzer := fuzzer.FuzzerFor(examplefuzzer.Funcs, rand.NewSource(benchmarkSeed), codecs)
|
||||||
items := make([]example.Pod, 3)
|
items := make([]example.Pod, 3)
|
||||||
for i := range items {
|
for i := range items {
|
||||||
clientapiObjectFuzzer.Fuzz(&items[i])
|
clientapiObjectFuzzer.Fill(&items[i])
|
||||||
}
|
}
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
fuzz "github.com/google/gofuzz"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
apidiscoveryv2 "k8s.io/api/apidiscovery/v2"
|
apidiscoveryv2 "k8s.io/api/apidiscovery/v2"
|
||||||
apidiscoveryv2beta1 "k8s.io/api/apidiscovery/v2beta1"
|
apidiscoveryv2beta1 "k8s.io/api/apidiscovery/v2beta1"
|
||||||
|
@ -59,16 +59,16 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv2.APIGroupDiscoveryList {
|
func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv2.APIGroupDiscoveryList {
|
||||||
fuzzer := fuzz.NewWithSeed(seed)
|
fuzzer := randfill.NewWithSeed(seed)
|
||||||
fuzzer.NumElements(atLeastNumGroups, maxNumGroups)
|
fuzzer.NumElements(atLeastNumGroups, maxNumGroups)
|
||||||
fuzzer.NilChance(0)
|
fuzzer.NilChance(0)
|
||||||
fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c fuzz.Continue) {
|
fuzzer.Funcs(func(o *apidiscoveryv2.APIGroupDiscovery, c randfill.Continue) {
|
||||||
c.FuzzNoCustom(o)
|
c.FillNoCustom(o)
|
||||||
|
|
||||||
// The ResourceManager will just not serve the group if its versions
|
// The ResourceManager will just not serve the group if its versions
|
||||||
// list is empty
|
// list is empty
|
||||||
atLeastOne := apidiscoveryv2.APIVersionDiscovery{}
|
atLeastOne := apidiscoveryv2.APIVersionDiscovery{}
|
||||||
c.Fuzz(&atLeastOne)
|
c.Fill(&atLeastOne)
|
||||||
o.Versions = append(o.Versions, atLeastOne)
|
o.Versions = append(o.Versions, atLeastOne)
|
||||||
sort.Slice(o.Versions[:], func(i, j int) bool {
|
sort.Slice(o.Versions[:], func(i, j int) bool {
|
||||||
return version.CompareKubeAwareVersionStrings(o.Versions[i].Version, o.Versions[j].Version) > 0
|
return version.CompareKubeAwareVersionStrings(o.Versions[i].Version, o.Versions[j].Version) > 0
|
||||||
|
@ -76,14 +76,14 @@ func fuzzAPIGroups(atLeastNumGroups, maxNumGroups int, seed int64) apidiscoveryv
|
||||||
|
|
||||||
o.TypeMeta = metav1.TypeMeta{}
|
o.TypeMeta = metav1.TypeMeta{}
|
||||||
var name string
|
var name string
|
||||||
c.Fuzz(&name)
|
c.Fill(&name)
|
||||||
o.ObjectMeta = metav1.ObjectMeta{
|
o.ObjectMeta = metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var apis []apidiscoveryv2.APIGroupDiscovery
|
var apis []apidiscoveryv2.APIGroupDiscovery
|
||||||
fuzzer.Fuzz(&apis)
|
fuzzer.Fill(&apis)
|
||||||
sort.Slice(apis[:], func(i, j int) bool {
|
sort.Slice(apis[:], func(i, j int) bool {
|
||||||
return apis[i].Name < apis[j].Name
|
return apis[i].Name < apis[j].Name
|
||||||
})
|
})
|
||||||
|
|
|
@ -28,7 +28,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
|
||||||
jsonpatch "gopkg.in/evanphx/json-patch.v4"
|
jsonpatch "gopkg.in/evanphx/json-patch.v4"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
@ -53,6 +52,7 @@ import (
|
||||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/component-base/metrics/legacyregistry"
|
"k8s.io/component-base/metrics/legacyregistry"
|
||||||
"k8s.io/component-base/metrics/testutil"
|
"k8s.io/component-base/metrics/testutil"
|
||||||
|
"sigs.k8s.io/randfill"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -991,11 +991,11 @@ func (alwaysErrorTyper) Recognizes(gvk schema.GroupVersionKind) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateToCreateOptions(t *testing.T) {
|
func TestUpdateToCreateOptions(t *testing.T) {
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
||||||
update := &metav1.UpdateOptions{}
|
update := &metav1.UpdateOptions{}
|
||||||
f.Fuzz(update)
|
f.Fill(update)
|
||||||
create := updateToCreateOptions(update)
|
create := updateToCreateOptions(update)
|
||||||
|
|
||||||
b, err := json.Marshal(create)
|
b, err := json.Marshal(create)
|
||||||
|
@ -1038,13 +1038,13 @@ func TestPatchToUpdateOptions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("Run %d/100", i), func(t *testing.T) {
|
||||||
patch := &metav1.PatchOptions{}
|
patch := &metav1.PatchOptions{}
|
||||||
f.Fuzz(patch)
|
f.Fill(patch)
|
||||||
converted := test.converterFn(patch)
|
converted := test.converterFn(patch)
|
||||||
|
|
||||||
b, err := json.Marshal(converted)
|
b, err := json.Marshal(converted)
|
||||||
|
|
|
@ -29,7 +29,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fuzz "github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/apitesting"
|
"k8s.io/apimachinery/pkg/api/apitesting"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
|
@ -480,13 +480,13 @@ func TestStoreCreateWithRetryNameGenerateFeatureDisabled(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewCreateOptionsFromUpdateOptions(t *testing.T) {
|
func TestNewCreateOptionsFromUpdateOptions(t *testing.T) {
|
||||||
f := fuzz.New().NilChance(0.0).NumElements(1, 1)
|
f := randfill.New().NilChance(0.0).NumElements(1, 1)
|
||||||
|
|
||||||
// The goal here is to trigger when any changes are made to either
|
// The goal here is to trigger when any changes are made to either
|
||||||
// CreateOptions or UpdateOptions types, so we can update the converter.
|
// CreateOptions or UpdateOptions types, so we can update the converter.
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
in := &metav1.UpdateOptions{}
|
in := &metav1.UpdateOptions{}
|
||||||
f.Fuzz(in)
|
f.Fill(in)
|
||||||
in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("CreateOptions"))
|
in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("CreateOptions"))
|
||||||
|
|
||||||
out := newCreateOptionsFromUpdateOptions(in)
|
out := newCreateOptionsFromUpdateOptions(in)
|
||||||
|
@ -532,13 +532,13 @@ func TestNewCreateOptionsFromUpdateOptions(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewDeleteOptionsFromUpdateOptions(t *testing.T) {
|
func TestNewDeleteOptionsFromUpdateOptions(t *testing.T) {
|
||||||
f := fuzz.New().NilChance(0.0).NumElements(1, 1)
|
f := randfill.New().NilChance(0.0).NumElements(1, 1)
|
||||||
|
|
||||||
// The goal here is to trigger when any changes are made to either
|
// The goal here is to trigger when any changes are made to either
|
||||||
// DeleteOptions or UpdateOptions types, so we can update the converter.
|
// DeleteOptions or UpdateOptions types, so we can update the converter.
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
in := &metav1.UpdateOptions{}
|
in := &metav1.UpdateOptions{}
|
||||||
f.Fuzz(in)
|
f.Fill(in)
|
||||||
in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("DeleteOptions"))
|
in.TypeMeta.SetGroupVersionKind(metav1.SchemeGroupVersion.WithKind("DeleteOptions"))
|
||||||
|
|
||||||
out := newDeleteOptionsFromUpdateOptions(in)
|
out := newDeleteOptionsFromUpdateOptions(in)
|
||||||
|
|
|
@ -24,22 +24,22 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
authenticationv1 "k8s.io/api/authentication/v1"
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
authenticationv1beta1 "k8s.io/api/authentication/v1beta1"
|
authenticationv1beta1 "k8s.io/api/authentication/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRoundTrip(t *testing.T) {
|
func TestRoundTrip(t *testing.T) {
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
seed := time.Now().UnixNano()
|
seed := time.Now().UnixNano()
|
||||||
t.Logf("seed = %v", seed)
|
t.Logf("seed = %v", seed)
|
||||||
f.RandSource(rand.New(rand.NewSource(seed)))
|
f.RandSource(rand.New(rand.NewSource(seed)))
|
||||||
|
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
original := &authenticationv1.TokenReview{}
|
original := &authenticationv1.TokenReview{}
|
||||||
f.Fuzz(&original.Spec)
|
f.Fill(&original.Spec)
|
||||||
f.Fuzz(&original.Status)
|
f.Fill(&original.Status)
|
||||||
converted := &authenticationv1beta1.TokenReview{
|
converted := &authenticationv1beta1.TokenReview{
|
||||||
Spec: v1SpecToV1beta1Spec(&original.Spec),
|
Spec: v1SpecToV1beta1Spec(&original.Spec),
|
||||||
Status: v1StatusToV1beta1Status(original.Status),
|
Status: v1StatusToV1beta1Status(original.Status),
|
||||||
|
|
|
@ -24,22 +24,22 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
fuzz "github.com/google/gofuzz"
|
"sigs.k8s.io/randfill"
|
||||||
|
|
||||||
authorizationv1 "k8s.io/api/authorization/v1"
|
authorizationv1 "k8s.io/api/authorization/v1"
|
||||||
authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
|
authorizationv1beta1 "k8s.io/api/authorization/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRoundTrip(t *testing.T) {
|
func TestRoundTrip(t *testing.T) {
|
||||||
f := fuzz.New()
|
f := randfill.New()
|
||||||
seed := time.Now().UnixNano()
|
seed := time.Now().UnixNano()
|
||||||
t.Logf("seed = %v", seed)
|
t.Logf("seed = %v", seed)
|
||||||
f.RandSource(rand.New(rand.NewSource(seed)))
|
f.RandSource(rand.New(rand.NewSource(seed)))
|
||||||
|
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
original := &authorizationv1.SubjectAccessReview{}
|
original := &authorizationv1.SubjectAccessReview{}
|
||||||
f.Fuzz(&original.Spec)
|
f.Fill(&original.Spec)
|
||||||
f.Fuzz(&original.Status)
|
f.Fill(&original.Status)
|
||||||
converted := &authorizationv1beta1.SubjectAccessReview{
|
converted := &authorizationv1beta1.SubjectAccessReview{
|
||||||
Spec: v1SpecToV1beta1Spec(&original.Spec),
|
Spec: v1SpecToV1beta1Spec(&original.Spec),
|
||||||
Status: v1StatusToV1beta1Status(original.Status),
|
Status: v1StatusToV1beta1Status(original.Status),
|
||||||
|
|
Loading…
Reference in New Issue