Skip to content

Commit

Permalink
hooks: fix timeout and sidecar name in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phoracek committed Jul 5, 2018
1 parent e82fb35 commit a8093cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -28,3 +28,4 @@ vendor/**/*_test.go
**/polarion.xml
tools/manifest-templator/manifest-templator
tools/vms-generator/vms-generator
.coverprofile
3 changes: 1 addition & 2 deletions cmd/virt-launcher/virt-launcher.go
Expand Up @@ -50,7 +50,6 @@ import (

const defaultStartTimeout = 3 * time.Minute
const defaultWatchdogInterval = 5 * time.Second
const hookSidecarsCollectTimeout = 10 * time.Second

func markReady(readinessFile string) {
f, err := os.OpenFile(readinessFile, os.O_RDONLY|os.O_CREATE, 0666)
Expand Down Expand Up @@ -268,7 +267,7 @@ func main() {

// Block until all requested hookSidecars are ready
hookManager := hooks.GetManager()
err := hookManager.Collect(*hookSidecars, hookSidecarsCollectTimeout)
err := hookManager.Collect(*hookSidecars, *qemuTimeout)
if err != nil {
panic(err)
}
Expand Down
14 changes: 4 additions & 10 deletions tests/vmi_hook_sidecar_test.go
Expand Up @@ -35,6 +35,8 @@ import (
"kubevirt.io/kubevirt/tests"
)

const hookSidecarImage = "example-hook-sidecar"

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

flag.Parse()
Expand All @@ -48,7 +50,7 @@ var _ = Describe("HookSidecars", func() {
tests.BeforeTestCleanup()
vmi = tests.NewRandomVMIWithEphemeralDisk(tests.RegistryDiskFor(tests.RegistryDiskAlpine))
vmi.ObjectMeta.Annotations = map[string]string{
"hooks.kubevirt.io/hookSidecars": `[{"image": "registry:5000/kubevirt/example-hook-sidecar:devel"}]`,
"hooks.kubevirt.io/hookSidecars": fmt.Sprintf(`[{"image": "%s/%s:%s", "imagePullPolicy": "IfNotPresent"}]`, tests.KubeVirtRepoPrefix, hookSidecarImage, tests.KubeVirtVersionTag),
"smbios.vm.kubevirt.io/baseBoardManufacturer": "Radical Edward",
}
})
Expand All @@ -62,7 +64,7 @@ var _ = Describe("HookSidecars", func() {
tests.WaitForSuccessfulVMIStart(vmi)
}, 300)

It("should call Collect on the hook sidecar", func() {
It("should call Collect and OnDefineDomain on the hook sidecar", func() {
By("Getting hook-sidecar logs")
vmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -72,14 +74,6 @@ var _ = Describe("HookSidecars", func() {
11*time.Second,
500*time.Millisecond).
Should(ContainSubstring("Hook's Info method has been called"))
}, 300)

It("should call OnDefineDomain on the hook sidecar", func() {
By("Getting hook-sidecar logs")
vmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expect(err).ToNot(HaveOccurred())
logs := func() string { return getHookSidecarLogs(virtClient, vmi) }
tests.WaitForSuccessfulVMIStart(vmi)
Eventually(logs,
11*time.Second,
500*time.Millisecond).
Expand Down

0 comments on commit a8093cf

Please sign in to comment.