Skip to content

Commit

Permalink
Merge pull request kubernetes#109770 from fromanirh/e2e-node-device-p…
Browse files Browse the repository at this point in the history
…lugin-skip

e2e: node: explicit skip for device plugin tests
  • Loading branch information
k8s-ci-robot authored May 5, 2022
2 parents 77c37da + 19ae360 commit f092895
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions test/e2e_node/device_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
e2etestfiles "k8s.io/kubernetes/test/e2e/framework/testfiles"
admissionapi "k8s.io/pod-security-admission/api"

Expand Down Expand Up @@ -77,26 +78,6 @@ func numberOfSampleResources(node *v1.Node) int64 {
return val.Value()
}

// getSampleDevicePluginPod returns the Device Plugin pod for sample resources in e2e tests.
func getSampleDevicePluginPod() *v1.Pod {
data, err := e2etestfiles.Read(SampleDevicePluginDSYAML)
if err != nil {
framework.Fail(err.Error())
}

ds := readDaemonSetV1OrDie(data)
p := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: sampleDevicePluginName,
Namespace: metav1.NamespaceSystem,
},

Spec: ds.Spec.Template.Spec,
}

return p
}

// readDaemonSetV1OrDie reads daemonset object from bytes. Panics on error.
func readDaemonSetV1OrDie(objBytes []byte) *appsv1.DaemonSet {
appsv1.AddToScheme(appsScheme)
Expand All @@ -116,6 +97,8 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
var devicePluginPod, dptemplate *v1.Pod

ginkgo.BeforeEach(func() {
e2eskipper.Skipf("Device Plugin tests are currently broken and being investigated")

ginkgo.By("Wait for node to be ready")
gomega.Eventually(func() bool {
nodes, err := e2enode.TotalReady(f.ClientSet)
Expand All @@ -124,8 +107,19 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
}, time.Minute, time.Second).Should(gomega.BeTrue())

ginkgo.By("Scheduling a sample device plugin pod")
dp := getSampleDevicePluginPod()
dp.Namespace = ""
data, err := e2etestfiles.Read(SampleDevicePluginDSYAML)
if err != nil {
framework.Fail(err.Error())
}
ds := readDaemonSetV1OrDie(data)

dp := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: sampleDevicePluginName,
},
Spec: ds.Spec.Template.Spec,
}

for i := range dp.Spec.Containers[0].Env {
if dp.Spec.Containers[0].Env[i].Name == envVarNamePluginSockDir {
dp.Spec.Containers[0].Env[i].Value = pluginSockDir
Expand Down

0 comments on commit f092895

Please sign in to comment.