This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathretry_imports_test.go
68 lines (57 loc) · 2.12 KB
/
retry_imports_test.go
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
package tests_test
import (
"flag"
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
tests "kubevirt.io/kubevirt-ansible/tests/framework"
ktests "kubevirt.io/kubevirt/tests"
)
const (
invalidURL = "https://noneexist.com"
dataVolumeName = "golden-data-volume"
dstDataVolumeFilePath = "/tmp/test-data-volume.json"
rawDataVolumeFilePath = "tests/manifests/golden-data-volume.yml"
apiVersion = "cdi.kubevirt.io/v1alpha1"
timeout = 1 * 60 * time.Second
)
var _ = Describe("Importing image using CDI with invalid URL", func() {
flag.Parse()
ktests.BeforeAll(func() {
ktests.BeforeTestCleanup()
By("Create a Data Volume with invalid image URL")
tests.ProcessTemplateWithParameters(rawDataVolumeFilePath, dstDataVolumeFilePath, "DV_NAME="+dataVolumeName, "EP_URL="+invalidURL, "API_VERSION="+apiVersion)
tests.CreateResourceWithFilePathTestNamespace(dstDataVolumeFilePath)
})
Context("Data Volume with invalid image url", func() {
It("Importer pod should be removed once data volume is deleted", func() {
By("Importer pod should be in CrashLoopBackOff status")
tests.WaitUntilResourceReadyByLabelTestNamespace("pod", tests.CDI_LABEL_SELECTOR, "", "CrashLoopBackOff")
By("Data Volume deleted successfully")
importer_pod := GetImporterPodName(dataVolumeName)
Expect(importer_pod).ToNot(BeEmpty())
tests.RemoveDataVolume(dataVolumeName, tests.NamespaceTestDefault)
By("Importer pod should be removed")
Eventually(func() string {
importer_pod := GetImporterPodName(dataVolumeName)
return importer_pod
}, timeout, 1*time.Second).Should(BeEmpty())
})
})
})
func GetImporterPodName(dataVolumeName string) string {
var importer_pod string
args := []string{"get", "pods", "-o=custom-columns=NAME:.metadata.name"}
output, _, err := ktests.RunCommand("oc", args...)
Expect(err).ToNot(HaveOccurred())
Expect(output).ToNot(BeEmpty())
pods := strings.Split(output, "\n")
for _, pod := range pods {
if strings.Contains(pod, dataVolumeName) && strings.Contains(pod, "importer") {
importer_pod = pod
break
}
}
return importer_pod
}