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