Skip to content

Commit

Permalink
initial functional tests for VM restore
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Henriksen <[email protected]>
  • Loading branch information
mhenriks committed Sep 10, 2020
1 parent adb1374 commit 13e6af1
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 32 deletions.
1 change: 0 additions & 1 deletion pkg/virt-controller/watch/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
Expand Down
30 changes: 0 additions & 30 deletions pkg/virt-controller/watch/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

k8sv1 "k8s.io/api/core/v1"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -138,32 +137,3 @@ func handlePVCMisuse(pvcInformer cache.SharedIndexInformer, recorder record.Even

return nil, nil
}

func podsUsingPVCs(podInformer cache.SharedIndexInformer, namespace string, pvcNames sets.String) ([]k8sv1.Pod, error) {
var pods []k8sv1.Pod

if pvcNames.Len() < 1 {
return pods, nil
}

objs, err := podInformer.GetIndexer().ByIndex(cache.NamespaceIndex, namespace)
if err != nil {
return nil, err
}

for _, obj := range objs {
pod, ok := obj.(*k8sv1.Pod)
if !ok {
return nil, fmt.Errorf("expected Pod, got %T", obj)
}

for _, volume := range pod.Spec.Volumes {
if volume.VolumeSource.PersistentVolumeClaim != nil &&
pvcNames.Has(volume.PersistentVolumeClaim.ClaimName) {
pods = append(pods, *pod)
}
}
}

return pods, nil
}
1 change: 1 addition & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ go_test(
"pausing_test.go",
"probes_test.go",
"replicaset_test.go",
"restore_test.go",
"security_features_test.go",
"snapshot_test.go",
"stability_test.go",
Expand Down
Loading

0 comments on commit 13e6af1

Please sign in to comment.