From Yaniv Bronhaim <ybron...@redhat.com>:

Yaniv Bronhaim has uploaded a new change for review.

Change subject: check-merged: split functions by logic and few nits
......................................................................

check-merged: split functions by logic and few nits

adding local, var renames

Change-Id: I74f9326289b972abaef4507ab4d2582a8d641778
Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com>
---
M automation/check-merged.sh
1 file changed, 27 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/70825/1

diff --git a/automation/check-merged.sh b/automation/check-merged.sh
index ef81436..e6933b9 100755
--- a/automation/check-merged.sh
+++ b/automation/check-merged.sh
@@ -6,17 +6,25 @@
 # direct backend, but without KVM(much slower).
 ! [[ -c "/dev/kvm" ]] && mknod /dev/kvm c 10 232
 
+# Fix when running in an el* chroot in fc2* host
+[[ -e /usr/bin/qemu-kvm ]] \
+|| ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
 
+# ENV vars
 DISTRO='el7'
 VM_NAME="vdsm_functional_tests_host-${DISTRO}"
 AUTOMATION="$PWD"/automation
 PREFIX="$AUTOMATION"/vdsm_functional
 EXPORTS="$PWD"/exported-artifacts
 
-function prepare {
+function setup_env {
+    # TODO: ask lago to create this folder
+    mkdir "$EXPORTS"/lago-logs
+
     # Creates RPMS
     "$AUTOMATION"/build-artifacts.sh
 
+    # TODO: jenkins mock env should take care of that
     if [[ -d "$PREFIX" ]]; then
         pushd "$PREFIX"
         echo 'cleaning old lago env'
@@ -25,15 +33,14 @@
         rm -rf "$PREFIX"
     fi
 
-    # Fix when running in an el* chroot in fc2* host
-    [[ -e /usr/bin/qemu-kvm ]] \
-    || ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
 
     lago init \
         "$PREFIX" \
         "$AUTOMATION"/lago-env.yml
 
     cd "$PREFIX"
+
+    # TODO: remove --reposync-yum-config /dev/null if not needed
     lago ovirt reposetup \
         --reposync-yum-config /dev/null \
         --custom-source "dir:$EXPORTS"
@@ -84,9 +91,6 @@
 }
 
 function run {
-    mkdir "$EXPORTS"/lago-logs
-    failed=0
-
     lago start "$VM_NAME"
 
     prepare_and_copy_yum_conf
@@ -95,28 +99,33 @@
     # otherwise
     lago ovirt deploy
 
+    # TODO: ask lago to have cooler way to keep the localrepo up
     lago ovirt serve &
-    PID=$!
+    local httpd_pid=$!
 
-    fake_ksm_in_vm
+    fake_ksm_in_vm && run_all_tests
+    local failed=$?
 
+    kill $httpd_pid
+
+    return $failed
+}
+
+function run_all_tests {
     run_infra_tests | tee "$EXPORTS/functional_tests_stdout.$DISTRO.log"
     failed="${PIPESTATUS[0]}"
 
     run_network_tests | tee -a "$EXPORTS/functional_tests_stdout.$DISTRO.log"
     res="${PIPESTATUS[0]}"
     [ "$res" -ne 0 ] && failed="$res"
+}
 
-    kill $PID
-
-    lago copy-from-vm \
-    "$VM_NAME" \
-    "/tmp/nosetests-${DISTRO}.xml" \
-    "$EXPORTS/nosetests-${DISTRO}.xml" || :
+function collect_logs {
+    lago copy-from-vm "$VM_NAME" \
+        "/tmp/nosetests-${DISTRO}.xml" \
+        "$EXPORTS/nosetests-${DISTRO}.xml" || :
     lago collect --output "$EXPORTS"/lago-logs
-
     cp "$PREFIX"/current/logs/*.log "$EXPORTS"/lago-logs
-    return $failed
 }
 
 function cleanup {
@@ -124,5 +133,5 @@
     lago cleanup
 }
 
-prepare && run && cleanup
+setup_env && run && collect_logs && cleanup
 exit $?


-- 
To view, visit https://gerrit.ovirt.org/70825
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I74f9326289b972abaef4507ab4d2582a8d641778
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to