don't GC images in tests by default
This commit is contained in:
parent
c3c2a85314
commit
8ef1b85ce9
|
@ -59,7 +59,7 @@ func TestDockerDriver_PidsLimit(t *testing.T) {
|
|||
cfg.Args = []string{"-c", "sleep 5 & sleep 5 & sleep 5"}
|
||||
require.NoError(task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
_, driver, _, cleanup := dockerSetup(t, task)
|
||||
_, driver, _, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
driver.WaitUntilStarted(task.ID, time.Duration(tu.TestMultiplier()*5)*time.Second)
|
||||
|
|
|
@ -120,15 +120,15 @@ func dockerTask(t *testing.T) (*drivers.TaskConfig, *TaskConfig, []int) {
|
|||
//
|
||||
// task := taskTemplate()
|
||||
// // do custom task configuration
|
||||
// client, handle, cleanup := dockerSetup(t, task)
|
||||
// client, handle, cleanup := dockerSetup(t, task, nil)
|
||||
// defer cleanup()
|
||||
// // do test stuff
|
||||
//
|
||||
// If there is a problem during setup this function will abort or skip the test
|
||||
// and indicate the reason.
|
||||
func dockerSetup(t *testing.T, task *drivers.TaskConfig) (*docker.Client, *dtestutil.DriverHarness, *taskHandle, func()) {
|
||||
func dockerSetup(t *testing.T, task *drivers.TaskConfig, driverCfg map[string]interface{}) (*docker.Client, *dtestutil.DriverHarness, *taskHandle, func()) {
|
||||
client := newTestDockerClient(t)
|
||||
driver := dockerDriverHarness(t, nil)
|
||||
driver := dockerDriverHarness(t, driverCfg)
|
||||
cleanup := driver.MkAllocDir(task, true)
|
||||
|
||||
copyImage(t, task.TaskDir(), "busybox.tar")
|
||||
|
@ -181,6 +181,7 @@ func dockerDriverHarness(t *testing.T, cfg map[string]interface{}) *dtestutil.Dr
|
|||
if cfg == nil {
|
||||
cfg = map[string]interface{}{
|
||||
"gc": map[string]interface{}{
|
||||
"image": false,
|
||||
"image_delay": "1s",
|
||||
},
|
||||
}
|
||||
|
@ -912,7 +913,7 @@ func TestDockerDriver_Labels(t *testing.T) {
|
|||
}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -940,7 +941,7 @@ func TestDockerDriver_ForcePull(t *testing.T) {
|
|||
cfg.ForcePull = true
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
@ -971,7 +972,7 @@ func TestDockerDriver_ForcePull_RepoDigest(t *testing.T) {
|
|||
cfg.Args = busyboxLongRunningCmd[1:]
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -994,7 +995,7 @@ func TestDockerDriver_SecurityOptUnconfined(t *testing.T) {
|
|||
cfg.SecurityOpt = []string{"seccomp=unconfined"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1021,7 +1022,7 @@ func TestDockerDriver_SecurityOptFromFile(t *testing.T) {
|
|||
cfg.SecurityOpt = []string{"seccomp=./test-resources/docker/seccomp.json"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1042,7 +1043,7 @@ func TestDockerDriver_Runtime(t *testing.T) {
|
|||
cfg.Runtime = "runc"
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1470,7 +1471,7 @@ func TestDockerDriver_DNS(t *testing.T) {
|
|||
cfg.DNSOptions = []string{"ndots:1"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
@ -1497,7 +1498,7 @@ func TestDockerDriver_MACAddress(t *testing.T) {
|
|||
cfg.MacAddress = "00:16:3e:00:00:00"
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1518,7 +1519,7 @@ func TestDockerWorkDir(t *testing.T) {
|
|||
cfg.WorkDir = "/some/path"
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1547,7 +1548,7 @@ func TestDockerDriver_PortsNoMap(t *testing.T) {
|
|||
res := ports[0]
|
||||
dyn := ports[1]
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1596,7 +1597,7 @@ func TestDockerDriver_PortsMapping(t *testing.T) {
|
|||
}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -1680,7 +1681,7 @@ func TestDockerDriver_CleanupContainer(t *testing.T) {
|
|||
cfg.Args = []string{"hello"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
waitCh, err := d.WaitTask(context.Background(), task.ID)
|
||||
|
@ -1914,7 +1915,7 @@ func TestDockerDriver_Stats(t *testing.T) {
|
|||
cfg.Args = []string{"1000"}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
_, d, handle, cleanup := dockerSetup(t, task)
|
||||
_, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -2379,7 +2380,7 @@ func TestDockerDriver_Device_Success(t *testing.T) {
|
|||
cfg.Devices = []DockerDevice{config}
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
client, driver, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, driver.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -2405,7 +2406,7 @@ func TestDockerDriver_Entrypoint(t *testing.T) {
|
|||
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
client, driver, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
require.NoError(t, driver.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
@ -2432,7 +2433,7 @@ func TestDockerDriver_ReadonlyRootfs(t *testing.T) {
|
|||
cfg.ReadonlyRootfs = true
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
client, driver, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, driver.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ func TestDockerDriver_CPUCFSPeriod(t *testing.T) {
|
|||
cfg.CPUCFSPeriod = 1000000
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, _, handle, cleanup := dockerSetup(t, task)
|
||||
client, _, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
|
||||
waitForExist(t, client, handle.containerID)
|
||||
|
@ -184,7 +184,7 @@ func TestDockerDriver_Sysctl_Ulimit(t *testing.T) {
|
|||
cfg.Ulimit = expectedUlimits
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
@ -678,7 +678,12 @@ func TestDockerDriver_Cleanup(t *testing.T) {
|
|||
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, driver, handle, cleanup := dockerSetup(t, task)
|
||||
client, driver, handle, cleanup := dockerSetup(t, task, map[string]interface{}{
|
||||
"gc": map[string]interface{}{
|
||||
"image": true,
|
||||
"image_delay": "1ms",
|
||||
},
|
||||
})
|
||||
defer cleanup()
|
||||
|
||||
require.NoError(t, driver.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestDanglingContainerRemoval(t *testing.T) {
|
|||
defer freeport.Return(ports)
|
||||
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))
|
||||
|
||||
client, d, handle, cleanup := dockerSetup(t, task)
|
||||
client, d, handle, cleanup := dockerSetup(t, task, nil)
|
||||
defer cleanup()
|
||||
require.NoError(t, d.WaitUntilStarted(task.ID, 5*time.Second))
|
||||
|
||||
|
|
Loading…
Reference in New Issue