node: e2e: ensure clean cluster state before e2e tests are run

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
This commit is contained in:
Swati Sehgal 2022-10-24 16:57:30 +01:00
parent 7e880d1bab
commit a9e3689e63

View File

@ -94,7 +94,9 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
// and then use the same here
devsLen := int64(2)
var devicePluginPod, dptemplate *v1.Pod
var v1alphaPodResources *kubeletpodresourcesv1alpha1.ListPodResourcesResponse
var v1PodResources *kubeletpodresourcesv1.ListPodResourcesResponse
var err error
ginkgo.BeforeEach(func() {
ginkgo.By("Wait for node to be ready")
gomega.Eventually(func() bool {
@ -103,6 +105,18 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
return nodes == 1
}, time.Minute, time.Second).Should(gomega.BeTrue())
v1alphaPodResources, err = getV1alpha1NodeDevices()
framework.ExpectNoError(err)
v1PodResources, err = getV1NodeDevices()
framework.ExpectNoError(err)
// Before we run the device plugin test, we need to ensure
// that the cluster is in a clean state and there are no
// pods running on this node.
framework.ExpectEqual(len(v1alphaPodResources.PodResources), 0)
framework.ExpectEqual(len(v1PodResources.PodResources), 0)
ginkgo.By("Scheduling a sample device plugin pod")
data, err := e2etestfiles.Read(SampleDevicePluginDSYAML)
if err != nil {
@ -175,10 +189,10 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
devID1 := parseLog(f, pod1.Name, pod1.Name, deviceIDRE)
gomega.Expect(devID1).To(gomega.Not(gomega.Equal("")))
v1alphaPodResources, err := getV1alpha1NodeDevices()
v1alphaPodResources, err = getV1alpha1NodeDevices()
framework.ExpectNoError(err)
v1PodResources, err := getV1NodeDevices()
v1PodResources, err = getV1NodeDevices()
framework.ExpectNoError(err)
framework.Logf("v1alphaPodResources.PodResources:%+v\n", v1alphaPodResources.PodResources)