Skip to content

Commit 18139b9

Browse files
committed
Add unit tests
Signed-off-by: Itamar Holder <[email protected]>
1 parent 16871a1 commit 18139b9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/kubelet/nodestatus/setters_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"k8s.io/kubernetes/pkg/kubelet/events"
5050
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
5151
netutils "k8s.io/utils/net"
52+
"k8s.io/utils/ptr"
5253
)
5354

5455
const (
@@ -1330,6 +1331,32 @@ func TestMachineInfo(t *testing.T) {
13301331
},
13311332
},
13321333
},
1334+
{
1335+
desc: "with swap info",
1336+
node: &v1.Node{},
1337+
machineInfo: &cadvisorapiv1.MachineInfo{
1338+
SwapCapacity: uint64(20 * 1024 * 1024 * 1024),
1339+
},
1340+
expectNode: &v1.Node{
1341+
Status: v1.NodeStatus{
1342+
NodeInfo: v1.NodeSystemInfo{
1343+
Swap: &v1.NodeSwapStatus{
1344+
Capacity: ptr.To(int64(20 * 1024 * 1024 * 1024)),
1345+
},
1346+
},
1347+
Capacity: v1.ResourceList{
1348+
v1.ResourceCPU: *resource.NewMilliQuantity(0, resource.DecimalSI),
1349+
v1.ResourceMemory: *resource.NewQuantity(0, resource.BinarySI),
1350+
v1.ResourcePods: *resource.NewQuantity(0, resource.DecimalSI),
1351+
},
1352+
Allocatable: v1.ResourceList{
1353+
v1.ResourceCPU: *resource.NewMilliQuantity(0, resource.DecimalSI),
1354+
v1.ResourceMemory: *resource.NewQuantity(0, resource.BinarySI),
1355+
v1.ResourcePods: *resource.NewQuantity(0, resource.DecimalSI),
1356+
},
1357+
},
1358+
},
1359+
},
13331360
}
13341361

13351362
for _, tc := range cases {

0 commit comments

Comments
 (0)