Add kubectl describe CSINode test coverage
Kubernetes-commit: 991547edb6bc5d9302034fbb94b97204ea951348
This commit is contained in:
parent
22018fa262
commit
ff83e52b28
|
@ -4032,7 +4032,7 @@ func describeCSINode(csi *storagev1.CSINode, events *corev1.EventList) (output s
|
||||||
for _, driver := range csi.Spec.Drivers {
|
for _, driver := range csi.Spec.Drivers {
|
||||||
w.Write(LEVEL_2, "%s:\n", driver.Name)
|
w.Write(LEVEL_2, "%s:\n", driver.Name)
|
||||||
w.Write(LEVEL_3, "Node ID:\t%s\n", driver.NodeID)
|
w.Write(LEVEL_3, "Node ID:\t%s\n", driver.NodeID)
|
||||||
if driver.Allocatable.Count != nil {
|
if driver.Allocatable != nil && driver.Allocatable.Count != nil {
|
||||||
w.Write(LEVEL_3, "Allocatables:\n")
|
w.Write(LEVEL_3, "Allocatables:\n")
|
||||||
w.Write(LEVEL_4, "Count:\t%d\n", *driver.Allocatable.Count)
|
w.Write(LEVEL_4, "Count:\t%d\n", *driver.Allocatable.Count)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1780,6 +1780,38 @@ func TestDescribeStorageClass(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDescribeCSINode(t *testing.T) {
|
||||||
|
limit := utilpointer.Int32Ptr(int32(2))
|
||||||
|
f := fake.NewSimpleClientset(&storagev1.CSINode{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||||
|
Spec: storagev1.CSINodeSpec{
|
||||||
|
Drivers: []storagev1.CSINodeDriver{
|
||||||
|
{
|
||||||
|
Name: "driver1",
|
||||||
|
NodeID: "node1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "driver2",
|
||||||
|
NodeID: "node2",
|
||||||
|
Allocatable: &storagev1.VolumeNodeResources{Count: limit},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
s := CSINodeDescriber{f}
|
||||||
|
out, err := s.Describe("", "foo", DescriberSettings{ShowEvents: true})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(out, "foo") ||
|
||||||
|
!strings.Contains(out, "driver1") ||
|
||||||
|
!strings.Contains(out, "node1") ||
|
||||||
|
!strings.Contains(out, "driver2") ||
|
||||||
|
!strings.Contains(out, "node2") {
|
||||||
|
t.Errorf("unexpected out: %s", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDescribePodDisruptionBudget(t *testing.T) {
|
func TestDescribePodDisruptionBudget(t *testing.T) {
|
||||||
minAvailable := intstr.FromInt(22)
|
minAvailable := intstr.FromInt(22)
|
||||||
f := fake.NewSimpleClientset(&policyv1beta1.PodDisruptionBudget{
|
f := fake.NewSimpleClientset(&policyv1beta1.PodDisruptionBudget{
|
||||||
|
|
Loading…
Reference in New Issue