package utils
import "k8s.io/kubernetes/test/e2e/dra/utils"
Index ¶
- func DriverResources(maxAllocations int, devicesPerNode ...map[string]map[resourceapi.QualifiedName]resourceapi.DeviceAttribute) driverResourcesGenFunc
- func DriverResourcesNow(nodes *Nodes, maxAllocations int, devicesPerNode ...map[string]map[resourceapi.QualifiedName]resourceapi.DeviceAttribute) map[string]resourceslice.DriverResources
- func ExtendedResourceName(i int) string
- func NetworkResources(maxAllocations int, tainted bool) driverResourcesGenFunc
- func TaintAllDevices(taints ...resourceapi.DeviceTaint) driverResourcesMutatorFunc
- func TestContainerEnv(ctx context.Context, f *framework.Framework, pod *v1.Pod, containerName string, fullMatch bool, env ...string)
- func ToDriverResources(counters []resourceapi.CounterSet, devices ...resourceapi.Device) driverResourcesGenFunc
- type Builder
- func NewBuilder(f *framework.Framework, driver *Driver) *Builder
- func NewBuilderNow(ctx context.Context, f *framework.Framework, driver *Driver) *Builder
- func (b *Builder) ClaimSpec() resourceapi.ResourceClaimSpec
- func (b *Builder) Class(i int) *resourceapi.DeviceClass
- func (b *Builder) ClassName() string
- func (b *Builder) ClientV1() cgoresource.ResourceV1Interface
- func (b *Builder) Create(ctx context.Context, objs ...klog.KMetadata) []klog.KMetadata
- func (b *Builder) DeletePodAndWaitForNotFound(ctx context.Context, pod *v1.Pod)
- func (b *Builder) ExternalClaim() *resourceapi.ResourceClaim
- func (b *Builder) ParametersEnv() (string, []string)
- func (b *Builder) Pod() *v1.Pod
- func (b *Builder) PodExternal() *v1.Pod
- func (b *Builder) PodExternalMultiple() *v1.Pod
- func (b *Builder) PodInline() (*v1.Pod, *resourceapi.ResourceClaimTemplate)
- func (b *Builder) PodInlineMultiple() (*v1.Pod, *resourceapi.ResourceClaimTemplate)
- func (b *Builder) PodInlineWithV1beta1() (*v1.Pod, *resourcev1beta1.ResourceClaimTemplate)
- func (b *Builder) PodInlineWithV1beta2() (*v1.Pod, *resourcev1beta2.ResourceClaimTemplate)
- func (b *Builder) TestPod(ctx context.Context, f *framework.Framework, pod *v1.Pod, env ...string)
- type Driver
- func NewDriver(f *framework.Framework, nodes *Nodes, driverResourcesGenerator driverResourcesGenFunc, driverResourcesMutators ...driverResourcesMutatorFunc) *Driver
- func NewDriverInstance(f *framework.Framework) *Driver
- func (d *Driver) CallCount(m MethodInstance) int64
- func (d *Driver) ClientV1() cgoresource.ResourceV1Interface
- func (d *Driver) Fail(m MethodInstance, injectError bool)
- func (d *Driver) ImpersonateKubeletPlugin(pod *v1.Pod) kubernetes.Interface
- func (d *Driver) IsGone(ctx context.Context)
- func (d *Driver) NewGetSlices() framework.GetFunc[*resourceapi.ResourceSliceList]
- func (d *Driver) Nodenames() (nodenames []string)
- func (d *Driver) Run(nodes *Nodes, driverResources map[string]resourceslice.DriverResources)
- func (d *Driver) SetUp(nodes *Nodes, driverResources map[string]resourceslice.DriverResources)
- func (d *Driver) TearDown(ctx context.Context)
- type KubeletPlugin
- type MethodInstance
- type Nodes
Functions ¶
func DriverResources ¶
func DriverResources(maxAllocations int, devicesPerNode ...map[string]map[resourceapi.QualifiedName]resourceapi.DeviceAttribute) driverResourcesGenFunc
func DriverResourcesNow ¶
func DriverResourcesNow(nodes *Nodes, maxAllocations int, devicesPerNode ...map[string]map[resourceapi.QualifiedName]resourceapi.DeviceAttribute) map[string]resourceslice.DriverResources
func ExtendedResourceName ¶
ExtendedResourceName returns hard coded extended resource name with a variable suffix from the input integer when it's greater than or equal to 0. "example.com/resource" is not special, any valid extended resource name can be used instead, except when using example device plugin in the test, which hard coded it, see test/e2e/dra/deploy_device_plugin.go. i == -1 is special, the extended resource name has no extra suffix, it is used in the test where a cluster has both DRA driver and device plugin.
func NetworkResources ¶
func TaintAllDevices ¶
func TaintAllDevices(taints ...resourceapi.DeviceTaint) driverResourcesMutatorFunc
func TestContainerEnv ¶
func TestContainerEnv(ctx context.Context, f *framework.Framework, pod *v1.Pod, containerName string, fullMatch bool, env ...string)
func ToDriverResources ¶
func ToDriverResources(counters []resourceapi.CounterSet, devices ...resourceapi.Device) driverResourcesGenFunc
Types ¶
type Builder ¶
type Builder struct { UseExtendedResourceName bool ClassParameters string // JSON // contains filtered or unexported fields }
Builder contains a running counter to make objects unique within thir namespace.
func NewBuilder ¶
func NewBuilderNow ¶
func (*Builder) ClaimSpec ¶
func (b *Builder) ClaimSpec() resourceapi.ResourceClaimSpec
claimSpecWithV1beta2 returns the device request for a claim or claim template with the associated config using the latest API.
func (*Builder) Class ¶
func (b *Builder) Class(i int) *resourceapi.DeviceClass
Class returns the device Class that the builder's other objects reference. The input i is used to pick the extended resource name whose suffix has the same i for the device class. i == -1 is special, the extended resource name has no extra suffix, it is used in the test where a cluster has both DRA driver and device plugin.
func (*Builder) ClassName ¶
ClassName returns the default device class name.
func (*Builder) ClientV1 ¶
func (b *Builder) ClientV1() cgoresource.ResourceV1Interface
ClientV1 returns a wrapper for client-go which provides the V1 API on top of whatever is enabled in the cluster.
func (*Builder) Create ¶
Create takes a bunch of objects and calls their Create function.
func (*Builder) DeletePodAndWaitForNotFound ¶
func (*Builder) ExternalClaim ¶
func (b *Builder) ExternalClaim() *resourceapi.ResourceClaim
ExternalClaim returns external resource claim that test pods can reference
func (*Builder) ParametersEnv ¶
ParametersEnv returns the default user env variables as JSON (config) and key/value list (pod env).
func (*Builder) Pod ¶
makePod returns a simple Pod with no resource claims. The Pod prints its env and waits.
func (*Builder) PodExternal ¶
PodExternal adds a pod that references external resource claim with default class name and parameters.
func (*Builder) PodExternalMultiple ¶
podShared returns a pod with 3 containers that reference external resource claim with default class name and parameters.
func (*Builder) PodInline ¶
func (b *Builder) PodInline() (*v1.Pod, *resourceapi.ResourceClaimTemplate)
makePodInline adds an inline resource claim with default class name and parameters.
func (*Builder) PodInlineMultiple ¶
func (b *Builder) PodInlineMultiple() (*v1.Pod, *resourceapi.ResourceClaimTemplate)
func (*Builder) PodInlineWithV1beta1 ¶
func (b *Builder) PodInlineWithV1beta1() (*v1.Pod, *resourcev1beta1.ResourceClaimTemplate)
func (*Builder) PodInlineWithV1beta2 ¶
func (b *Builder) PodInlineWithV1beta2() (*v1.Pod, *resourcev1beta2.ResourceClaimTemplate)
func (*Builder) TestPod ¶
TestPod runs pod and checks if container logs contain expected environment variables
type Driver ¶
type Driver struct { // NameSuffix can be set while registering a test to deploy different // drivers in the same test namespace. NameSuffix string // InstanceSuffix can be set while registering a test to deploy two different // instances of the same driver. Used to generate unique objects in the API server. // The socket path is still the same. InstanceSuffix string // RollingUpdate can be set to true to enable using different socket names // for different pods and thus seamless upgrades. Must be supported by the kubelet! RollingUpdate bool // Normally, tearing down the driver should cause ResourceSlices to get removed eventually. // The exception is when the driver is part of a rolling update and is torn down first. ExpectResourceSliceRemoval bool // Name gets derived automatically from the current test namespace and // (if set) the NameSuffix while setting up the driver for a test. Name string // Nodes contains entries for each node selected for a test when the test runs. // In addition, there is one entry for a fictional node. Nodes map[string]KubeletPlugin // IsLocal can be set to true when using local-up-cluster.sh *and* ensuring // that /var/lib/kubelet/plugins, /var/lib/kubelet/plugins_registry and // /var/run/cdi are writable by the current user. IsLocal bool NodeV1 bool NodeV1beta1 bool // Register the DRA test driver with the kubelet and expect DRA to work (= feature.DynamicResourceAllocation). WithKubelet bool // contains filtered or unexported fields }
func NewDriver ¶
func NewDriver(f *framework.Framework, nodes *Nodes, driverResourcesGenerator driverResourcesGenFunc, driverResourcesMutators ...driverResourcesMutatorFunc) *Driver
NewDriver sets up controller (as client of the cluster) and kubelet plugin (via proxy) before the test runs. It cleans up after the test.
Call this outside of ginkgo.It, then use the instance inside ginkgo.It.
func NewDriverInstance ¶
NewDriverInstance is a variant of NewDriver where the driver is inactive and must be started explicitly with Run. May be used inside ginkgo.It.
func (*Driver) CallCount ¶
func (d *Driver) CallCount(m MethodInstance) int64
func (*Driver) ClientV1 ¶
func (d *Driver) ClientV1() cgoresource.ResourceV1Interface
ClientV1 returns a wrapper for client-go which provides the V1 API on top of whatever is enabled in the cluster.
func (*Driver) Fail ¶
func (d *Driver) Fail(m MethodInstance, injectError bool)
func (*Driver) ImpersonateKubeletPlugin ¶
func (d *Driver) ImpersonateKubeletPlugin(pod *v1.Pod) kubernetes.Interface
func (*Driver) IsGone ¶
IsGone checks that the kubelet is done with the driver. This is done by waiting for the kubelet to remove the driver's ResourceSlices, which takes at least 30 seconds because of the delay in the kubelet.
Only use this in tests where kubelet support for DRA is guaranteed.
func (*Driver) NewGetSlices ¶
func (d *Driver) NewGetSlices() framework.GetFunc[*resourceapi.ResourceSliceList]
NewGetSlices generates a function for gomega.Eventually/Consistently which returns the ResourceSliceList.
func (*Driver) Nodenames ¶
func (*Driver) Run ¶
func (d *Driver) Run(nodes *Nodes, driverResources map[string]resourceslice.DriverResources)
func (*Driver) SetUp ¶
func (d *Driver) SetUp(nodes *Nodes, driverResources map[string]resourceslice.DriverResources)
func (*Driver) TearDown ¶
type KubeletPlugin ¶
type KubeletPlugin struct { *app.ExamplePlugin ClientSet kubernetes.Interface }
type MethodInstance ¶
type Nodes ¶
type Nodes struct { // NodeNames has the main set of node names. NodeNames []string // NumReservedNodes specifies the desired number of // extra nodes that get set aside. That many node names // will be stored in ExtraNodeNames. // // Must be <= the minimum number of requested nodes. NumReservedNodes int // ExtraNodeNames has exactly as many node names as // requested via NumReservedNodes. Those nodes are // different than the nodes listed in NodeNames. ExtraNodeNames []string // contains filtered or unexported fields }
func NewNodes ¶
NewNodes selects nodes to run the test on.
Call this outside of ginkgo.It, then use the instance inside ginkgo.It.
func NewNodesNow ¶
NewNodesNow is a variant of NewNodes which can be used inside a ginkgo.It.
Source Files ¶
builder.go deploy.go
- Version
- v1.34.0-rc.0
- Published
- Aug 6, 2025
- Platform
- js/wasm
- Imports
- 66 packages
- Last checked
- 30 minutes ago –
Tools for package owners.