@@ -17,6 +17,7 @@ limitations under the License.
17
17
package devicemanager
18
18
19
19
import (
20
+ "fmt"
20
21
"path"
21
22
"testing"
22
23
"time"
@@ -26,12 +27,12 @@ import (
26
27
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
27
28
)
28
29
29
- var (
30
- esocketName = "mock.sock"
31
- )
30
+ func esocketName () string {
31
+ return fmt . Sprintf ( "mock%d .sock" , time . Now (). UnixNano ())
32
+ }
32
33
33
34
func TestNewEndpoint (t * testing.T ) {
34
- socket := path .Join ("/tmp" , esocketName )
35
+ socket := path .Join ("/tmp" , esocketName () )
35
36
36
37
devs := []* pluginapi.Device {
37
38
{ID : "ADeviceId" , Health : pluginapi .Healthy },
@@ -42,7 +43,7 @@ func TestNewEndpoint(t *testing.T) {
42
43
}
43
44
44
45
func TestRun (t * testing.T ) {
45
- socket := path .Join ("/tmp" , esocketName )
46
+ socket := path .Join ("/tmp" , esocketName () )
46
47
47
48
devs := []* pluginapi.Device {
48
49
{ID : "ADeviceId" , Health : pluginapi .Healthy },
@@ -107,7 +108,7 @@ func TestRun(t *testing.T) {
107
108
}
108
109
109
110
func TestAllocate (t * testing.T ) {
110
- socket := path .Join ("/tmp" , esocketName )
111
+ socket := path .Join ("/tmp" , esocketName () )
111
112
devs := []* pluginapi.Device {
112
113
{ID : "ADeviceId" , Health : pluginapi .Healthy },
113
114
}
@@ -160,7 +161,7 @@ func TestAllocate(t *testing.T) {
160
161
}
161
162
162
163
func TestGetPreferredAllocation (t * testing.T ) {
163
- socket := path .Join ("/tmp" , esocketName )
164
+ socket := path .Join ("/tmp" , esocketName () )
164
165
callbackCount := 0
165
166
callbackChan := make (chan int )
166
167
p , e := esetup (t , []* pluginapi.Device {}, socket , "mock" , func (n string , d []pluginapi.Device ) {
0 commit comments