github.com/kobeld/docker@v1.12.0-rc1/daemon/graphdriver/overlay2/overlay_test.go (about)

     1  // +build linux
     2  
     3  package overlay2
     4  
     5  import (
     6  	"os"
     7  	"syscall"
     8  	"testing"
     9  
    10  	"github.com/docker/docker/daemon/graphdriver"
    11  	"github.com/docker/docker/daemon/graphdriver/graphtest"
    12  	"github.com/docker/docker/pkg/archive"
    13  	"github.com/docker/docker/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 cdMountFrom(dir, device, target, mType, label string) error {
    26  	wd, err := os.Getwd()
    27  	if err != nil {
    28  		return err
    29  	}
    30  	os.Chdir(dir)
    31  	defer os.Chdir(wd)
    32  
    33  	return syscall.Mount(device, target, mType, 0, label)
    34  }
    35  
    36  // This avoids creating a new driver for each test if all tests are run
    37  // Make sure to put new tests between TestOverlaySetup and TestOverlayTeardown
    38  func TestOverlaySetup(t *testing.T) {
    39  	graphtest.GetDriver(t, driverName)
    40  }
    41  
    42  func TestOverlayCreateEmpty(t *testing.T) {
    43  	graphtest.DriverTestCreateEmpty(t, driverName)
    44  }
    45  
    46  func TestOverlayCreateBase(t *testing.T) {
    47  	graphtest.DriverTestCreateBase(t, driverName)
    48  }
    49  
    50  func TestOverlayCreateSnap(t *testing.T) {
    51  	graphtest.DriverTestCreateSnap(t, driverName)
    52  }
    53  
    54  func TestOverlay128LayerRead(t *testing.T) {
    55  	graphtest.DriverTestDeepLayerRead(t, 128, driverName)
    56  }
    57  
    58  func TestOverlayDiffApply10Files(t *testing.T) {
    59  	graphtest.DriverTestDiffApply(t, 10, driverName)
    60  }
    61  
    62  func TestOverlayChanges(t *testing.T) {
    63  	graphtest.DriverTestChanges(t, driverName)
    64  }
    65  
    66  func TestOverlayTeardown(t *testing.T) {
    67  	graphtest.PutDriver(t)
    68  }
    69  
    70  // Benchmarks should always setup new driver
    71  
    72  func BenchmarkExists(b *testing.B) {
    73  	graphtest.DriverBenchExists(b, driverName)
    74  }
    75  
    76  func BenchmarkGetEmpty(b *testing.B) {
    77  	graphtest.DriverBenchGetEmpty(b, driverName)
    78  }
    79  
    80  func BenchmarkDiffBase(b *testing.B) {
    81  	graphtest.DriverBenchDiffBase(b, driverName)
    82  }
    83  
    84  func BenchmarkDiffSmallUpper(b *testing.B) {
    85  	graphtest.DriverBenchDiffN(b, 10, 10, driverName)
    86  }
    87  
    88  func BenchmarkDiff10KFileUpper(b *testing.B) {
    89  	graphtest.DriverBenchDiffN(b, 10, 10000, driverName)
    90  }
    91  
    92  func BenchmarkDiff10KFilesBottom(b *testing.B) {
    93  	graphtest.DriverBenchDiffN(b, 10000, 10, driverName)
    94  }
    95  
    96  func BenchmarkDiffApply100(b *testing.B) {
    97  	graphtest.DriverBenchDiffApplyN(b, 100, driverName)
    98  }
    99  
   100  func BenchmarkDiff20Layers(b *testing.B) {
   101  	graphtest.DriverBenchDeepLayerDiff(b, 20, driverName)
   102  }
   103  
   104  func BenchmarkRead20Layers(b *testing.B) {
   105  	graphtest.DriverBenchDeepLayerRead(b, 20, driverName)
   106  }