summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorjortkoopmans <jort@jabo-solutions.eu>2020-11-30 15:58:23 +0100
committerGitHub <noreply@github.com>2020-11-30 15:58:23 +0100
commit84e8b2afa795ca060f4d2c5206f47d320292ed9b (patch)
treeea0e985d3f50d389b33fdb403d240e817251fd8c /test
parent5cfbe0b78e3672dd67cd028b85d816fc19d6a614 (diff)
parentfc85ec942ee3273f5ad56381a0f6b9e78aea59bf (diff)
downloadpodman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.tar.gz
podman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.tar.bz2
podman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.zip
Merge branch 'master' into patch-1
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/25-containersMore.at27
-rw-r--r--test/e2e/network_test.go11
-rw-r--r--test/e2e/play_kube_test.go89
3 files changed, 108 insertions, 19 deletions
diff --git a/test/apiv2/25-containersMore.at b/test/apiv2/25-containersMore.at
index e0e6f7222..4f6b80a5f 100644
--- a/test/apiv2/25-containersMore.at
+++ b/test/apiv2/25-containersMore.at
@@ -52,4 +52,31 @@ t POST libpod/containers/foo/unmount '' 204
t DELETE libpod/containers/foo?force=true 204
+podman run $IMAGE true
+
+t GET libpod/containers/json?last=1 200 \
+ length=1 \
+ .[0].Id~[0-9a-f]\\{64\\} \
+ .[0].Image=$IMAGE \
+ .[0].Command[0]="true" \
+ .[0].State~\\\(exited\\\|stopped\\\) \
+ .[0].ExitCode=0 \
+ .[0].IsInfra=false
+
+cid=$(jq -r '.[0].Id' <<<"$output")
+
+t GET libpod/generate/$cid/kube 200
+like "$output" ".*apiVersion:.*" "Check generated kube yaml - apiVersion"
+like "$output" ".*kind:\\sPod.*" "Check generated kube yaml - kind: Pod"
+like "$output" ".*metadata:.*" "Check generated kube yaml - metadata"
+like "$output" ".*spec:.*" "Check generated kube yaml - spec"
+
+t GET libpod/generate/$cid/kube?service=true 200
+like "$output" ".*apiVersion:.*" "Check generated kube yaml(service=true) - apiVersion"
+like "$output" ".*kind:\\sPod.*" "Check generated kube yaml(service=true) - kind: Pod"
+like "$output" ".*metadata:.*" "Check generated kube yaml(service=true) - metadata"
+like "$output" ".*spec:.*" "Check generated kube yaml(service=true) - spec"
+like "$output" ".*kind:\\sService.*" "Check generated kube yaml(service=true) - kind: Service"
+
+t DELETE libpod/containers/$cid 204
# vim: filetype=sh
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index 139a90ac7..adcf74f7e 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -499,4 +499,15 @@ var _ = Describe("Podman network", func() {
exec.WaitWithDefaultTimeout()
Expect(exec.ExitCode()).To(BeZero())
})
+
+ It("podman network create/remove macvlan", func() {
+ net := "macvlan" + stringid.GenerateNonCryptoID()
+ nc := podmanTest.Podman([]string{"network", "create", "--macvlan", "lo", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc.ExitCode()).To(Equal(0))
+
+ nc = podmanTest.Podman([]string{"network", "rm", net})
+ nc.WaitWithDefaultTimeout()
+ Expect(nc.ExitCode()).To(Equal(0))
+ })
})
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 92e4544f9..5ecfdd6b5 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -164,9 +164,15 @@ spec:
volumes:
{{ range . }}
- name: {{ .Name }}
+ {{- if (eq .VolumeType "HostPath") }}
hostPath:
- path: {{ .Path }}
- type: {{ .Type }}
+ path: {{ .HostPath.Path }}
+ type: {{ .HostPath.Type }}
+ {{- end }}
+ {{- if (eq .VolumeType "PersistentVolumeClaim") }}
+ persistentVolumeClaim:
+ claimName: {{ .PersistentVolumeClaim.ClaimName }}
+ {{- end }}
{{ end }}
{{ end }}
status: {}
@@ -692,19 +698,44 @@ func getCtrNameInPod(pod *Pod) string {
return fmt.Sprintf("%s-%s", pod.Name, defaultCtrName)
}
-type Volume struct {
- Name string
+type HostPath struct {
Path string
Type string
}
-// getVolume takes a type and a location for a volume
-// giving it a default name of volName
-func getVolume(vType, vPath string) *Volume {
+type PersistentVolumeClaim struct {
+ ClaimName string
+}
+
+type Volume struct {
+ VolumeType string
+ Name string
+ HostPath
+ PersistentVolumeClaim
+}
+
+// getHostPathVolume takes a type and a location for a HostPath
+// volume giving it a default name of volName
+func getHostPathVolume(vType, vPath string) *Volume {
+ return &Volume{
+ VolumeType: "HostPath",
+ Name: defaultVolName,
+ HostPath: HostPath{
+ Path: vPath,
+ Type: vType,
+ },
+ }
+}
+
+// getHostPathVolume takes a name for a Persistentvolumeclaim
+// volume giving it a default name of volName
+func getPersistentVolumeClaimVolume(vName string) *Volume {
return &Volume{
- Name: defaultVolName,
- Path: vPath,
- Type: vType,
+ VolumeType: "PersistentVolumeClaim",
+ Name: defaultVolName,
+ PersistentVolumeClaim: PersistentVolumeClaim{
+ ClaimName: vName,
+ },
}
}
@@ -1257,7 +1288,7 @@ spec:
It("podman play kube test with non-existent empty HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume(`""`, hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1272,7 +1303,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume(`""`, hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1284,7 +1315,7 @@ spec:
It("podman play kube test with non-existent File HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("File", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1299,7 +1330,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume("File", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1311,7 +1342,7 @@ spec:
It("podman play kube test with FileOrCreate HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("FileOrCreate", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("FileOrCreate", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1327,7 +1358,7 @@ spec:
It("podman play kube test with DirectoryOrCreate HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("DirectoryOrCreate", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("DirectoryOrCreate", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1347,7 +1378,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume("Socket", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("Socket", hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1356,14 +1387,14 @@ spec:
Expect(kube.ExitCode()).NotTo(Equal(0))
})
- It("podman play kube test with read only volume", func() {
+ It("podman play kube test with read only HostPath volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
f, err := os.Create(hostPathLocation)
Expect(err).To(BeNil())
f.Close()
ctr := getCtr(withVolumeMount(hostPathLocation, true), withImage(BB))
- pod := getPod(withVolume(getVolume("File", hostPathLocation)), withCtr(ctr))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)), withCtr(ctr))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1379,6 +1410,26 @@ spec:
Expect(inspect.OutputToString()).To(ContainSubstring(correct))
})
+ It("podman play kube test with PersistentVolumeClaim volume", func() {
+ volumeName := "namedVolume"
+
+ ctr := getCtr(withVolumeMount("/test", false), withImage(BB))
+ pod := getPod(withVolume(getPersistentVolumeClaimVolume(volumeName)), withCtr(ctr))
+ err = generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(pod), "--format", "{{ (index .Mounts 0).Type }}:{{ (index .Mounts 0).Name }}"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+
+ correct := fmt.Sprintf("volume:%s", volumeName)
+ Expect(inspect.OutputToString()).To(Equal(correct))
+ })
+
It("podman play kube applies labels to pods", func() {
var numReplicas int32 = 5
expectedLabelKey := "key1"