← Back to team overview

cloud-init-dev team mailing list archive

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

 

@smoser: thanks for the template!

@rharper: responses below two big points:

1) Knowning when network is up is a better solution than the sleep. May try to see if cloud-init is finished if cloud-init is in the images or some other solution.
2) Knowing when we need to use the proxy. When this is run in the test env. we need to have the proxy set for yum to work properly.

Diff comments:

> 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}    

I do not believe there are point release images. At least there are none today from the 'images:' remote. See: https://us.images.linuxcontainers.org/

> +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

I have found in my own running of this, that doing the following fails when scripted because the network is not up yet:
lxc launch images:centos/6 c6
lxc exec c6 -- yum install git -y

> +
> +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 ))


-- 
https://code.launchpad.net/~powersj/cloud-init/+git/cloud-init/+merge/324982
Your team cloud-init commiters is requested to review the proposed merge of ~powersj/cloud-init:create-centos-tests into cloud-init:master.


References