@@ -22,7 +22,6 @@ import (
22
22
23
23
"github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/internal"
24
24
"github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/proxy"
25
- "github.com/sirupsen/logrus"
26
25
"github.com/stretchr/testify/require"
27
26
"go.uber.org/goleak"
28
27
)
@@ -49,8 +48,8 @@ func TestCacheEvictionOnConnectionFailure(t *testing.T) {
49
48
return nil , errors .New ("mock dial error" )
50
49
}
51
50
frequency := 2 * time .Millisecond
52
- log := logrus . New ()
53
- cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dial , frequency , log ))
51
+ dialer := proxy. Dialer { Dial : dial , Timeout : 1 * time . Second }
52
+ cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dialer , frequency ))
54
53
defer cache .Close ()
55
54
56
55
_ , err := cache .Get (context .Background (), "test" )
@@ -85,8 +84,8 @@ func TestCacheNotEvictedIfConnectionIsHealthy(t *testing.T) {
85
84
return & net.UnixConn {}, nil
86
85
}
87
86
frequency := 1 * time .Millisecond
88
- log := logrus . New ()
89
- cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dial , frequency , log ))
87
+ dialer := proxy. Dialer { Dial : dial , Timeout : 1 * time . Second }
88
+ cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dialer , frequency ))
90
89
defer cache .Close ()
91
90
92
91
_ , err := cache .Get (context .Background (), "test" )
@@ -119,8 +118,8 @@ func TestBackgroundEnforcersCanBeStopped(t *testing.T) {
119
118
return & net.UnixConn {}, nil
120
119
}
121
120
frequency := 1 * time .Millisecond
122
- log := logrus . New ()
123
- cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dial , frequency , log ))
121
+ dialer := proxy. Dialer { Dial : dial , Timeout : 1 * time . Second }
122
+ cache := NewRemoteSnapshotterCache (getSnapshotter , EvictOnConnectionFailure (dialer , frequency ))
124
123
125
124
_ , err := cache .Get (context .Background (), "test" )
126
125
require .NoError (t , err , "Snapshotter not added to cache correctly" )
@@ -137,8 +136,8 @@ func TestLogErrorOnEvictionFailure(t *testing.T) {
137
136
return nil , errors .New ("mock dial error" )
138
137
}
139
138
frequency := 1 * time .Millisecond
140
- log := logrus . New ()
141
- cache := NewRemoteSnapshotterCache (getErrorSnapshotter , EvictOnConnectionFailure (dial , frequency , log ))
139
+ dialer := proxy. Dialer { Dial : dial , Timeout : 1 * time . Second }
140
+ cache := NewRemoteSnapshotterCache (getErrorSnapshotter , EvictOnConnectionFailure (dialer , frequency ))
142
141
defer cache .Close ()
143
142
144
143
_ , err := cache .Get (context .Background (), "test" )
@@ -156,6 +155,7 @@ func TestLogErrorOnEvictionFailure(t *testing.T) {
156
155
if cache .length () == 1 {
157
156
continue
158
157
}
158
+
159
159
return
160
160
case <- ctx .Done ():
161
161
require .Len (t , cache .snapshotters , 1 , "Cache entry was never evicted" )
0 commit comments