@@ -785,6 +785,7 @@ func (suite *PouchRunSuite) TestRunWithDiskQuota(c *check.C) {
785785 for _ , line := range strings .Split (out , "\n " ) {
786786 if strings .Contains (line , "/" ) && strings .Contains (line , "2048000" ) {
787787 found = true
788+ break
788789 }
789790 }
790791
@@ -812,3 +813,65 @@ func (suite *PouchRunSuite) TestRunWithAnnotation(c *check.C) {
812813 c .Assert (util .PartialEqual (annotationStr , "a=b" ), check .IsNil )
813814 c .Assert (util .PartialEqual (annotationStr , "foo=bar" ), check .IsNil )
814815}
816+
817+ // TestRunWithDiskQuotaRegular tests running container with --disk-quota.
818+ func (suite * PouchRunSuite ) TestRunWithDiskQuotaRegular (c * check.C ) {
819+ if ! environment .IsDiskQuota () {
820+ c .Skip ("Host does not support disk quota" )
821+ }
822+
823+ volumeName := "diskquota-volume"
824+ containerName := "diskquota-regular"
825+
826+ ret := command .PouchRun ("volume" , "create" , "-n" , volumeName , "-o" , "size=256m" , "-o" , "mount=/data/volume" )
827+ defer func () {
828+ command .PouchRun ("volume" , "rm" , volumeName ).Assert (c , icmd .Success )
829+ }()
830+ ret .Assert (c , icmd .Success )
831+
832+ ret = command .PouchRun ("run" ,
833+ "--disk-quota=1024m" ,
834+ `--disk-quota=".*=512m"` ,
835+ `--disk-quota="/mnt/mount1=768m"` ,
836+ "-v" , "/data/mount1:/mnt/mount1" ,
837+ "-v" , "/data/mount2:/mnt/mount2" ,
838+ "-v" , "diskquota-volume:/mnt/mount3" ,
839+ "--name" , containerName , busyboxImage , "df" )
840+ defer func () {
841+ command .PouchRun ("rm" , "-f" , containerName ).Assert (c , icmd .Success )
842+ }()
843+ ret .Assert (c , icmd .Success )
844+
845+ out := ret .Stdout ()
846+
847+ rootFound := false
848+ mount1Found := false
849+ mount2Found := false
850+ mount3Found := false
851+ for _ , line := range strings .Split (out , "\n " ) {
852+ if strings .Contains (line , "/" ) && strings .Contains (line , "1048576" ) {
853+ rootFound = true
854+ continue
855+ }
856+
857+ if strings .Contains (line , "/mnt/mount1" ) && strings .Contains (line , "786432" ) {
858+ mount1Found = true
859+ continue
860+ }
861+
862+ if strings .Contains (line , "/mnt/mount2" ) && strings .Contains (line , "524288" ) {
863+ mount2Found = true
864+ continue
865+ }
866+
867+ if strings .Contains (line , "/mnt/mount3" ) && strings .Contains (line , "262144" ) {
868+ mount3Found = true
869+ continue
870+ }
871+ }
872+
873+ c .Assert (rootFound , check .Equals , true )
874+ c .Assert (mount1Found , check .Equals , true )
875+ c .Assert (mount2Found , check .Equals , true )
876+ c .Assert (mount3Found , check .Equals , true )
877+ }
0 commit comments