mirror of
				https://github.com/containers/podman.git
				synced 2025-10-31 18:08:51 +08:00 
			
		
		
		
	Add podman machine test suite
This PR introduces a test suite for podman machine. It can currently be run on developers' local machines and is not part of the official CI testing; however, the expectation is that any work on machine should come with an accompanying test. At present, the test must be run on Linux. It is untested on Darwin. There is no Makefile target for the test. It can be run like `ginkgo -v pkg/machine/test/.`. It should be run as a unprivileged user. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
		
							
								
								
									
										67
									
								
								pkg/machine/e2e/rm_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								pkg/machine/e2e/rm_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | ||||
| package e2e | ||||
|  | ||||
| import ( | ||||
| 	. "github.com/onsi/ginkgo" | ||||
| 	. "github.com/onsi/gomega" | ||||
| ) | ||||
|  | ||||
| var _ = Describe("podman machine rm", func() { | ||||
| 	var ( | ||||
| 		mb      *machineTestBuilder | ||||
| 		testDir string | ||||
| 	) | ||||
|  | ||||
| 	BeforeEach(func() { | ||||
| 		testDir, mb = setup() | ||||
| 	}) | ||||
| 	AfterEach(func() { | ||||
| 		teardown(originalHomeDir, testDir, mb) | ||||
| 	}) | ||||
|  | ||||
| 	It("bad init name", func() { | ||||
| 		i := rmMachine{} | ||||
| 		reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||||
| 		session, err := mb.setName(reallyLongName).setCmd(&i).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(session.ExitCode()).To(Equal(125)) | ||||
| 	}) | ||||
|  | ||||
| 	It("Remove machine", func() { | ||||
| 		i := new(initMachine) | ||||
| 		session, err := mb.setCmd(i.withImagePath(mb.imagePath)).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(session.ExitCode()).To(Equal(0)) | ||||
| 		rm := rmMachine{} | ||||
| 		_, err = mb.setCmd(rm.withForce()).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
|  | ||||
| 		// Inspecting a non-existent machine should fail | ||||
| 		// which means it is gone | ||||
| 		_, ec, err := mb.toQemuInspectInfo() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(ec).To(Equal(125)) | ||||
| 	}) | ||||
|  | ||||
| 	It("Remove running machine", func() { | ||||
| 		i := new(initMachine) | ||||
| 		session, err := mb.setCmd(i.withImagePath(mb.imagePath).withNow()).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(session.ExitCode()).To(Equal(0)) | ||||
| 		rm := new(rmMachine) | ||||
|  | ||||
| 		// Removing a running machine should fail | ||||
| 		stop, err := mb.setCmd(rm).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(stop.ExitCode()).To(Equal(125)) | ||||
|  | ||||
| 		// Removing again with force | ||||
| 		stopAgain, err := mb.setCmd(rm.withForce()).run() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(stopAgain.ExitCode()).To(BeZero()) | ||||
|  | ||||
| 		// Inspect to be dead sure | ||||
| 		_, ec, err := mb.toQemuInspectInfo() | ||||
| 		Expect(err).To(BeNil()) | ||||
| 		Expect(ec).To(Equal(125)) | ||||
| 	}) | ||||
| }) | ||||
		Reference in New Issue
	
	Block a user
	 Brent Baude
					Brent Baude