mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-18 17:33:39 +00:00
test/e2e: Improve kubectl subresource e2e test
We now get structured output using jsonpath for the name and version fields of the node object and then compare the outputs. Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
This commit is contained in:
parent
8decaf3ae7
commit
88b498f23e
@ -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))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user