github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/apiv2/45-system.at (about) 1 # -*- sh -*- 2 # 3 # system related tests 4 # 5 6 ## ensure system is clean 7 t POST 'libpod/system/prune?volumes=true&all=true' params='' 200 8 9 ## podman system df 10 t GET system/df 200 '{"LayersSize":0,"Images":[],"Containers":[],"Volumes":[],"BuildCache":[],"BuilderSize":0}' 11 t GET libpod/system/df 200 '{"Images":[],"Containers":[],"Volumes":[]}' 12 13 # Create volume. We expect df to report this volume next invocation of system/df 14 t GET libpod/info 200 15 volumepath=$(jq -r ".store.volumePath" <<<"$output") 16 t POST libpod/volumes/create name=foo1 201 \ 17 .Name=foo1 \ 18 .Driver=local \ 19 .Mountpoint=$volumepath/foo1/_data \ 20 .CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* \ 21 .Labels={} \ 22 .Options={} 23 24 t GET system/df 200 '.Volumes[0].Name=foo1' 25 26 t GET libpod/system/df 200 '.Volumes[0].VolumeName=foo1' 27 28 # Create two more volumes to test pruneing 29 t POST libpod/volumes/create \ 30 Name=foo2 \ 31 Label='{"testlabel1":""}' \ 32 Options='{"type":"tmpfs","o":"nodev,noexec"}}' \ 33 201 \ 34 .Name=foo2 \ 35 .Driver=local \ 36 .Mountpoint=$volumepath/foo2/_data \ 37 .CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* \ 38 .Labels.testlabel1="" \ 39 .Options.o=nodev,noexec 40 41 t POST libpod/volumes/create \ 42 Name=foo3 \ 43 Label='{"testlabel1":"testonly"}' \ 44 Options='{"type":"tmpfs","o":"nodev,noexec"}}' \ 45 201 \ 46 .Name=foo3 \ 47 .Driver=local \ 48 .Mountpoint=$volumepath/foo3/_data \ 49 .CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* \ 50 .Labels.testlabel1=testonly \ 51 .Options.o=nodev,noexec 52 53 t GET system/df 200 '.Volumes | length=3' 54 t GET libpod/system/df 200 '.Volumes | length=3' 55 56 # Prune volumes 57 58 t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1=idontmatch"]}' params='' 200 59 60 # nothing should have been pruned 61 t GET system/df 200 '.Volumes | length=3' 62 t GET libpod/system/df 200 '.Volumes | length=3' 63 64 # only foo3 should be pruned because of filter 65 t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1=testonly"]}' params='' 200 .VolumePruneReports[0].Id=foo3 66 # only foo2 should be pruned because of filter 67 t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1"]}' params='' 200 .VolumePruneReports[0].Id=foo2 68 # foo1, the last remaining volume should be pruned without any filters applied 69 t POST 'libpod/system/prune?volumes=true' params='' 200 .VolumePruneReports[0].Id=foo1 70 71 # TODO add other system prune tests for pods / images