Skip to content

Commit

Permalink
Merge pull request #79 from ksimon1/fix/windows-test
Browse files Browse the repository at this point in the history
templates: fix windows test
  • Loading branch information
ffromani authored Aug 7, 2019
2 parents bad41a8 + ef30cd6 commit 3425ea3
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 44 deletions.
2 changes: 1 addition & 1 deletion automation/kubevirtci
Submodule kubevirtci updated 27 files
+5 −5 cluster-provision/README.md
+4 −1 cluster-provision/gocli/cmd/run.go
+1 −1 cluster-provision/okd/4.1.0/provision.sh
+2 −2 cluster-provision/okd/4.1.0/run.sh
+1 −1 cluster-provision/okd/4.1.2/provision.sh
+2 −2 cluster-provision/okd/4.1.2/run.sh
+0 −18 cluster-provision/okd/scripts/provision.sh
+1 −1 cluster-up/cluster/ephemeral-provider-common.sh
+33 −0 cluster-up/cluster/kind-k8s-1.14.2/README.md
+13 −0 cluster-up/cluster/kind-k8s-1.14.2/provider.sh
+32 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/README.md
+77 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/config_sriov.sh
+531 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/manifests/kube-flannel.yaml
+147 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/manifests/multus.yaml
+42 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/manifests/sriov-cni-daemonset.yaml
+19 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/manifests/sriov-crd.yaml
+57 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/manifests/sriovdp-daemonset.yaml
+22 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/provider.sh
+42 −0 cluster-up/cluster/kind-k8s-sriov-1.14.2/sriovdp_setup.sh
+13 −0 cluster-up/cluster/kind/README.md
+135 −0 cluster-up/cluster/kind/common.sh
+7 −0 cluster-up/cluster/kind/manifests/kind.yaml
+531 −0 cluster-up/cluster/kind/manifests/kube-flannel.yaml
+1 −1 cluster-up/cluster/okd-4.1.0/provider.sh
+1 −1 cluster-up/cluster/okd-4.1.2/provider.sh
+1 −1 cluster-up/hack/common.sh
+2 −0 cluster-up/ssh.sh
78 changes: 60 additions & 18 deletions automation/test-rhel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ _oc() {
}

template_name=$1

# Prepare PV and PVC for rhel8 testing

_oc create -f - <<EOF
Expand Down Expand Up @@ -52,8 +51,8 @@ spec:
kubevirt.io/test: "rhel"
---
EOF
sleep 10
timeout=600

timeout=300
sample=10

kubeconfig=$( cluster-up/kubeconfig.sh )
Expand All @@ -65,45 +64,88 @@ if [[ $TARGET =~ rhel6.* ]]; then
workloads=("desktop" "server")
fi

for size in ${sizes[@]}; do
for workload in ${workloads[@]}; do
templatePath="../../dist/templates/$template_name-$workload-$size.yaml"
delete_vm(){
vm_name=$1
template_path=$2
set +e
#stop vm
./virtctl --kubeconfig=$kubeconfig stop $vm_name
#delete vm
_oc process -o json --local -f $template_path NAME=$vm_name PVCNAME=disk-rhel | \
_oc delete -f -
set -e
}

run_vm(){
vm_name=$1
template_path="../../dist/templates/$vm_name.yaml"
running=false

_oc process -o json --local -f $templatePath NAME="$template_name-$workload-$size" PVCNAME=disk-rhel | \
#If first try fails, it tries 2 more time to run it, before it fails whole test
for i in `seq 1 3`; do
error=false
_oc process -o json --local -f $template_path NAME=$vm_name PVCNAME=disk-rhel | \
jq '.items[0].spec.template.spec.volumes[0]+= {"ephemeral": {"persistentVolumeClaim": {"claimName": "disk-rhel"}}} |
del(.items[0].spec.template.spec.volumes[0].persistentVolumeClaim)' | \
_oc apply -f -

# start vm
./virtctl --kubeconfig=$kubeconfig start "$template_name-$workload-$size"
./virtctl --kubeconfig=$kubeconfig start $vm_name

set +e
current_time=0
while [ $(_oc get vmi $template_name-$workload-$size -o json | jq -r '.status.phase') != Running ] ; do
_oc describe vmi $template_name-$workload-$size
while [ $(_oc get vmi $vm_name -o json | jq -r '.status.phase') != Running ] ; do
_oc describe vmi $vm_name
current_time=$((current_time + sample))
if [ $current_time -gt $timeout ]; then
exit 1
error=true
break
fi
sleep $sample;
done
set -e

if $error ; then
#delete vm
delete_vm $vm_name $template_path
#jump to next iteration and try to run vm again
continue
fi

_oc describe vm $vm_name
_oc describe vmi $vm_name

set +e
current_time=0
while [ $(./connect_to_rhel_console.exp $kubeconfig $template_name-$workload-$size | grep login | wc -l) -lt 1 ] ; do
while [ $(./connect_to_rhel_console.exp $kubeconfig $vm_name | grep login | wc -l) -lt 1 ] ; do
echo "waiting for vm to be ready"

current_time=$((current_time + sample))
if [ $current_time -gt $timeout ]; then
echo "It should show login prompt"
exit 1
echo "It should shown login prompt"
error=true
break
fi
sleep $sample;
done
set -e

delete_vm $vm_name $template_path
#no error were observed, the vm is running
if ! $error ; then
running=true
break
fi
done

./virtctl --kubeconfig=$kubeconfig stop "$template_name-$workload-$size"
if ! $running ; then
exit 1
fi
}

_oc process -o json --local -f $templatePath NAME=$template_name-$workload-$size PVCNAME=disk-rhel | \
_oc delete -f -
set -e
for size in ${sizes[@]}; do
for workload in ${workloads[@]}; do
vm_name=$template_name-$workload-$size
run_vm $vm_name
done
done
78 changes: 58 additions & 20 deletions automation/test-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ restartPolicy: Always
---
EOF

timeout=600
timeout=400
sample=30

# Make sure winrmcli pod is ready
Expand All @@ -82,59 +82,97 @@ while [ $(_oc get pod winrmcli -o json | jq -r '.status.phase') != "Running" ]
done
set -e

_oc exec -it winrmcli -- yum install -y iproute iputils
_oc exec -it winrmcli -- yum install -y iproute iputils net-tools arp-scan

kubeconfig=$( cluster-up/kubeconfig.sh )

sizes=("medium" "large")
workloads=("server" "desktop")

pwd
for size in ${sizes[@]}; do
for workload in ${workloads[@]}; do
templatePath="../../dist/templates/$template_name-$workload-$size.yaml"
delete_vm(){
vm_name=$1
template_path=$2
set +e
#stop vm
./virtctl --kubeconfig=$kubeconfig stop $vm_name
#delete vm
_oc process -o json --local -f $template_path NAME=$vm_name PVCNAME=disk-win | \
_oc delete -f -
set -e
}

run_vm(){
vm_name=$1
template_path="../../dist/templates/$vm_name.yaml"
running=false

_oc process -o json --local -f $templatePath NAME=$template_name-$workload-$size PVCNAME=disk-win | \
#If first try fails, it tries 2 more time to run it, before it fails whole test
for i in `seq 1 3`; do
error=false
_oc process -o json --local -f $template_path NAME=$vm_name PVCNAME=disk-win | \
jq '.items[0].spec.template.spec.volumes[0]+= {"ephemeral": {"persistentVolumeClaim": {"claimName": "disk-win"}}} |
del(.items[0].spec.template.spec.volumes[0].persistentVolumeClaim)' | \
_oc apply -f -

# start vm
./virtctl --kubeconfig=$kubeconfig start $template_name-$workload-$size
./virtctl --kubeconfig=$kubeconfig start $vm_name

set +e
current_time=0
while [ $(_oc get vmi $template_name-$workload-$size -o json | jq -r '.status.phase') != Running ] ; do
_oc describe vmi $template_name-$workload-$size
while [ $(_oc get vmi $vm_name -o json | jq -r '.status.phase') != Running ] ; do
_oc describe vmi $vm_name
current_time=$((current_time + sample))
if [ $current_time -gt $timeout ]; then
exit 1
error=true
break
fi
sleep $sample;
done
set -e

_oc describe vm $template_name-$workload-$size
_oc describe vmi $template_name-$workload-$size
if $error ; then
#delete vm
delete_vm $vm_name $template_path
#jump to next iteration and try to run vm again
continue
fi

_oc describe vm $vm_name
_oc describe vmi $vm_name

# get ip address of vm
ipAddressVMI=$(_oc get vmi $template_name-$workload-$size -o json| jq -r '.status.interfaces[0].ipAddress')
ipAddressVMI=$(_oc get vmi $vm_name -o json| jq -r '.status.interfaces[0].ipAddress')

set +e
pod_name=$(_oc get pods | egrep -i '*virt-launcher*' | cut -d " " -f1)
current_time=0
# run ipconfig /all command on windows vm
while [[ $(_oc exec -it winrmcli -- ./usr/bin/winrm-cli -hostname $ipAddressVMI -port 5985 -username "Administrator" -password "Heslo123" "ipconfig /all") != *"$ipAddressVMI"* ]] ; do
while [[ $(_oc exec -it winrmcli -- ./usr/bin/winrm-cli -hostname $ipAddressVMI -port 5985 -username "Administrator" -password "Heslo123" "ipconfig /all" | grep "IPv4 Address") != *"$ipAddressVMI"* ]] ; do
current_time=$((current_time + 10))
if [[ $current_time -gt $timeout ]]; then
exit 1
error=true
break
fi
sleep 10;
done

./virtctl --kubeconfig=$kubeconfig stop $template_name-$workload-$size
set -e

_oc process -o json --local -f $templatePath NAME=$template_name-$workload-$size PVCNAME=disk-$template_name | \
_oc delete -f -
delete_vm $vm_name $template_path
#no error were observed, the vm is running
if ! $error ; then
running=true
break
fi
done

if ! $running ; then
exit 1
fi
}

for size in ${sizes[@]}; do
for workload in ${workloads[@]}; do
vm_name=$template_name-$workload-$size
run_vm $vm_name
done
done
7 changes: 3 additions & 4 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ if [[ $TARGET =~ rhel.* ]]; then
# Download RHEL image
rhel_image="$RHEL_NFS_DIR/disk.img"
safe_download "$RHEL_LOCK_PATH" "$rhel_image_url" "$rhel_image" || exit 1

# Hack to correctly set rhel nfs directory for kubevirt
# https://github.com/kubevirt/kubevirt/blob/master/cluster/ephemeral-provider-common.sh#L38
# Hack to correctly set rhel nfs directory for kubevirtci
# https://github.com/kubevirt/kubevirtci/blob/master/cluster-up/cluster/ephemeral-provider-common.sh#L33
export TARGET="os-3.11.0"
fi

Expand Down Expand Up @@ -254,5 +253,5 @@ if [[ $TARGET =~ rhel.* ]]; then
fi

if [[ $TARGET =~ windows.* ]]; then
../test-windows.sh
../test-windows.sh $TARGET
fi
2 changes: 1 addition & 1 deletion stdci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sub-stages:
- windows2012
- windows2016
- windows2019
# - windows2019
- windows10
- rhel6
- rhel7
Expand Down

0 comments on commit 3425ea3

Please sign in to comment.