mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
devicemanager testing: time out sooner
Each individual step should not take longer than a second. Suggest by Vikas Choudhary (https://github.com/kubernetes/kubernetes/pull/59489#discussion_r167205672).
This commit is contained in:
parent
1325c2f8be
commit
0d828e061b
@ -24,6 +24,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -99,7 +100,12 @@ func TestDevicePluginReRegistration(t *testing.T) {
|
|||||||
p1.Register(socketName, testResourceName)
|
p1.Register(socketName, testResourceName)
|
||||||
// Wait for the first callback to be issued.
|
// Wait for the first callback to be issued.
|
||||||
|
|
||||||
<-callbackChan
|
select {
|
||||||
|
case <-callbackChan:
|
||||||
|
break
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
devices := m.Devices()
|
devices := m.Devices()
|
||||||
require.Equal(t, 2, len(devices[testResourceName]), "Devices are not updated.")
|
require.Equal(t, 2, len(devices[testResourceName]), "Devices are not updated.")
|
||||||
|
|
||||||
@ -109,7 +115,12 @@ func TestDevicePluginReRegistration(t *testing.T) {
|
|||||||
atomic.StoreInt32(&expCallbackCount, 2)
|
atomic.StoreInt32(&expCallbackCount, 2)
|
||||||
p2.Register(socketName, testResourceName)
|
p2.Register(socketName, testResourceName)
|
||||||
// Wait for the second callback to be issued.
|
// Wait for the second callback to be issued.
|
||||||
<-callbackChan
|
select {
|
||||||
|
case <-callbackChan:
|
||||||
|
break
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
devices2 := m.Devices()
|
devices2 := m.Devices()
|
||||||
require.Equal(t, 2, len(devices2[testResourceName]), "Devices shouldn't change.")
|
require.Equal(t, 2, len(devices2[testResourceName]), "Devices shouldn't change.")
|
||||||
@ -121,7 +132,12 @@ func TestDevicePluginReRegistration(t *testing.T) {
|
|||||||
atomic.StoreInt32(&expCallbackCount, 3)
|
atomic.StoreInt32(&expCallbackCount, 3)
|
||||||
p3.Register(socketName, testResourceName)
|
p3.Register(socketName, testResourceName)
|
||||||
// Wait for the second callback to be issued.
|
// Wait for the second callback to be issued.
|
||||||
<-callbackChan
|
select {
|
||||||
|
case <-callbackChan:
|
||||||
|
break
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
devices3 := m.Devices()
|
devices3 := m.Devices()
|
||||||
require.Equal(t, 1, len(devices3[testResourceName]), "Devices of plugin previously registered should be removed.")
|
require.Equal(t, 1, len(devices3[testResourceName]), "Devices of plugin previously registered should be removed.")
|
||||||
|
Loading…
Reference in New Issue
Block a user