@@ -19,6 +19,7 @@ package container
19
19
import (
20
20
"fmt"
21
21
"io"
22
+ "os"
22
23
"strings"
23
24
"testing"
24
25
"time"
@@ -199,3 +200,31 @@ func TestStopWithTimeout(t *testing.T) {
199
200
// The container should get the SIGKILL before the 10s default timeout
200
201
assert .Assert (t , elapsed < 10 * time .Second , "Container did not respect --timeout flag" )
201
202
}
203
+
204
+ func TestStopCleanupFIFOs (t * testing.T ) {
205
+ t .Parallel ()
206
+
207
+ base := testutil .NewBase (t )
208
+ testContainerName := testutil .Identifier (t )
209
+
210
+ // Stop the container after 2 seconds
211
+ go func () {
212
+ time .Sleep (2 * time .Second )
213
+ base .Cmd ("stop" , testContainerName ).Run ()
214
+ }()
215
+
216
+ // Start a container that is automatically removed after it exits
217
+ base .Cmd ("run" , "--rm" , "--name" , testContainerName , testutil .NginxAlpineImage ).AssertOK ()
218
+
219
+ fifoDir := "/run/containerd/fifo"
220
+ entries , err := os .ReadDir (fifoDir )
221
+ assert .NilError (t , err , "failed to read fifo directory" )
222
+
223
+ if len (entries ) != 0 {
224
+ for _ , entry := range entries {
225
+ t .Logf ("Leaked FIFO file: %s" , entry .Name ())
226
+ }
227
+ }
228
+ // The FIFO directory should be empty after the container be stopped
229
+ assert .Assert (t , len (entries ) == 0 , "Expected no FIFO files under %s, but found %d" , fifoDir , len (entries ))
230
+ }
0 commit comments