Browse code

devmapper: fix unit test

It has been pointed out that sometimes device mapper unit tests
fail with the following diagnostics:

> --- FAIL: TestDevmapperSetup (0.02s)
> graphtest_unix.go:44: graphdriver: loopback attach failed
> graphtest_unix.go:48: loopback attach failed

The root cause is the absence of udev inside the container used
for testing, which causes device nodes (/dev/loop*) to not be
created.

The test suite itself already has a workaround, but it only
creates 8 devices (loop0 till loop7). It might very well be
the case that the first few devices are already used by the
system (on my laptop 15 devices are busy).

The fix is to raise the number of devices being manually created.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Kir Kolyshkin authored on 2019/10/08 04:51:24
Showing 1 changed files
... ...
@@ -34,8 +34,9 @@ func initLoopbacks() error {
34 34
 	if err != nil {
35 35
 		return err
36 36
 	}
37
-	// create at least 8 loopback files, ya, that is a good number
38
-	for i := 0; i < 8; i++ {
37
+	// create at least 128 loopback files, since a few first ones
38
+	// might be already in use by the host OS
39
+	for i := 0; i < 128; i++ {
39 40
 		loopPath := fmt.Sprintf("/dev/loop%d", i)
40 41
 		// only create new loopback files if they don't exist
41 42
 		if _, err := os.Stat(loopPath); err != nil {