From ce163947aa634b2a4228d5fe55155236a4b8e2fd Mon Sep 17 00:00:00 2001 From: Paco Xu Date: Mon, 10 Mar 2025 11:10:23 +0800 Subject: [PATCH] fix a flake of TestRoundTripTypes: for FirstAvailable[].AllocationMode --- pkg/apis/resource/fuzzer/fuzzer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/apis/resource/fuzzer/fuzzer.go b/pkg/apis/resource/fuzzer/fuzzer.go index f3203dc6dff..33bfb5bbb95 100644 --- a/pkg/apis/resource/fuzzer/fuzzer.go +++ b/pkg/apis/resource/fuzzer/fuzzer.go @@ -39,6 +39,15 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { }[c.Int31n(2)] } }, + func(r *resource.DeviceSubRequest, c randfill.Continue) { + c.FillNoCustom(r) // fuzz self without calling this function again + if r.AllocationMode == "" { + r.AllocationMode = []resource.DeviceAllocationMode{ + resource.DeviceAllocationModeAll, + resource.DeviceAllocationModeExactCount, + }[c.Int31n(2)] + } + }, func(r *resource.DeviceAllocationConfiguration, c randfill.Continue) { c.FillNoCustom(r) if r.Source == "" {