Merge pull request #116639 from MadhavJivrajani/improve-e2e-subresource-test

test/e2e: Improve kubectl subresource e2e test
This commit is contained in:
Kubernetes Prow Robot 2023-03-15 07:14:16 -07:00 committed by GitHub
commit 409d055bf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2048,26 +2048,19 @@ metadata:
framework.ExpectNoError(err)
gomega.Expect(nodes.Items).ToNot(gomega.BeEmpty())
node := nodes.Items[0]
ginkgo.By(fmt.Sprintf("calling kubectl get nodes %s", node.Name))
outBuiltIn := e2ekubectl.RunKubectlOrDie("", "get", "nodes", node.Name)
ginkgo.By(fmt.Sprintf("calling kubectl get nodes %s --subresource=status", node.Name))
outStatusSubresource := e2ekubectl.RunKubectlOrDie("", "get", "nodes", node.Name, "--subresource=status")
// Avoid comparing values of fields that might end up
// changing between the two invocations of kubectl.
requiredOutput := [][]string{
{"NAME"},
{"STATUS"},
{"ROLES"},
{"AGE"},
{"VERSION"},
{node.Name}, // check for NAME
{""}, // avoid comparing STATUS
{""}, // avoid comparing ROLES
{""}, // avoid comparing AGE
{node.Status.NodeInfo.KubeletVersion}, // check for VERSION
}
checkOutput(outBuiltIn, requiredOutput)
checkOutput(outStatusSubresource, requiredOutput)
// changing between the two invocations of kubectl. We
// compare the name and version fields.
ginkgo.By(fmt.Sprintf("calling kubectl get nodes %s", node.Name))
outBuiltIn := e2ekubectl.RunKubectlOrDie("", "get", "nodes", node.Name,
"--output=jsonpath='{.metadata.name}{.status.nodeInfo.kubeletVersion}'",
)
ginkgo.By(fmt.Sprintf("calling kubectl get nodes %s --subresource=status", node.Name))
outStatusSubresource := e2ekubectl.RunKubectlOrDie("", "get", "nodes", node.Name,
"--output=jsonpath='{.metadata.name}{.status.nodeInfo.kubeletVersion}'",
"--subresource=status",
)
gomega.Expect(outBuiltIn).To(gomega.Equal(outStatusSubresource))
})
})
})