github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/graphdriver/overlay2/overlay_test.go (about) 1 // +build linux 2 3 package overlay2 // import "github.com/demonoid81/moby/daemon/graphdriver/overlay2" 4 5 import ( 6 "io/ioutil" 7 "os" 8 "testing" 9 10 "github.com/demonoid81/moby/daemon/graphdriver" 11 "github.com/demonoid81/moby/daemon/graphdriver/graphtest" 12 "github.com/demonoid81/moby/pkg/archive" 13 "github.com/demonoid81/moby/pkg/reexec" 14 ) 15 16 func init() { 17 // Do not sure chroot to speed run time and allow archive 18 // errors or hangs to be debugged directly from the test process. 19 untar = archive.UntarUncompressed 20 graphdriver.ApplyUncompressedLayer = archive.ApplyUncompressedLayer 21 22 reexec.Init() 23 } 24 25 func skipIfNaive(t *testing.T) { 26 td, err := ioutil.TempDir("", "naive-check-") 27 if err != nil { 28 t.Fatalf("Failed to create temp dir: %v", err) 29 } 30 defer os.RemoveAll(td) 31 32 if useNaiveDiff(td) { 33 t.Skipf("Cannot run test with naive diff") 34 } 35 } 36 37 // This avoids creating a new driver for each test if all tests are run 38 // Make sure to put new tests between TestOverlaySetup and TestOverlayTeardown 39 func TestOverlaySetup(t *testing.T) { 40 graphtest.GetDriver(t, driverName) 41 } 42 43 func TestOverlayCreateEmpty(t *testing.T) { 44 graphtest.DriverTestCreateEmpty(t, driverName) 45 } 46 47 func TestOverlayCreateBase(t *testing.T) { 48 graphtest.DriverTestCreateBase(t, driverName) 49 } 50 51 func TestOverlayCreateSnap(t *testing.T) { 52 graphtest.DriverTestCreateSnap(t, driverName) 53 } 54 55 func TestOverlay128LayerRead(t *testing.T) { 56 graphtest.DriverTestDeepLayerRead(t, 128, driverName) 57 } 58 59 func TestOverlayDiffApply10Files(t *testing.T) { 60 skipIfNaive(t) 61 graphtest.DriverTestDiffApply(t, 10, driverName) 62 } 63 64 func TestOverlayChanges(t *testing.T) { 65 t.Skipf("Cannot run test with naive change algorithm") 66 graphtest.DriverTestChanges(t, driverName) 67 } 68 69 func TestOverlayTeardown(t *testing.T) { 70 graphtest.PutDriver(t) 71 } 72 73 // Benchmarks should always setup new driver 74 75 func BenchmarkExists(b *testing.B) { 76 graphtest.DriverBenchExists(b, driverName) 77 } 78 79 func BenchmarkGetEmpty(b *testing.B) { 80 graphtest.DriverBenchGetEmpty(b, driverName) 81 } 82 83 func BenchmarkDiffBase(b *testing.B) { 84 graphtest.DriverBenchDiffBase(b, driverName) 85 } 86 87 func BenchmarkDiffSmallUpper(b *testing.B) { 88 graphtest.DriverBenchDiffN(b, 10, 10, driverName) 89 } 90 91 func BenchmarkDiff10KFileUpper(b *testing.B) { 92 graphtest.DriverBenchDiffN(b, 10, 10000, driverName) 93 } 94 95 func BenchmarkDiff10KFilesBottom(b *testing.B) { 96 graphtest.DriverBenchDiffN(b, 10000, 10, driverName) 97 } 98 99 func BenchmarkDiffApply100(b *testing.B) { 100 graphtest.DriverBenchDiffApplyN(b, 100, driverName) 101 } 102 103 func BenchmarkDiff20Layers(b *testing.B) { 104 graphtest.DriverBenchDeepLayerDiff(b, 20, driverName) 105 } 106 107 func BenchmarkRead20Layers(b *testing.B) { 108 graphtest.DriverBenchDeepLayerRead(b, 20, driverName) 109 }