@@ -348,7 +348,7 @@ func TestUpdateCapacityAllocatable(t *testing.T) {
348
348
testManager , err := newManagerImpl (socketName , nil , topologyStore )
349
349
as := assert .New (t )
350
350
as .NotNil (testManager )
351
- as .Nil (err )
351
+ as .NoError (err )
352
352
353
353
devs := []pluginapi.Device {
354
354
{ID : "Device1" , Health : pluginapi .Healthy },
@@ -464,11 +464,11 @@ func TestUpdateCapacityAllocatable(t *testing.T) {
464
464
// during the time of propagating capacity change to the scheduler will be
465
465
// properly rejected instead of being incorrectly started.
466
466
err = testManager .writeCheckpoint ()
467
- as .Nil (err )
467
+ as .NoError (err )
468
468
testManager .healthyDevices = make (map [string ]sets.Set [string ])
469
469
testManager .unhealthyDevices = make (map [string ]sets.Set [string ])
470
470
err = testManager .readCheckpoint ()
471
- as .Nil (err )
471
+ as .NoError (err )
472
472
as .Len (testManager .endpoints , 1 )
473
473
as .Contains (testManager .endpoints , resourceName2 )
474
474
capacity , allocatable , removed = testManager .GetCapacity ()
@@ -490,7 +490,7 @@ func TestGetAllocatableDevicesMultipleResources(t *testing.T) {
490
490
testManager , err := newManagerImpl (socketName , nil , topologyStore )
491
491
as := assert .New (t )
492
492
as .NotNil (testManager )
493
- as .Nil (err )
493
+ as .NoError (err )
494
494
495
495
resource1Devs := []pluginapi.Device {
496
496
{ID : "R1Device1" , Health : pluginapi .Healthy },
@@ -531,7 +531,7 @@ func TestGetAllocatableDevicesHealthTransition(t *testing.T) {
531
531
testManager , err := newManagerImpl (socketName , nil , topologyStore )
532
532
as := assert .New (t )
533
533
as .NotNil (testManager )
534
- as .Nil (err )
534
+ as .NoError (err )
535
535
536
536
resource1Devs := []pluginapi.Device {
537
537
{ID : "R1Device1" , Health : pluginapi .Healthy },
@@ -673,10 +673,10 @@ func TestCheckpoint(t *testing.T) {
673
673
resourceName3 := "domain2.com/resource3"
674
674
as := assert .New (t )
675
675
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
676
- as .Nil (err )
676
+ as .NoError (err )
677
677
defer os .RemoveAll (tmpDir )
678
678
ckm , err := checkpointmanager .NewCheckpointManager (tmpDir )
679
- as .Nil (err )
679
+ as .NoError (err )
680
680
testManager := & ManagerImpl {
681
681
endpoints : make (map [string ]endpointInfo ),
682
682
healthyDevices : make (map [string ]sets.Set [string ]),
@@ -742,10 +742,10 @@ func TestCheckpoint(t *testing.T) {
742
742
743
743
err = testManager .writeCheckpoint ()
744
744
745
- as .Nil (err )
745
+ as .NoError (err )
746
746
testManager .podDevices = newPodDevices ()
747
747
err = testManager .readCheckpoint ()
748
- as .Nil (err )
748
+ as .NoError (err )
749
749
750
750
as .Equal (expectedPodDevices .size (), testManager .podDevices .size ())
751
751
for podUID , containerDevices := range expectedPodDevices .devs {
@@ -1007,10 +1007,10 @@ func TestPodContainerDeviceAllocation(t *testing.T) {
1007
1007
activePods : []* v1.Pod {},
1008
1008
}
1009
1009
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1010
- as .Nil (err )
1010
+ as .NoError (err )
1011
1011
defer os .RemoveAll (tmpDir )
1012
1012
testManager , err := getTestManager (tmpDir , podsStub .getActivePods , testResources )
1013
- as .Nil (err )
1013
+ as .NoError (err )
1014
1014
1015
1015
testPods := []* v1.Pod {
1016
1016
makePod (v1.ResourceList {
@@ -1067,7 +1067,7 @@ func TestPodContainerDeviceAllocation(t *testing.T) {
1067
1067
}
1068
1068
runContainerOpts , err := testManager .GetDeviceRunContainerOptions (pod , & pod .Spec .Containers [0 ])
1069
1069
if testCase .expErr == nil {
1070
- as .Nil (err )
1070
+ as .NoError (err )
1071
1071
}
1072
1072
if testCase .expectedContainerOptsLen == nil {
1073
1073
as .Nil (runContainerOpts )
@@ -1088,7 +1088,7 @@ func TestPodContainerDeviceToAllocate(t *testing.T) {
1088
1088
resourceName3 := "domain2.com/resource3"
1089
1089
as := require .New (t )
1090
1090
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1091
- as .Nil (err )
1091
+ as .NoError (err )
1092
1092
defer os .RemoveAll (tmpDir )
1093
1093
1094
1094
testManager := & ManagerImpl {
@@ -1273,11 +1273,11 @@ func TestGetDeviceRunContainerOptions(t *testing.T) {
1273
1273
as := require .New (t )
1274
1274
1275
1275
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1276
- as .Nil (err )
1276
+ as .NoError (err )
1277
1277
defer os .RemoveAll (tmpDir )
1278
1278
1279
1279
testManager , err := getTestManager (tmpDir , podsStub .getActivePods , testResources )
1280
- as .Nil (err )
1280
+ as .NoError (err )
1281
1281
1282
1282
pod1 := makePod (v1.ResourceList {
1283
1283
v1 .ResourceName (res1 .resourceName ): res1 .resourceQuantity ,
@@ -1291,13 +1291,13 @@ func TestGetDeviceRunContainerOptions(t *testing.T) {
1291
1291
podsStub .updateActivePods (activePods )
1292
1292
1293
1293
err = testManager .Allocate (pod1 , & pod1 .Spec .Containers [0 ])
1294
- as .Nil (err )
1294
+ as .NoError (err )
1295
1295
err = testManager .Allocate (pod2 , & pod2 .Spec .Containers [0 ])
1296
- as .Nil (err )
1296
+ as .NoError (err )
1297
1297
1298
1298
// when pod is in activePods, GetDeviceRunContainerOptions should return
1299
1299
runContainerOpts , err := testManager .GetDeviceRunContainerOptions (pod1 , & pod1 .Spec .Containers [0 ])
1300
- as .Nil (err )
1300
+ as .NoError (err )
1301
1301
as .Len (runContainerOpts .Devices , 3 )
1302
1302
as .Len (runContainerOpts .Mounts , 2 )
1303
1303
as .Len (runContainerOpts .Envs , 2 )
@@ -1308,7 +1308,7 @@ func TestGetDeviceRunContainerOptions(t *testing.T) {
1308
1308
1309
1309
// when pod is removed from activePods,G etDeviceRunContainerOptions should return error
1310
1310
runContainerOpts , err = testManager .GetDeviceRunContainerOptions (pod1 , & pod1 .Spec .Containers [0 ])
1311
- as .Nil (err )
1311
+ as .NoError (err )
1312
1312
as .Nil (runContainerOpts )
1313
1313
}
1314
1314
@@ -1335,11 +1335,11 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
1335
1335
activePods : []* v1.Pod {},
1336
1336
}
1337
1337
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1338
- as .Nil (err )
1338
+ as .NoError (err )
1339
1339
defer os .RemoveAll (tmpDir )
1340
1340
1341
1341
testManager , err := getTestManager (tmpDir , podsStub .getActivePods , testResources )
1342
- as .Nil (err )
1342
+ as .NoError (err )
1343
1343
1344
1344
podWithPluginResourcesInInitContainers := & v1.Pod {
1345
1345
ObjectMeta : metav1.ObjectMeta {
@@ -1393,7 +1393,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
1393
1393
for _ , container := range podWithPluginResourcesInInitContainers .Spec .Containers {
1394
1394
err = testManager .Allocate (podWithPluginResourcesInInitContainers , & container )
1395
1395
}
1396
- as .Nil (err )
1396
+ as .NoError (err )
1397
1397
podUID := string (podWithPluginResourcesInInitContainers .UID )
1398
1398
initCont1 := podWithPluginResourcesInInitContainers .Spec .InitContainers [0 ].Name
1399
1399
initCont2 := podWithPluginResourcesInInitContainers .Spec .InitContainers [1 ].Name
@@ -1436,11 +1436,11 @@ func TestRestartableInitContainerDeviceAllocation(t *testing.T) {
1436
1436
activePods : []* v1.Pod {},
1437
1437
}
1438
1438
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1439
- as .Nil (err )
1439
+ as .NoError (err )
1440
1440
defer os .RemoveAll (tmpDir )
1441
1441
1442
1442
testManager , err := getTestManager (tmpDir , podsStub .getActivePods , testResources )
1443
- as .Nil (err )
1443
+ as .NoError (err )
1444
1444
1445
1445
containerRestartPolicyAlways := v1 .ContainerRestartPolicyAlways
1446
1446
podWithPluginResourcesInRestartableInitContainers := & v1.Pod {
@@ -1503,7 +1503,7 @@ func TestRestartableInitContainerDeviceAllocation(t *testing.T) {
1503
1503
for _ , container := range podWithPluginResourcesInRestartableInitContainers .Spec .Containers {
1504
1504
err = testManager .Allocate (podWithPluginResourcesInRestartableInitContainers , & container )
1505
1505
}
1506
- as .Nil (err )
1506
+ as .NoError (err )
1507
1507
podUID := string (podWithPluginResourcesInRestartableInitContainers .UID )
1508
1508
regularInitCont1 := podWithPluginResourcesInRestartableInitContainers .Spec .InitContainers [0 ].Name
1509
1509
restartableInitCont2 := podWithPluginResourcesInRestartableInitContainers .Spec .InitContainers [1 ].Name
@@ -1553,11 +1553,11 @@ func TestUpdatePluginResources(t *testing.T) {
1553
1553
as := assert .New (t )
1554
1554
monitorCallback := func (resourceName string , devices []pluginapi.Device ) {}
1555
1555
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1556
- as .Nil (err )
1556
+ as .NoError (err )
1557
1557
defer os .RemoveAll (tmpDir )
1558
1558
1559
1559
ckm , err := checkpointmanager .NewCheckpointManager (tmpDir )
1560
- as .Nil (err )
1560
+ as .NoError (err )
1561
1561
m := & ManagerImpl {
1562
1562
allocatedDevices : make (map [string ]sets.Set [string ]),
1563
1563
healthyDevices : make (map [string ]sets.Set [string ]),
@@ -1611,11 +1611,11 @@ func TestDevicePreStartContainer(t *testing.T) {
1611
1611
activePods : []* v1.Pod {},
1612
1612
}
1613
1613
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1614
- as .Nil (err )
1614
+ as .NoError (err )
1615
1615
defer os .RemoveAll (tmpDir )
1616
1616
1617
1617
testManager , err := getTestManager (tmpDir , podsStub .getActivePods , []TestResource {res1 })
1618
- as .Nil (err )
1618
+ as .NoError (err )
1619
1619
1620
1620
ch := make (chan []string , 1 )
1621
1621
testManager .endpoints [res1 .resourceName ] = endpointInfo {
@@ -1631,9 +1631,9 @@ func TestDevicePreStartContainer(t *testing.T) {
1631
1631
activePods = append (activePods , pod )
1632
1632
podsStub .updateActivePods (activePods )
1633
1633
err = testManager .Allocate (pod , & pod .Spec .Containers [0 ])
1634
- as .Nil (err )
1634
+ as .NoError (err )
1635
1635
runContainerOpts , err := testManager .GetDeviceRunContainerOptions (pod , & pod .Spec .Containers [0 ])
1636
- as .Nil (err )
1636
+ as .NoError (err )
1637
1637
var initializedDevs []string
1638
1638
select {
1639
1639
case <- time .After (time .Second ):
@@ -1647,7 +1647,7 @@ func TestDevicePreStartContainer(t *testing.T) {
1647
1647
as .Equal (len (initializedDevs ), res1 .devs .Devices ().Len ())
1648
1648
1649
1649
expectedResps , err := allocateStubFunc ()([]string {"dev1" , "dev2" })
1650
- as .Nil (err )
1650
+ as .NoError (err )
1651
1651
as .Len (expectedResps .ContainerResponses , 1 )
1652
1652
expectedResp := expectedResps .ContainerResponses [0 ]
1653
1653
as .Equal (len (runContainerOpts .Devices ), len (expectedResp .Devices ))
@@ -1659,9 +1659,9 @@ func TestDevicePreStartContainer(t *testing.T) {
1659
1659
activePods = append (activePods , pod2 )
1660
1660
podsStub .updateActivePods (activePods )
1661
1661
err = testManager .Allocate (pod2 , & pod2 .Spec .Containers [0 ])
1662
- as .Nil (err )
1662
+ as .NoError (err )
1663
1663
_ , err = testManager .GetDeviceRunContainerOptions (pod2 , & pod2 .Spec .Containers [0 ])
1664
- as .Nil (err )
1664
+ as .NoError (err )
1665
1665
select {
1666
1666
case <- time .After (time .Millisecond ):
1667
1667
t .Log ("When pod resourceQuantity is 0, PreStartContainer RPC stub will be skipped" )
@@ -1673,10 +1673,10 @@ func TestDevicePreStartContainer(t *testing.T) {
1673
1673
func TestResetExtendedResource (t * testing.T ) {
1674
1674
as := assert .New (t )
1675
1675
tmpDir , err := os .MkdirTemp ("" , "checkpoint" )
1676
- as .Nil (err )
1676
+ as .NoError (err )
1677
1677
defer os .RemoveAll (tmpDir )
1678
1678
ckm , err := checkpointmanager .NewCheckpointManager (tmpDir )
1679
- as .Nil (err )
1679
+ as .NoError (err )
1680
1680
testManager := & ManagerImpl {
1681
1681
endpoints : make (map [string ]endpointInfo ),
1682
1682
healthyDevices : make (map [string ]sets.Set [string ]),
@@ -1699,16 +1699,16 @@ func TestResetExtendedResource(t *testing.T) {
1699
1699
testManager .healthyDevices [extendedResourceName ].Insert ("dev1" )
1700
1700
// checkpoint is present, indicating node hasn't been recreated
1701
1701
err = testManager .writeCheckpoint ()
1702
- as . Nil ( err )
1702
+ require . NoError ( t , err )
1703
1703
1704
1704
as .False (testManager .ShouldResetExtendedResourceCapacity ())
1705
1705
1706
1706
// checkpoint is absent, representing node recreation
1707
1707
ckpts , err := ckm .ListCheckpoints ()
1708
- as .Nil (err )
1708
+ as .NoError (err )
1709
1709
for _ , ckpt := range ckpts {
1710
1710
err = ckm .RemoveCheckpoint (ckpt )
1711
- as .Nil (err )
1711
+ as .NoError (err )
1712
1712
}
1713
1713
as .True (testManager .ShouldResetExtendedResourceCapacity ())
1714
1714
}
0 commit comments