| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  | # This test runs podman and checks if simple container starts | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ./make-test-python.nix ( | 
					
						
							| 
									
										
										
										
											2020-04-20 12:35:36 +01:00
										 |  |  |   { pkgs, lib, ... }: { | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  |     name = "podman"; | 
					
						
							| 
									
										
										
										
											2020-04-20 12:35:36 +01:00
										 |  |  |     meta = { | 
					
						
							|  |  |  |       maintainers = lib.teams.podman.members; | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodes = { | 
					
						
							|  |  |  |       podman = | 
					
						
							|  |  |  |         { pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |           virtualisation.podman.enable = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           users.users.alice = { | 
					
						
							|  |  |  |             isNormalUser = true; | 
					
						
							|  |  |  |             home = "/home/alice"; | 
					
						
							|  |  |  |             description = "Alice Foobar"; | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  |           }; | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     testScript = ''
 | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |       import shlex | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def su_cmd(cmd): | 
					
						
							|  |  |  |           cmd = shlex.quote(cmd) | 
					
						
							|  |  |  |           return f"su alice -l -c {cmd}" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       podman.wait_for_unit("sockets.target") | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |       start_all() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |       with subtest("Run container as root with runc"): | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |           podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg") | 
					
						
							|  |  |  |           podman.succeed( | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |               "podman run --runtime=runc -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10" | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |           ) | 
					
						
							|  |  |  |           podman.succeed("podman ps | grep sleeping") | 
					
						
							|  |  |  |           podman.succeed("podman stop sleeping") | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |           podman.succeed("podman rm sleeping") | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |       with subtest("Run container as root with crun"): | 
					
						
							|  |  |  |           podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg") | 
					
						
							|  |  |  |           podman.succeed( | 
					
						
							|  |  |  |               "podman run --runtime=crun -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10" | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |           podman.succeed("podman ps | grep sleeping") | 
					
						
							|  |  |  |           podman.succeed("podman stop sleeping") | 
					
						
							|  |  |  |           podman.succeed("podman rm sleeping") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-20 00:15:31 +01:00
										 |  |  |       with subtest("Run container as root with the default backend"): | 
					
						
							|  |  |  |           podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg") | 
					
						
							|  |  |  |           podman.succeed( | 
					
						
							|  |  |  |               "podman run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10" | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |           podman.succeed("podman ps | grep sleeping") | 
					
						
							|  |  |  |           podman.succeed("podman stop sleeping") | 
					
						
							|  |  |  |           podman.succeed("podman rm sleeping") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       with subtest("Run container rootless with crun"): | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |           podman.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg")) | 
					
						
							|  |  |  |           podman.succeed( | 
					
						
							|  |  |  |               su_cmd( | 
					
						
							| 
									
										
										
										
											2020-11-20 00:15:31 +01:00
										 |  |  |                   "podman run --runtime=crun -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10" | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |               ) | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |           podman.succeed(su_cmd("podman ps | grep sleeping")) | 
					
						
							|  |  |  |           podman.succeed(su_cmd("podman stop sleeping")) | 
					
						
							|  |  |  |           podman.succeed(su_cmd("podman rm sleeping")) | 
					
						
							| 
									
										
										
										
											2020-11-20 00:15:31 +01:00
										 |  |  |       # As of 2020-11-20, the runc backend doesn't work with cgroupsv2 yet, so we don't run that test. | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-20 00:15:31 +01:00
										 |  |  |       with subtest("Run container rootless with the default backend"): | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |           podman.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg")) | 
					
						
							|  |  |  |           podman.succeed( | 
					
						
							|  |  |  |               su_cmd( | 
					
						
							| 
									
										
										
										
											2020-11-20 00:15:31 +01:00
										 |  |  |                   "podman run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10" | 
					
						
							| 
									
										
										
										
											2020-04-24 10:49:36 +01:00
										 |  |  |               ) | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |           podman.succeed(su_cmd("podman ps | grep sleeping")) | 
					
						
							|  |  |  |           podman.succeed(su_cmd("podman stop sleeping")) | 
					
						
							| 
									
										
										
										
											2020-05-13 15:12:59 +10:00
										 |  |  |           podman.succeed(su_cmd("podman rm sleeping")) | 
					
						
							| 
									
										
										
										
											2020-04-20 09:37:53 +01:00
										 |  |  |     '';
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | ) |