Skip to content

Commit

Permalink
Make test image location for imageupload configurable
Browse files Browse the repository at this point in the history
Support bazel and plain go test.
  • Loading branch information
rmohr committed Mar 1, 2019
1 parent b0da8ef commit 149b473
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
4 changes: 4 additions & 0 deletions pkg/virtctl/imageupload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ go_test(
"imageupload_suite_test.go",
"imageupload_test.go",
],
args = [
"--cirros-image-path",
"$(location @cirros_image//file)",
],
data = ["@cirros_image//file"],
embed = [":go_default_library"],
deps = [
Expand Down
27 changes: 19 additions & 8 deletions pkg/virtctl/imageupload/imageupload_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package imageupload_test

import (
"flag"
"fmt"
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"time"

"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -30,14 +32,22 @@ const (
podPhaseAnnotation = "cdi.kubevirt.io/storage.pod.phase"
)

var _ = Describe("ImageUpload", func() {
const (
pvcNamespace = "default"
pvcName = "test-pvc"
pvcSize = "500Mi"
)

const (
pvcNamespace = "default"
pvcName = "test-pvc"
pvcSize = "500Mi"
imagePath = "../../../external/cirros_image/file/downloaded"
)
var imagePath string

func init() {
// how could this ever happen that we have a 13MB blob in our repo?
flag.StringVar(&imagePath, "cirros-image-path", "vendor/kubevirt.io/containerized-data-importer/tests/images/cirros-qcow2.img", "path to cirros test image")
flag.Parse()
imagePath = filepath.Join("../../../", imagePath)
}

var _ = Describe("ImageUpload", func() {

var (
ctrl *gomock.Controller
Expand All @@ -60,6 +70,7 @@ var _ = Describe("ImageUpload", func() {
})

addPodPhaseAnnotation := func() {
defer GinkgoRecover()
time.Sleep(10 * time.Millisecond)
pvc, err := kubeClient.CoreV1().PersistentVolumeClaims(pvcNamespace).Get(pvcName, metav1.GetOptions{})
Expect(err).To(BeNil())
Expand Down

0 comments on commit 149b473

Please sign in to comment.