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 pathe2e_test.go
63 lines (51 loc) · 1.93 KB
/
e2e_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
package tests_test
import (
"os"
. "github.com/onsi/ginkgo"
tests "kubevirt.io/kubevirt-ansible/tests/framework"
)
// template parameters
const (
pvcEPHTTPNOAUTHURL = "https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img"
invalidPVCURL = "https://noneexist.com"
pvcName = "golden-pvc"
pvcName1 = "golden-pvc1"
vmName = "test-vm"
vmAPIVersion = "kubevirt.io/v1alpha3"
rawPVCFilePath = "tests/manifests/golden-pvc.yml"
rawVMFilePath = "tests/manifests/test-vm.yml"
)
var _ = Describe("Importing and starting a VM using CDI", func() {
var dstPVCFilePath, dstVMFilePath, newPVCName, url string
BeforeEach(func() {
var ok bool
dstPVCFilePath = "/tmp/test-pvc.json"
dstVMFilePath = "/tmp/test-vm.json"
newPVCName = pvcName
url, ok = os.LookupEnv("STREAM_IMAGE_URL")
if !ok {
url = pvcEPHTTPNOAUTHURL
}
})
JustBeforeEach(func() {
tests.ProcessTemplateWithParameters(rawPVCFilePath, dstPVCFilePath, "PVC_NAME="+newPVCName, "EP_URL="+url)
tests.CreateResourceWithFilePathTestNamespace(dstPVCFilePath)
})
Context("PVC with valid image url", func() {
It("will succeed", func() {
tests.WaitUntilResourceReadyByNameTestNamespace("pvc", pvcName, "-o=jsonpath='{.metadata.annotations}'", "pv.kubernetes.io/bind-completed:yes")
tests.ProcessTemplateWithParameters(rawVMFilePath, dstVMFilePath, "VM_NAME="+vmName, "PVC_NAME="+pvcName, "VM_APIVERSION="+vmAPIVersion)
tests.CreateResourceWithFilePathTestNamespace(dstVMFilePath)
tests.WaitUntilResourceReadyByNameTestNamespace("vmi", vmName, "-o=jsonpath='{.status.phase}'", "Running")
})
})
Context("PVC with invalid image url", func() {
BeforeEach(func() {
newPVCName = pvcName1
url = invalidPVCURL
})
It("will be failed because the PVC should become failed", func() {
tests.WaitUntilResourceReadyByLabelTestNamespace("pod", tests.CDI_LABEL_SELECTOR, "", "CrashLoopBackOff")
})
})
})