k8s.io/kubernetes@v1.29.3/test/e2e_node/util_sriov.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package e2enode
    18  
    19  import (
    20  	"k8s.io/kubernetes/test/e2e/framework"
    21  	e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
    22  )
    23  
    24  const (
    25  	// SRIOVDevicePluginCMYAML is the path of the config map to configure the sriov device plugin.
    26  	SRIOVDevicePluginCMYAML = "test/e2e_node/testing-manifests/sriovdp-cm.yaml"
    27  	// SRIOVDevicePluginDSYAML is the path of the daemonset template of the sriov device plugin. // TODO: Parametrize it by making it a feature in TestFramework.
    28  	SRIOVDevicePluginDSYAML = "test/e2e_node/testing-manifests/sriovdp-ds.yaml"
    29  	// SRIOVDevicePluginSAYAML is the path of the service account needed by the sriov device plugin to run.
    30  	SRIOVDevicePluginSAYAML = "test/e2e_node/testing-manifests/sriovdp-sa.yaml"
    31  	// SRIOVDevicePluginName is the name of the device plugin pod
    32  	SRIOVDevicePluginName = "sriov-device-plugin"
    33  )
    34  
    35  func requireSRIOVDevices() {
    36  	sriovdevCount, err := countSRIOVDevices()
    37  	framework.ExpectNoError(err)
    38  
    39  	if sriovdevCount > 0 {
    40  		return // all good
    41  	}
    42  
    43  	msg := "this test is meant to run on a system with at least one configured VF from SRIOV device"
    44  	if framework.TestContext.RequireDevices {
    45  		framework.Failf(msg)
    46  	} else {
    47  		e2eskipper.Skipf(msg)
    48  	}
    49  }