Add tempest run scripts and prepare scripts

Also change some hardcoded network config to dynamic
Change-Id: I5dc1df89b32436a41cf7d7c46e30be879207b224
This commit is contained in:
zhaoxinyu 2014-04-01 00:12:34 +00:00
parent 74f1bc08a4
commit 885609ef39
7 changed files with 158 additions and 5 deletions

View File

@ -1,7 +1,9 @@
#!/bin/bash #!/bin/bash
echo 'Installing Required packages for Compass...' echo 'Installing Required packages for Compass...'
if [ "$tempest" == "true" ]; then
sudo yum install -y virt-install libvirt qemu-kvm libxml2-devel libxslt-devel python-devel sshpass
fi
sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python git wget python-setuptools python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis sudo yum install -y rsyslog logrotate ntp iproute openssh-clients python git wget python-setuptools python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock mod_wsgi httpd squid dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e ca-certificates redis python-redis
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
echo "failed to install yum dependency" echo "failed to install yum dependency"
@ -14,6 +16,11 @@ if [[ "$?" != "0" ]]; then
exit 1 exit 1
fi fi
if [ "$tempest" == "true" ]; then
sudo pip install -U setuptools
sudo pip install -U setuptools
sudo pip install -U shyaml
fi
sudo pip install -r $COMPASSDIR/requirements.txt sudo pip install -r $COMPASSDIR/requirements.txt
sudo pip install -r $COMPASSDIR/test-requirements.txt sudo pip install -r $COMPASSDIR/test-requirements.txt
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then

View File

@ -15,14 +15,17 @@ export NIC=installation
# DHCP config # DHCP config
# SUBNET variable specifies the subnet for DHCP server. Example: 192.168.0.0/16 # SUBNET variable specifies the subnet for DHCP server. Example: 192.168.0.0/16
export SUBNET=192.168.10.0/24 export ipaddr=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
export ipnet=$(ip address| grep "global $NIC" |cut -f 6 -d ' ')
export SUBNET=$(ipcalc $ipnet -n |cut -f 2 -d '=')/$(ipcalc $ipnet -p |cut -f 2 -d '=')
# DHCP option router address(Default is your management interface IP address )" # DHCP option router address(Default is your management interface IP address )"
export OPTION_ROUTER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` export OPTION_ROUTER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
# The IP range for DHCP clients (Default: local subnet start from 100 to 254) # The IP range for DHCP clients (Default: local subnet start from 100 to 254)
export IP_RANGE='192.168.10.100 192.168.10.254' export ip_start=`echo $ipaddr |cut -d. -f'1 2 3'`.128
export ip_end=`echo $ipaddr |cut -d. -f'1 2 3'`.254
export IP_RANGE="$ip_start $ip_end"
# TFTP server's IP address(Default: Management Interface/eth0 IP) # TFTP server's IP address(Default: Management Interface/eth0 IP)
export NEXTSERVER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` export NEXTSERVER=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
export ipaddr=`ifconfig $NIC | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
# the domains covered by nameserver # the domains covered by nameserver
export NAMESERVER_DOMAINS=ods.com export NAMESERVER_DOMAINS=ods.com

View File

@ -123,6 +123,22 @@ else
copylocal2dir $ADAPTER_SOURCE $ADAPTER_HOME copylocal2dir $ADAPTER_SOURCE $ADAPTER_HOME
fi fi
if [ "$tempest" == "true" ]; then
if [[ ! -e /tmp/tempest ]]; then
git clone http://git.openstack.org/openstack/tempest /tmp/tempest
cd /tmp/tempest
git checkout grizzly-eol
else
cd /tmp/tempest
git remote set-url origin http://git.openstack.org/openstack/tempest
git remote update
git reset --hard
git clean -x -f -d -q
git checkout grizzly-eol
fi
pip install -e .
fi
download() download()
{ {
url=$1 url=$1

14
misc/ci/prepare_node_compass.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash -x
echo 0 > /selinux/enforce
yum -y update
sed -i "s/Defaults requiretty/#Defaults requiretty/" /etc/sudoers
git clone http://git.openstack.org/stackforge/compass-core
cd compass-core
source install/install.conf.template
export tempest=true
source install/dependency.sh
source install/prepare.sh
service libvirtd start
sync
sleep 5
echo "image preparation done"

View File

@ -8,3 +8,6 @@ virsh start pxe01
virsh list virsh list
source compass-core/install/install.conf.template source compass-core/install/install.conf.template
/usr/bin/python /tmp/test.py /usr/bin/python /tmp/test.py
if [ "$tempest" == "true" ]; then
./tempest_run.sh
fi

View File

@ -16,7 +16,7 @@ fi
virt-install --accelerate --hvm --connect qemu:///system \ virt-install --accelerate --hvm --connect qemu:///system \
--network=bridge:installation,mac=00:11:20:30:40:01 --pxe \ --network=bridge:installation,mac=00:11:20:30:40:01 --pxe \
--network=network:default \ --network=network:default \
--name pxe01 --ram=4096 \ --name pxe01 --ram=8192 \
--disk /tmp/pxe01.raw,format=raw \ --disk /tmp/pxe01.raw,format=raw \
--vcpus=10 \ --vcpus=10 \
--graphics vnc,listen=0.0.0.0 --noautoconsole \ --graphics vnc,listen=0.0.0.0 --noautoconsole \

110
misc/ci/tempest_run.sh Executable file
View File

@ -0,0 +1,110 @@
#!/bin/bash -xe
# Determinate is the given option present in the INI file
# ini_has_option config-file section option
function ini_has_option {
local xtrace=$(set +o | grep xtrace)
set +o xtrace
local file=$1
local section=$2
local option=$3
local line
line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
$xtrace
[ -n "$line" ]
}
# Set an option in an INI file
# iniset config-file section option value
function iniset {
local xtrace=$(set +o | grep xtrace)
set +o xtrace
local file=$1
local section=$2
local option=$3
local value=$4
[[ -z $section || -z $option ]] && return
if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then
# Add section at the end
echo -e "\n[$section]" >>"$file"
fi
if ! ini_has_option "$file" "$section" "$option"; then
# Add it
sed -i -e "/^\[$section\]/ a\\
$option = $value
" "$file"
else
local sep=$(echo -ne "\x01")
# Replace it
sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
fi
$xtrace
}
#Install prerequites for Tempest
pip install tox==1.6.1
#Install setuptools twice so that it is really upgraded
pip install -U setuptools
pip install -U setuptools
pip install shyaml
yum install -y libxml2-devel libxslt-devel python-devel sshpass
if [[ ! -e /tmp/tempest ]]; then
git clone http://git.openstack.org/openstack/tempest /tmp/tempest
cd /tmp/tempest
git checkout grizzly-eol
else
cd /tmp/tempest
git remote set-url origin http://git.openstack.org/openstack/tempest
git remote update
git reset --hard
git clean -x -f -d -q
git checkout grizzly-eol
fi
cd /tmp/tempest
#Install Tempest including dependencies
pip install -e .
if [[ ! -e /etc/tempest ]]; then
mkdir /etc/tempest
fi
#Initialize cloud environment for test and Tempest config file
cp etc/tempest.conf.sample /etc/tempest/tempest.conf
nova_api_host=`knife data bag show openstack openstack_1 | shyaml get-value endpoints.compute.service.host`
sshpass -p 'root' scp -o StrictHostKeyChecking=no -r root@$nova_api_host:/root/openrc /root/.
source /root/openrc
demo_tenant_id=`keystone tenant-create --name demo |grep " id " |awk '{print $4}'`
alt_demo_tenant_id=`keystone tenant-create --name alt_demo |grep " id " |awk '{print $4}'`
keystone user-create --name demo --pass secret --tenant $demo_tenant_id
keystone user-create --name alt_demo --pass secret --tenant $alt_demo_tenant_id
image_id=`glance image-list |grep 'cirros'|awk '{print$2}'`
private_net_id=`quantum net-create --tenant_id $demo_tenant_id private |grep " id " |awk '{print$4}'`
quantum subnet-create --tenant_id $demo_tenant_id --ip_version 4 --gateway 10.1.0.1 $private_net_id 10.10.0.0/24
router_id=`quantum router-create --tenant_id $demo_tenant_id router1|grep " id " |awk '{print$4}'`
public_net_id=`quantum net-create public -- --router:external=True |grep " id " |awk '{print$4}'`
quantum subnet-create --ip_version 4 $public_net_id 172.24.4.0/28 -- --enable_dhcp=False
quantum router-gateway-set $router_id $public_net_id
iniset /etc/tempest/tempest.conf identity uri $OS_AUTH_URL
iniset /etc/tempest/tempest.conf identity admin_username $OS_USERNAME
iniset /etc/tempest/tempest.conf identity admin_password $OS_PASSWORD
iniset /etc/tempest/tempest.conf compute allow_tenant_isolation false
iniset /etc/tempest/tempest.conf compute image_ref $image_id
iniset /etc/tempest/tempest.conf compute image_ref_alt $image_id
iniset /etc/tempest/tempest.conf compute image_ssh_user cirros
iniset /etc/tempest/tempest.conf compute image_alt_ssh_user cirros
iniset /etc/tempest/tempest.conf compute resize_available false
iniset /etc/tempest/tempest.conf compute change_password_available false
iniset /etc/tempest/tempest.conf compute build_interval 15
iniset /etc/tempest/tempest.conf whitebox whitebox_enabled false
iniset /etc/tempest/tempest.conf network public_network_id $public_net_id
iniset /etc/tempest/tempest.conf network public_router_id ''
iniset /etc/tempest/tempest.conf network quantum_available true
#Start a smoke test against cloud without object storage and aws related tests
#as they are unavailable for now
if [ $tempest_full == true ]; then
nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --attr=type=smoke \
--xunit-file=nosetests-smoke.xml tempest -e object_storage -e boto
else
nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit --xunit-file=nosetests-smoke.xml \
-sv --attr=type=smoke --tests="\
tempest.tests.compute.servers.test_server_addresses:ServerAddressesTest.test_list_server_addresses,\
tempest.tests.compute.servers.test_create_server:ServersTestAutoDisk.test_verify_server_details,\
tempest.tests.volume.test_volumes_get:VolumesGetTest.test_volume_create_get_delete"
fi