32
32
# export; history; import_image; insert; port; push; tag; get; load; stats;
33
33
34
34
DEFAULT_BASE_URL = os .environ .get ('DOCKER_HOST' )
35
+ EXEC_DRIVER_IS_NATIVE = True
35
36
36
37
warnings .simplefilter ('error' )
37
38
create_host_config = docker .utils .create_host_config
@@ -312,6 +313,7 @@ def runTest(self):
312
313
self .assertFalse (inspect_data ['VolumesRW' ][mount_dest ])
313
314
314
315
316
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
315
317
class TestCreateContainerReadOnlyFs (BaseTestCase ):
316
318
def runTest (self ):
317
319
ctnr = self .client .create_container (
@@ -325,6 +327,7 @@ def runTest(self):
325
327
self .assertNotEqual (res , 0 )
326
328
327
329
330
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
328
331
class TestStartContainerReadOnlyFs (BaseTestCase ):
329
332
def runTest (self ):
330
333
# Presumably a bug in 1.5.0
@@ -351,14 +354,18 @@ def runTest(self):
351
354
352
355
class TestRenameContainer (BaseTestCase ):
353
356
def runTest (self ):
357
+ version = self .client .version ()['Version' ]
354
358
name = 'hong_meiling'
355
359
res = self .client .create_container ('busybox' , 'true' )
356
360
self .assertIn ('Id' , res )
357
361
self .tmp_containers .append (res ['Id' ])
358
362
self .client .rename (res , name )
359
363
inspect = self .client .inspect_container (res ['Id' ])
360
364
self .assertIn ('Name' , inspect )
361
- self .assertEqual (name , inspect ['Name' ])
365
+ if version == '1.5.0' :
366
+ self .assertEqual (name , inspect ['Name' ])
367
+ else :
368
+ self .assertEqual ('/{0}' .format (name ), inspect ['Name' ])
362
369
363
370
364
371
class TestStartContainer (BaseTestCase ):
@@ -581,7 +588,8 @@ def runTest(self):
581
588
self .assertIn ('State' , container_info )
582
589
state = container_info ['State' ]
583
590
self .assertIn ('ExitCode' , state )
584
- self .assertNotEqual (state ['ExitCode' ], 0 )
591
+ if EXEC_DRIVER_IS_NATIVE :
592
+ self .assertNotEqual (state ['ExitCode' ], 0 )
585
593
self .assertIn ('Running' , state )
586
594
self .assertEqual (state ['Running' ], False )
587
595
@@ -598,7 +606,8 @@ def runTest(self):
598
606
self .assertIn ('State' , container_info )
599
607
state = container_info ['State' ]
600
608
self .assertIn ('ExitCode' , state )
601
- self .assertNotEqual (state ['ExitCode' ], 0 )
609
+ if EXEC_DRIVER_IS_NATIVE :
610
+ self .assertNotEqual (state ['ExitCode' ], 0 )
602
611
self .assertIn ('Running' , state )
603
612
self .assertEqual (state ['Running' ], False )
604
613
@@ -614,7 +623,8 @@ def runTest(self):
614
623
self .assertIn ('State' , container_info )
615
624
state = container_info ['State' ]
616
625
self .assertIn ('ExitCode' , state )
617
- self .assertNotEqual (state ['ExitCode' ], 0 )
626
+ if EXEC_DRIVER_IS_NATIVE :
627
+ self .assertNotEqual (state ['ExitCode' ], 0 )
618
628
self .assertIn ('Running' , state )
619
629
self .assertEqual (state ['Running' ], False )
620
630
@@ -630,7 +640,8 @@ def runTest(self):
630
640
self .assertIn ('State' , container_info )
631
641
state = container_info ['State' ]
632
642
self .assertIn ('ExitCode' , state )
633
- self .assertNotEqual (state ['ExitCode' ], 0 )
643
+ if EXEC_DRIVER_IS_NATIVE :
644
+ self .assertNotEqual (state ['ExitCode' ], 0 )
634
645
self .assertIn ('Running' , state )
635
646
self .assertEqual (state ['Running' ], False )
636
647
@@ -978,6 +989,7 @@ def runTest(self):
978
989
self .client .remove_container (id , force = True )
979
990
980
991
992
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
981
993
class TestExecuteCommand (BaseTestCase ):
982
994
def runTest (self ):
983
995
container = self .client .create_container ('busybox' , 'cat' ,
@@ -991,6 +1003,7 @@ def runTest(self):
991
1003
self .assertEqual (res , expected )
992
1004
993
1005
1006
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
994
1007
class TestExecuteCommandString (BaseTestCase ):
995
1008
def runTest (self ):
996
1009
container = self .client .create_container ('busybox' , 'cat' ,
@@ -1004,6 +1017,7 @@ def runTest(self):
1004
1017
self .assertEqual (res , expected )
1005
1018
1006
1019
1020
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
1007
1021
class TestExecuteCommandStreaming (BaseTestCase ):
1008
1022
def runTest (self ):
1009
1023
container = self .client .create_container ('busybox' , 'cat' ,
@@ -1311,6 +1325,8 @@ def runTest(self):
1311
1325
with open (os .path .join (base_dir , '.dockerignore' ), 'w' ) as f :
1312
1326
f .write ("\n " .join ([
1313
1327
'node_modules' ,
1328
+ 'Dockerfile' ,
1329
+ '.dockerginore' ,
1314
1330
'' , # empty line
1315
1331
]))
1316
1332
@@ -1329,6 +1345,8 @@ def runTest(self):
1329
1345
chunk = chunk .decode ('utf-8' )
1330
1346
logs += chunk
1331
1347
self .assertFalse ('node_modules' in logs )
1348
+ self .assertFalse ('Dockerfile' in logs )
1349
+ self .assertFalse ('.dockerginore' in logs )
1332
1350
self .assertTrue ('not-ignored' in logs )
1333
1351
1334
1352
#######################
@@ -1458,5 +1476,7 @@ def test_443(self):
1458
1476
if __name__ == '__main__' :
1459
1477
c = docker .Client (base_url = DEFAULT_BASE_URL )
1460
1478
c .pull ('busybox' )
1479
+ exec_driver = c .info ()['ExecutionDriver' ]
1480
+ EXEC_DRIVER_IS_NATIVE = exec_driver .startswith ('native' )
1461
1481
c .close ()
1462
1482
unittest .main ()
0 commit comments