File: podman_test.go

package info (click to toggle)
golang-github-crc-org-crc 2.34.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,548 kB
  • sloc: sh: 398; makefile: 326; javascript: 40
file content (89 lines) | stat: -rw-r--r-- 2,724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package test_test

import (
	"os"
	"path/filepath"
	"runtime"

	"github.com/crc-org/crc/v2/test/extended/crc/cmd"
	"github.com/crc-org/crc/v2/test/extended/util"
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("podman preset", Serial, Ordered, Label("podman-preset"), func() {

	// runs 1x after all the It blocks (specs) inside this Describe node
	AfterAll(func() {

		// cleanup CRC
		Expect(RunCRCExpectSuccess("cleanup")).To(MatchRegexp("Cleanup finished"))

		// remove config file crc.json
		err := util.RemoveCRCConfig()
		Expect(err).NotTo(HaveOccurred())

	})

	Describe("basic use", Serial, Ordered, func() {

		It("write to config", func() {
			Expect(RunCRCExpectSuccess("config", "set", "preset", "podman")).To(ContainSubstring("please run 'crc setup' before 'crc start'"))
		})

		It("setup CRC", func() {
			Expect(RunCRCExpectSuccess("setup")).To(ContainSubstring("Your system is correctly setup for using CRC"))
		})

		It("start CRC", func() {
			Expect(RunCRCExpectSuccess("start")).To(ContainSubstring("podman runtime is now running"))
		})

		It("podman-env", func() {
			// Do what 'eval $(crc podman-env) would do
			path := os.ExpandEnv("${HOME}/.crc/bin/podman:$PATH")
			csshk := os.ExpandEnv("${HOME}/.crc/machines/crc/id_ecdsa")
			dh := os.ExpandEnv("unix:///${HOME}/.crc/machines/crc/docker.sock")
			ch := "ssh://core@127.0.0.1:2222/run/user/1000/podman/podman.sock"
			if runtime.GOOS == "windows" {
				userHomeDir, _ := os.UserHomeDir()
				unexpandedPath := filepath.Join(userHomeDir, ".crc/bin/podman;${PATH}")
				path = os.ExpandEnv(unexpandedPath)
				csshk = filepath.Join(userHomeDir, ".crc/machines/crc/id_ecdsa")
				dh = "npipe:////./pipe/crc-podman"
			}
			if runtime.GOOS == "linux" {
				ch = "ssh://core@192.168.130.11:22/run/user/1000/podman/podman.sock"
			}

			os.Setenv("PATH", path)
			os.Setenv("CONTAINER_SSHKEY", csshk)
			os.Setenv("CONTAINER_HOST", ch)
			os.Setenv("DOCKER_HOST", dh)
		})

		It("version", func() {
			out, err := cmd.RunPodmanExpectSuccess("version")
			Expect(err).NotTo(HaveOccurred())
			Expect(out).Should(MatchRegexp(`Version:[\s]*\d+\.\d+\.\d+`))
		})

		It("pull image", func() {
			_, err := cmd.RunPodmanExpectSuccess("pull", "fedora")
			Expect(err).NotTo(HaveOccurred())
		})

		It("run image", func() {
			_, err := cmd.RunPodmanExpectSuccess("run", "fedora")
			Expect(err).NotTo(HaveOccurred())
		})

		It("cleanup CRC", func() {
			Expect(RunCRCExpectSuccess("cleanup")).To(MatchRegexp("Cleanup finished"))
		})

		It("unset preset in config", func() {
			Expect(RunCRCExpectSuccess("config", "unset", "preset")).To(ContainSubstring("Successfully unset configuration property 'preset'"))
		})
	})
})