← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~powersj/cloud-init:create-centos-tests into cloud-init:master

 

Joshua Powers has proposed merging ~powersj/cloud-init:create-centos-tests into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~powersj/cloud-init/+git/cloud-init/+merge/324982

Looking for a review on this. It isn't fully working yet, complains about uncommitted changes, which I have to figure out why but:

* Creates centos 6 or 7 lxd container
* Installs pip and yum dependencies
* Creates centos user
* Tar's up working directory
* Pushes to container and untars
* As user centos, runs unittests
* As user centos, runs ./packages/brpm

I did not use make-tarball because it removes all the git stuff, and to run brpm we have to have the git info since it in turn calls make-tarball. 
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~powersj/cloud-init:create-centos-tests into cloud-init:master.
diff --git a/tools/test-centos-run.sh b/tools/test-centos-run.sh
new file mode 100755
index 0000000..13cde62
--- /dev/null
+++ b/tools/test-centos-run.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# This file is part of cloud-init. See LICENSE file for license information.
+set -ux
+
+version=${1:-7}    
+name="cloud-init-centos-$version"
+src="images:centos/$version"
+tarball='cloud-init.tar.gz'
+user='centos'
+
+error() { echo "$@" 1>&2; }
+fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
+info() { echo "$@"; }
+
+# Create tarball of current directory, with git info
+cd "$(git rev-parse --show-toplevel)" ||
+    fail "failed: changing to top level directory"
+tar_folder=${PWD##*/}
+cd ..
+tar -czvf "$tarball" "$tar_folder" || 
+    fail "failed: creating tarball"
+cd "$tar_folder/tools" ||
+    fail "failed: changing directory"
+
+lxc stop "$name" && lxc delete "$name"
+lxc launch "$src" "$name"
+
+# need to wait for networking
+sleep 10
+
+lxc exec "$name" -- useradd "$user"
+lxc exec "$name" -- /bin/sh <test-centos-setup.sh ||
+    fail "failed: setting up container"
+lxc file push "../../$tarball" "$name"/home/"$user"/
+lxc exec "$name" -- chown "$user:$user" $tarball
+lxc exec "$name" -- su "$user" -c "cd /home/$user; tar xvfz /home/$user/$tarball" ||
+    fail "failed: extracting tarball"
+
+lxc exec "$name" -- su "$user" -c "cd /home/$user/$tar_folder; nosetests tests/unittests"
+exit_1=$?
+lxc exec "$name" -- su "$user" -c "cd /home/$user/$tar_folder; ./packages/brpm -v"
+exit_2=0
+
+lxc stop "$name"
+lxc delete "$name"
+
+! (( exit_1 || exit_2 ))
diff --git a/tools/test-centos-setup.sh b/tools/test-centos-setup.sh
new file mode 100755
index 0000000..d8d16e7
--- /dev/null
+++ b/tools/test-centos-setup.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+# This file is part of cloud-init. See LICENSE file for license information.
+set -fux
+export LANG=C
+
+packages="
+    git
+    tar
+    python-pip
+    file
+    e2fsprogs
+    pyserial
+    python-argparse
+    python-cheetah
+    python-configobj
+    python-devel
+    python-jinja2
+    python-jsonpatch
+    python-oauthlib
+    python-prettytable
+    python-requests
+    python-six
+    PyYAML
+    rpm-build
+"
+
+pips="
+    contextlib2
+    httpretty
+    mock
+    nose
+    pep8
+    unittest2
+"
+
+error() { echo "$@" 1>&2; }
+fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
+info() { echo "$@"; }
+
+pips=$(for p in $pips; do echo "$p"; done | sort -u)
+packages=$(for p in $packages; do echo "$p"; done | sort -u)
+
+if ! rpm -q epel-release >/dev/null; then
+    yum install --assumeyes epel-release ||
+        fail "failed: yum install epel-release"
+fi
+yum install --assumeyes $packages ||
+        fail "failed: yum install" "$packages"
+
+pip install --upgrade $pips ||
+    fail "failed: pip install $pips"

Follow ups