Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows VM tests #809

Merged
merged 2 commits into from Apr 8, 2018
Merged

Add Windows VM tests #809

merged 2 commits into from Apr 8, 2018

Conversation

cynepco3hahue
Copy link

Requirments for Windows VM testing:

  • must exist disk-windows PVC that bounded to some PV
  • will need to start pod that includes winrm-cli tool

Tests:

  • Start Windows VM
  • Stop Windows VM
  • Verify that Windows VM has correct UUID
  • Verify that Windows VM has pod IP

Signed-off-by: Lukianov Artyom alukiano@redhat.com

@cynepco3hahue cynepco3hahue changed the title [WIP] Add Windows VM tests [Skip CI][WIP] Add Windows VM tests Mar 12, 2018
@cynepco3hahue
Copy link
Author

Start and stop windows VM tests passed, working on other tests.

Copy link
Member

@stu-gott stu-gott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far!

import (
"flag"
"fmt"
//"time"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented module

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will remove it

)
})

XIt("should have correct UUID", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The X means "skip", right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I still trying to make work exec command via API, so I disable this tests ro run locally until it will work.

@cynepco3hahue cynepco3hahue changed the title [Skip CI][WIP] Add Windows VM tests [WIP] Add Windows VM tests Mar 14, 2018
@cynepco3hahue cynepco3hahue changed the title [WIP] Add Windows VM tests Add Windows VM tests Mar 14, 2018
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have preferred the possibility to directly talk to windows from within our code with winrm, but it is a good start to create this extra container.

# Copyright 2018 Red Hat, Inc.
#

FROM golang:1.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we can provide winrm-cli without having to pull in anoter image which is not fedora:27.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check if we have the possibility to bring fedora 27 with go inside

tests.BeforeAll(func() {
windowsPv, err := virtClient.CoreV1().PersistentVolumes().Get(tests.DiskWindows, metav1.GetOptions{})
if err != nil {
Skip(fmt.Sprintf("Skip Windows tests that requires PVC %s", tests.DiskWindows))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create a helper which is called something like SkipIfNoWindowsImage() and isolate the logic in utils.go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we call this in a BeforeEach block? The BeforeAll is a not so well done extension for Ginkgo by us.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • will create a separate helper
  • yes I know, I just wanted to avoid calling to Kube API for each test, it just relevant for all windows tests
    @rmohr Do you have some objections vs BeforeAll, I checked ginkgo issue and the only objections vs it, was the possibility to run tests in parallel, but for windows testing, we can't run in parallel anyway(without test code changes)

if err != nil {
Skip(fmt.Sprintf("Skip Windows tests that requires PVC %s", tests.DiskWindows))
}
windowsPv.Spec.ClaimRef = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that before testing we already added windows PV to the cluster, and maybe it already used by some PVC(currently not), so the PV will have the state Released, but new PVC still cannot use it(https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retain), so I remove ClaimRef to move it to Available state(I checked via google, looks it acceptable action that does not do any harm to the cluster).
I think I will check on PV state, if it has Released state I will remove ClaimRef, otherwise will skip windows tests.

Copy link
Author

@cynepco3hahue cynepco3hahue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I also more like API usage instead of calling to pod exec command, but currently we run tests outside of the cluster and we do not have the possibility to reach VM

# Copyright 2018 Red Hat, Inc.
#

FROM golang:1.6
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check if we have the possibility to bring fedora 27 with go inside

tests.BeforeAll(func() {
windowsPv, err := virtClient.CoreV1().PersistentVolumes().Get(tests.DiskWindows, metav1.GetOptions{})
if err != nil {
Skip(fmt.Sprintf("Skip Windows tests that requires PVC %s", tests.DiskWindows))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • will create a separate helper
  • yes I know, I just wanted to avoid calling to Kube API for each test, it just relevant for all windows tests
    @rmohr Do you have some objections vs BeforeAll, I checked ginkgo issue and the only objections vs it, was the possibility to run tests in parallel, but for windows testing, we can't run in parallel anyway(without test code changes)

if err != nil {
Skip(fmt.Sprintf("Skip Windows tests that requires PVC %s", tests.DiskWindows))
}
windowsPv.Spec.ClaimRef = nil
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that before testing we already added windows PV to the cluster, and maybe it already used by some PVC(currently not), so the PV will have the state Released, but new PVC still cannot use it(https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retain), so I remove ClaimRef to move it to Available state(I checked via google, looks it acceptable action that does not do any harm to the cluster).
I think I will check on PV state, if it has Released state I will remove ClaimRef, otherwise will skip windows tests.

@cynepco3hahue
Copy link
Author

Passed fine on my environment 😄

Running Suite: Tests Suite
==========================
Random Seed: 1521032584
Will run 4 of 64 specs

SSSSSSSSSSSSSSSSSSSSSSSSSSS
------------------------------
• [SLOW TEST:109.742 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  should success to start
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:128
------------------------------
• [SLOW TEST:39.100 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  should success to stop
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:134
------------------------------
• [SLOW TEST:237.837 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  with winrm connection
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:145
    should have correct UUID
    /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:185
------------------------------
• [SLOW TEST:219.764 seconds]
Windows VM                                                                                                                                                
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  with winrm connection
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:145
    should have pod IP
    /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:201

@cynepco3hahue
Copy link
Author

I ran it on nested environment and it looks pretty good 😄

./automation/test.sh 
+ export WORKSPACE=/home/alukiano/go/src/kubevirt.io/kubevirt
+ WORKSPACE=/home/alukiano/go/src/kubevirt.io/kubevirt
+ export PROVIDER=k8s-1.9.3
+ PROVIDER=k8s-1.9.3
+ export VAGRANT_NUM_NODES=1
+ VAGRANT_NUM_NODES=1
+ export NAMESPACE=kube-system
+ NAMESPACE=kube-system
+ trap '{ make cluster-down; }' EXIT
+ make cluster-down
./cluster/down.sh
+ NFS_SERVER=nfs
+ NFS_WINDOWS_DIR=/home/alukiano/Downloads/windows2016_images/qe_image
...
Waiting for rsyncd to be ready
rsync: safe_read failed to read 1 bytes [sender]: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(276) [sender=3.1.3]
Waiting for rsyncd to be ready
skipping directory .
go version go1.9.2 linux/amd64
Compiling tests...
    compiled tests.test
a68ea9e93176f3722987df3a3db20c6cb4e7790f78eb890da4c9de83be5fc63a
a68ea9e93176f3722987df3a3db20c6cb4e7790f78eb890da4c9de83be5fc63a
hack/functests.sh
Running Suite: Tests Suite
==========================
Random Seed: 1521657006
Will run 4 of 66 specs

SSSSSSSSSSSSSSSSSSSSSSSSSSSSS
------------------------------
• [SLOW TEST:14.475 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  should success to start
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:128
------------------------------
• [SLOW TEST:13.016 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  should success to stop
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:134
------------------------------
• [SLOW TEST:149.177 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  with winrm connection
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:145
    should have correct UUID
    /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:185
------------------------------
• [SLOW TEST:204.675 seconds]
Windows VM
/root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:54
  with winrm connection
  /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:145
    should have pod IP
    /root/go/src/kubevirt.io/kubevirt/tests/windows_test.go:201
------------------------------
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
Waiting for namespace kubevirt-test-default to be removed, this can take a while ...
Waiting for namespace kubevirt-test-alternative to be removed, this can take a while ...

Ran 4 of 66 Specs in 424.611 seconds
SUCCESS! -- 4 Passed | 0 Failed | 0 Pending | 62 Skipped PASS
+ make cluster-down
./cluster/down.sh

Will see how does it will work on CI.

@cynepco3hahue
Copy link
Author

@rmohr I ran it on CI host and unexpectedly it all passed with pretty good times(almost the same as on my environment) 😄

@cynepco3hahue
Copy link
Author

retest this please

@cynepco3hahue cynepco3hahue force-pushed the windows_tests branch 6 times, most recently from 6219815 to 39e342e Compare March 26, 2018 14:05
@cynepco3hahue
Copy link
Author

Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes requests.

Expect(output).Should(ContainSubstring(strings.ToUpper(windowsFirmware)))
}, 360)

It("should have pod IP", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of fetching the pod, you can simply wait for the vm to run and look up the ip from its status.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

tests.WaitForSuccessfulVMStartWithTimeout(vm, 180)
}, 300)

It("should success to stop", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It("should succeed to stop a running vm"), By("Strating the vm"), By ("Stopping the vm")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

windowsVm.Spec = windowsVmSpec
})

It("should success to start", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It("should succeed to start a vm")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

var cli []string
var output string

BeforeEach(func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I am convinced now that the BeforeAll which we have should also be good enough in this case.

To test Windows VM we need to create additional pod that
will have winrm-cli tool.

Tests:
- Start Windows VM
- Stop Windows VM
- Verify that Windows VM has correct UUID
- Verify that Windows VM has pod IP

Signed-off-by: Lukianov Artyom <alukiano@redhat.com>
Signed-off-by: Lukianov Artyom <alukiano@redhat.com>
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Once the windows image is in place again we can rerun a last time and then merge.

@cynepco3hahue
Copy link
Author

@rmohr rmohr merged commit e83802d into kubevirt:master Apr 8, 2018
@cynepco3hahue cynepco3hahue deleted the windows_tests branch April 12, 2018 12:25
kubevirt-bot pushed a commit to kubevirt-bot/kubevirt that referenced this pull request Nov 6, 2020
Adding code to not allow importing from registry when contenType is not kubevirt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants