Skip to content

Commit

Permalink
destroy/recreate branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenriks committed Nov 26, 2018
1 parent 6e6c1e4 commit d35b62b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
12 changes: 6 additions & 6 deletions manifests/testing/cdi-v1.3.0.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ metadata:
name: cdi-apiserver
namespace: {{.Namespace}}
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: cdi-apiserver
namespace: {{.Namespace}}
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
roleRef:
kind: Role
name: cdi-apiserver
Expand All @@ -143,7 +143,7 @@ metadata:
name: cdi-apiserver
namespace: {{.Namespace}}
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
rules:
- apiGroups:
- ''
Expand All @@ -165,7 +165,7 @@ kind: ClusterRoleBinding
metadata:
name: cdi-apiserver
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
roleRef:
kind: ClusterRole
name: cdi-apiserver
Expand All @@ -180,7 +180,7 @@ kind: ClusterRole
metadata:
name: cdi-apiserver
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
rules:
- apiGroups:
- apiregistration.k8s.io
Expand All @@ -204,7 +204,7 @@ kind: ClusterRoleBinding
metadata:
name: cdi-apiserver-auth-delegator
labels:
kubevirt.io: ""
cdi.kubevirt.io: ""
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
4 changes: 2 additions & 2 deletions manifests/testing/local-block-storage.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
values:
- node01
persistentVolumeReclaimPolicy: Retain
storageClassName: local
storageClassName: local-block
volumeMode: Block
---
apiVersion: v1
Expand All @@ -37,7 +37,7 @@ spec:
requests:
storage: 1Gi
volumeMode: Block
storageClassName: local
storageClassName: local-block
selector:
matchLabels:
blockstorage: "cirros"
1 change: 1 addition & 0 deletions tests/imageupload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var _ = Describe("ImageUpload", func() {
"--pvc-size", pvcSize,
"--uploadproxy-url", fmt.Sprintf("https://127.0.0.1:%d", localUploadProxyPort),
"--wait-secs", "30",
"--storage-class", "local",
"--insecure")
err = virtctlCmd()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ var _ = Describe("Storage", func() {
BeforeEach(func() {
// Setup second PVC to use in this context
tests.CreateHostPathPv(tests.CustomHostPath, tests.HostPathCustom)
tests.CreatePVC(tests.CustomHostPath, "1Gi")
tests.CreateHostPathPVC(tests.CustomHostPath, "1Gi")
}, 120)

AfterEach(func() {
Expand Down Expand Up @@ -397,7 +397,7 @@ var _ = Describe("Storage", func() {
BeforeEach(func() {
for _, pvc := range pvcs {
tests.CreateHostPathPv(pvc, filepath.Join(tests.HostPathBase, pvc))
tests.CreatePVC(pvc, "1G")
tests.CreateHostPathPVC(pvc, "1G")
}
}, 120)

Expand Down
55 changes: 37 additions & 18 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ const (
NamespaceTestAlternative = "kubevirt-test-alternative"
)

const LocalStorageClass = "local"
const (
LocalStorageClass = "local"

HostPathStorageClass = "host-path"

BlockVolumeStorageClass = "block-volume"
)

var testNamespaces = []string{NamespaceTestDefault, NamespaceTestAlternative}

Expand Down Expand Up @@ -364,10 +370,10 @@ func BeforeTestSuitSetup() {
createServiceAccounts()

CreateHostPathPv(osAlpineHostPath, HostPathAlpine)
CreatePVC(osAlpineHostPath, defaultDiskSize)
CreateHostPathPVC(osAlpineHostPath, defaultDiskSize)

CreatePVC(osWindows, defaultWindowsDiskSize)
CreatePVC(osRhel, defaultRhelDiskSize)
CreateLocalPVC(osWindows, defaultWindowsDiskSize)
CreateLocalPVC(osRhel, defaultRhelDiskSize)

EnsureKVMPresent()

Expand Down Expand Up @@ -441,22 +447,29 @@ func CreateSecret(name string, data map[string]string) {
}
}

func CreatePVC(os string, size string) {
func CreateHostPathPVC(os, size string) {
CreatePVC(os, size, HostPathStorageClass)
}

func CreateLocalPVC(os, size string) {
CreatePVC(os, size, LocalStorageClass)
}

func CreatePVC(os, size, storageClass string) {
virtCli, err := kubecli.GetKubevirtClient()
PanicOnError(err)

_, err = virtCli.CoreV1().PersistentVolumeClaims(NamespaceTestDefault).Create(newPVC(os, size))
_, err = virtCli.CoreV1().PersistentVolumeClaims(NamespaceTestDefault).Create(newPVC(os, size, storageClass))
if !errors.IsAlreadyExists(err) {
PanicOnError(err)
}
}

func newPVC(os string, size string) *k8sv1.PersistentVolumeClaim {
func newPVC(os, size, storageClass string) *k8sv1.PersistentVolumeClaim {
quantity, err := resource.ParseQuantity(size)
PanicOnError(err)

name := fmt.Sprintf("disk-%s", os)
storageClass := LocalStorageClass

return &k8sv1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{Name: name},
Expand Down Expand Up @@ -510,7 +523,7 @@ func CreateHostPathPvWithSize(osName string, hostPath string, size string) {
Type: &hostPathType,
},
},
StorageClassName: LocalStorageClass,
StorageClassName: HostPathStorageClass,
NodeAffinity: &k8sv1.VolumeNodeAffinity{
Required: &k8sv1.NodeSelector{
NodeSelectorTerms: []k8sv1.NodeSelectorTerm{
Expand Down Expand Up @@ -1175,7 +1188,7 @@ func newBlockVolumePV(name string, labelSelector map[string]string, size string)
quantity, err := resource.ParseQuantity(size)
PanicOnError(err)

storageClass := LocalStorageClass
storageClass := BlockVolumeStorageClass
volumeMode := k8sv1.PersistentVolumeBlock

// Note: the path depends on kubevirtci!
Expand Down Expand Up @@ -1221,7 +1234,7 @@ func newBlockVolumePVC(name string, labelSelector map[string]string, size string
quantity, err := resource.ParseQuantity(size)
PanicOnError(err)

storageClass := LocalStorageClass
storageClass := BlockVolumeStorageClass
volumeMode := k8sv1.PersistentVolumeBlock

return &k8sv1.PersistentVolumeClaim{
Expand Down Expand Up @@ -2442,15 +2455,21 @@ func KubevirtFailHandler(message string, callerSkip ...int) {
}

for _, ns := range []string{KubeVirtInstallNamespace, metav1.NamespaceSystem, NamespaceTestDefault} {
// Get KubeVirt specific pods information
pods, err := virtClient.CoreV1().Pods(ns).List(metav1.ListOptions{LabelSelector: "kubevirt.io"})
if err != nil {
fmt.Println(err)
Fail(message, callerSkip...)
return
// Get KubeVirt and CDI specific pods information
labels := []string{"kubevirt.io", "cdi.kubevirt.io"}
allPods := []k8sv1.Pod{}

for _, label := range labels {
pods, err := virtClient.CoreV1().Pods(ns).List(metav1.ListOptions{LabelSelector: label})
if err != nil {
fmt.Println(err)
Fail(message, callerSkip...)
return
}
allPods = append(allPods, pods.Items...)
}

for _, pod := range pods.Items {
for _, pod := range allPods {
fmt.Printf("\nPod name: %s\t Pod phase: %s\n\n", pod.Name, pod.Status.Phase)
var tailLines int64 = 15
var containerName = ""
Expand Down

0 comments on commit d35b62b

Please sign in to comment.