@@ -22,7 +22,6 @@ import (
2222
2323 "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/internal"
2424 "github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/proxy"
25- "github.com/sirupsen/logrus"
2625 "github.com/stretchr/testify/require"
2726 "go.uber.org/goleak"
2827)
@@ -49,8 +48,8 @@ func TestCacheEvictionOnConnectionFailure(t *testing.T) {
4948 return nil , errors .New ("mock dial error" )
5049 }
5150 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 ))
5453 defer cache .Close ()
5554
5655 _ , err := cache .Get (context .Background (), "test" )
@@ -85,8 +84,8 @@ func TestCacheNotEvictedIfConnectionIsHealthy(t *testing.T) {
8584 return & net.UnixConn {}, nil
8685 }
8786 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 ))
9089 defer cache .Close ()
9190
9291 _ , err := cache .Get (context .Background (), "test" )
@@ -119,8 +118,8 @@ func TestBackgroundEnforcersCanBeStopped(t *testing.T) {
119118 return & net.UnixConn {}, nil
120119 }
121120 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 ))
124123
125124 _ , err := cache .Get (context .Background (), "test" )
126125 require .NoError (t , err , "Snapshotter not added to cache correctly" )
@@ -137,8 +136,8 @@ func TestLogErrorOnEvictionFailure(t *testing.T) {
137136 return nil , errors .New ("mock dial error" )
138137 }
139138 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 ))
142141 defer cache .Close ()
143142
144143 _ , err := cache .Get (context .Background (), "test" )
@@ -156,6 +155,7 @@ func TestLogErrorOnEvictionFailure(t *testing.T) {
156155 if cache .length () == 1 {
157156 continue
158157 }
158+
159159 return
160160 case <- ctx .Done ():
161161 require .Len (t , cache .snapshotters , 1 , "Cache entry was never evicted" )
0 commit comments