Skip to content

Commit c4cf7d3

Browse files
authored
Merge pull request kubernetes#94539 from liggitt/deflake-cmdevice
Use unique socket name per cm test
2 parents 1a04aac + 803da10 commit c4cf7d3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/kubelet/cm/devicemanager/endpoint_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package devicemanager
1818

1919
import (
20+
"fmt"
2021
"path"
2122
"testing"
2223
"time"
@@ -26,12 +27,12 @@ import (
2627
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
2728
)
2829

29-
var (
30-
esocketName = "mock.sock"
31-
)
30+
func esocketName() string {
31+
return fmt.Sprintf("mock%d.sock", time.Now().UnixNano())
32+
}
3233

3334
func TestNewEndpoint(t *testing.T) {
34-
socket := path.Join("/tmp", esocketName)
35+
socket := path.Join("/tmp", esocketName())
3536

3637
devs := []*pluginapi.Device{
3738
{ID: "ADeviceId", Health: pluginapi.Healthy},
@@ -42,7 +43,7 @@ func TestNewEndpoint(t *testing.T) {
4243
}
4344

4445
func TestRun(t *testing.T) {
45-
socket := path.Join("/tmp", esocketName)
46+
socket := path.Join("/tmp", esocketName())
4647

4748
devs := []*pluginapi.Device{
4849
{ID: "ADeviceId", Health: pluginapi.Healthy},
@@ -107,7 +108,7 @@ func TestRun(t *testing.T) {
107108
}
108109

109110
func TestAllocate(t *testing.T) {
110-
socket := path.Join("/tmp", esocketName)
111+
socket := path.Join("/tmp", esocketName())
111112
devs := []*pluginapi.Device{
112113
{ID: "ADeviceId", Health: pluginapi.Healthy},
113114
}
@@ -160,7 +161,7 @@ func TestAllocate(t *testing.T) {
160161
}
161162

162163
func TestGetPreferredAllocation(t *testing.T) {
163-
socket := path.Join("/tmp", esocketName)
164+
socket := path.Join("/tmp", esocketName())
164165
callbackCount := 0
165166
callbackChan := make(chan int)
166167
p, e := esetup(t, []*pluginapi.Device{}, socket, "mock", func(n string, d []pluginapi.Device) {

0 commit comments

Comments
 (0)