From a60b5d2ccdcb94abaa9513d9a349fb0710a7f92d Mon Sep 17 00:00:00 2001 From: zhaoxinyu Date: Thu, 3 Apr 2014 23:16:17 +0000 Subject: [PATCH] Change some static values to dynamic and add minimal test config Also fixed some typos and add teardown after test Change-Id: If279d8c59d32a6eef0e6dded726ead99d4c644e6 --- bin/client.py | 14 +++---- compass/apiclient/example.py | 2 + install/prepare.sh | 1 + misc/ci/tempest_run.sh | 4 +- regtest/regtest.conf | 15 ++++---- regtest/regtest.sh | 69 ++++++++++++++++++++++------------ regtest/regtest3.conf | 2 +- regtest/regtest_dashboard.conf | 10 +++++ 8 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 regtest/regtest_dashboard.conf diff --git a/bin/client.py b/bin/client.py index 92bdc71c..00e66932 100755 --- a/bin/client.py +++ b/bin/client.py @@ -77,13 +77,11 @@ flags.add('host_roles', ), default='') flags.add('deployment_timeout', - type='int', - help='deployment timeout', - default=60 * 60) + help='deployment timeout in minutes', + default=60) flags.add('progress_update_check_interval', - type='int', - help='progress update status check interval', - default=30) + help='progress update status check interval in seconds', + default=60) flags.add('dashboard_role', help='dashboard role name', default='os-dashboard') @@ -447,7 +445,7 @@ def _deploy_clusters(client, cluster_hosts): def _get_installing_progress(client, cluster_hosts): """get intalling progress.""" - timeout = time.time() + flags.OPTIONS.deployment_timeout + timeout = time.time() + 60 * float(flags.OPTIONS.deployment_timeout) clusters_progress = {} hosts_progress = {} install_finished = False @@ -510,7 +508,7 @@ def _get_installing_progress(client, cluster_hosts): 'there are some clusters/hosts in installing.' 'sleep %s seconds and retry', flags.OPTIONS.progress_update_check_interval) - time.sleep(flags.OPTIONS.progress_update_check_interval) + time.sleep(float(flags.OPTIONS.progress_update_check_interval)) else: install_finished = True logging.info('all clusters/hosts are installed.') diff --git a/compass/apiclient/example.py b/compass/apiclient/example.py index e5f45bba..7463cad6 100755 --- a/compass/apiclient/example.py +++ b/compass/apiclient/example.py @@ -285,6 +285,8 @@ status, resp = client.get_dashboard_links(cluster_id) print 'get cluster %s dashboardlinks status: %s, resp: %s' % ( cluster_id, status, resp) dashboardlinks = resp['dashboardlinks'] +if not dashboardlinks.keys(): + raise Exception("Dashboard link is not found!") for x in dashboardlinks.keys(): if x in ("os-dashboard", "os-controller"): dashboardurl = dashboardlinks.get(x) diff --git a/install/prepare.sh b/install/prepare.sh index 56d890c6..c7e4df32 100755 --- a/install/prepare.sh +++ b/install/prepare.sh @@ -136,6 +136,7 @@ if [ "$tempest" == "true" ]; then git clean -x -f -d -q git checkout grizzly-eol fi + cd /tmp/tempest pip install -e . fi diff --git a/misc/ci/tempest_run.sh b/misc/ci/tempest_run.sh index 9fcda8ee..eaaa26b9 100755 --- a/misc/ci/tempest_run.sh +++ b/misc/ci/tempest_run.sh @@ -68,7 +68,7 @@ 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/. +sshpass -p 'root' scp -o UserKnownHostsFile=/dev/null -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}'` @@ -98,7 +98,7 @@ 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 +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 diff --git a/regtest/regtest.conf b/regtest/regtest.conf index dde79ba6..b13abbbc 100644 --- a/regtest/regtest.conf +++ b/regtest/regtest.conf @@ -10,9 +10,9 @@ export SWITCH_CREDENTIAL=${SWITCH_CREDENTIAL:-"version=${SWITCH_VERSION},communi export HOST_ROLES=${HOST_ROLES:-''} -export MANAGEMENT_IP_START=${MANAGEMENT_IP_START:-'172.16.1.1'} -export MANAGEMENT_IP_END=${MANAGEMENT_IP_END:-'172.16.1.254'} -export MANAGEMENT_NETMASK=${MANAGEMENT_NETMASK:-'255.255.0.0'} +export MANAGEMENT_IP_START=${MANAGEMENT_IP_START:-`echo $ipaddr |cut -d. -f'1 2 3'`.10} +export MANAGEMENT_IP_END=${MANAGEMENT_IP_END:-`echo $ipaddr |cut -d. -f'1 2 3'`.100} +export MANAGEMENT_NETMASK=${MANAGEMENT_NETMASK:-'255.255.255.0'} export MANAGEMENT_NIC=${MANAGEMENT_NIC:-'eth0'} export MANAGEMENT_PROMISC=${MANAGEMENT_PROMISC:-'0'} export TENANT_IP_START=${TENANT_IP_START:-'172.16.2.1'} @@ -30,10 +30,10 @@ export STORAGE_IP_END=${STORAGE_IP_END:-'172.16.4.254'} export STORAGE_NETMASK=${STORAGE_NETMASK:-'255.255.255.0'} export STORAGE_NIC=${STORAGE_NIC:-'eth3'} export STORAGE_PROMISC=${STORAGE_PROMISC:-'0'} -export NAMESERVERS=${NAMESERVERS:-'172.16.0.1'} -export NTP_SERVER=${NTP_SERVER:-'172.16.0.1'} -export GATEWAY=${GATEWAY:-'172.16.0.1'} -export PROXY=${PROXY:-"http://172.16.0.1:3128"} +export NAMESERVERS=${NAMESERVERS:-$ipaddr} +export NTP_SERVER=${NTP_SERVER:-$ipaddr} +export GATEWAY=${GATEWAY:-$ipaddr} +export PROXY=${PROXY:-http://$ipaddr:3128} export SEARCH_PATH=${SEARCH_PATH:-'ods.com'} export HA_VIP=${HA_VIP:-''} export NETWORKING=${NETWORKING:-"nameservers=$NAMESERVERS;search_path=$SEARCH_PATH;gateway=$GATEWAY;proxy=$PROXY;ntp_server=$NTP_SERVER;ha_vip=$HA_VIP;management_ip_start=$MANAGEMENT_IP_START;management_ip_end=$MANAGEMENT_IP_END;management_netmask=$MANAGEMENT_NETMASK;management_gateway=;management_nic=$MANAGEMENT_NIC;management_promisc=$MANAGEMENT_PROMISC;tenant_ip_start=$TENANT_IP_START;tenant_ip_end=$TENANT_IP_END;tenant_netmask=$TENANT_NETMASK;tenant_gateway=;tenant_nic=$TENANT_NIC;tenant_promisc=$TENANT_PROMISC;public_ip_start=$PUBLIC_IP_START;public_ip_end=$PUBLIC_IP_END;public_netmask=$PUBLIC_NETMASK;public_gateway=;public_nic=$PUBLIC_NIC;public_promisc=$PUBLIC_PROMISC;storage_ip_start=$STORAGE_IP_START;storage_ip_end=$STORAGE_IP_END;storage_netmask=$STORAGE_NETMASK;storage_gateway=;storage_nic=$STORAGE_NIC;storage_promisc=$STORAGE_PROMISC"} @@ -52,3 +52,4 @@ export CONSOLE_PASSWORD=${CONSOLE_PASSWORD:-console} export SECURITY=${SECURITY:-"server:${SERVER_USERNAME}=${SERVER_PASSWORD},service:${SERVICE_USERNAME}=${SERVICE_PASSWORD},console:${CONSOLE_USERNAME}=${CONSOLE_PASSWORD}"} export DASHBOARD_ROLE=${DASHBOARD_ROLE:-"os-controller"} +export DEPLOYMENT_TIMEOUT=${DEPLOYMENT_TIMEOUT:-"90"} diff --git a/regtest/regtest.sh b/regtest/regtest.sh index eb6adfae..59d28634 100755 --- a/regtest/regtest.sh +++ b/regtest/regtest.sh @@ -11,6 +11,27 @@ function mac_address() { echo "00:00:$(mac_address_part):$(mac_address_part):$(mac_address_part):$(mac_address_part)" } +function tear_down_machines() { + virtmachines=$(virsh list --name) + for virtmachine in $virtmachines; do + echo "destroy $virtmachine" + virsh destroy $virtmachine + if [[ "$?" != "0" ]]; then + echo "destroy instance $virtmachine failed" + exit 1 + fi + done + virtmachines=$(virsh list --all --name) + for virtmachine in $virtmachines; do + echo "undefine $virtmachine" + virsh undefine $virtmachine + if [[ "$?" != "0" ]]; then + echo "undefine instance $virtmachine failed" + exit 1 + fi + done +} + REGTEST_CONF=${REGTEST_CONF:-"regtest.conf"} REGTEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source ${REGTEST_DIR}/${REGTEST_CONF} @@ -25,24 +46,7 @@ echo "role list: ${roles_list[@]}" roles_offset=0 host_roles_list='' -virtmachines=$(virsh list --name) -for virtmachine in $virtmachines; do - echo "destroy $virtmachine" - virsh destroy $virtmachine - if [[ "$?" != "0" ]]; then - echo "destroy instance $virtmachine failed" - exit 1 - fi -done -virtmachines=$(virsh list --all --name) -for virtmachine in $virtmachines; do - echo "undefine $virtmachine" - virsh undefine $virtmachine - if [[ "$?" != "0" ]]; then - echo "undefine instance $virtmachine failed" - exit 1 - fi -done +tear_down_machines echo "setup $VIRT_NUM virt machines" for i in `seq $VIRT_NUM`; do @@ -71,7 +75,7 @@ for i in `seq $VIRT_NUM`; do --network=bridge:installation \ --name pxe${i} --ram=${VIRT_MEM} \ --disk /tmp/pxe${i}.raw,format=raw \ - --vcpus=${VIRT_CPU} \ + --vcpus=${VIRT_CPUS} \ --graphics vnc,listen=0.0.0.0 \ --noautoconsole \ --autostart \ @@ -125,8 +129,13 @@ echo "machines: $machines" echo "host roles: $host_roles_list" virsh list -ln -sf /var/log/cobbler/anamon cobbler_logs -ln -sf /var/log/compass compass_logs +# Avoid infinite relative symbolic links +if [[ ! -L cobbler_logs ]]; then + ln -s /var/log/cobbler/anamon cobbler_logs +fi +if [[ ! -L compass_logs ]]; then + ln -s /var/log/compass compass_logs +fi CLIENT_SCRIPT=/opt/compass/bin/client.py /opt/compass/bin/refresh.sh if [[ "$?" != "0" ]]; then @@ -134,8 +143,20 @@ if [[ "$?" != "0" ]]; then exit 1 fi -${CLIENT_SCRIPT} --logfile= --loglevel=info --logdir= --networking="${NETWORKING}" --partitions="${PARTITION}" --credentials="${SECURITY}" --host_roles="${host_roles_list}" --dashboard_role="${DASHBOARD_ROLE}" --switch_ips="${SWITCH_IPS}" --machines="${machines}" --switch_credential="${SWITCH_CREDENTIAL}" -if [[ "$?" != "0" ]]; then - echo "deploy cluster failed" +${CLIENT_SCRIPT} --logfile= --loglevel=info --logdir= --networking="${NETWORKING}" --partitions="${PARTITION}" --credentials="${SECURITY}" --host_roles="${host_roles_list}" --dashboard_role="${DASHBOARD_ROLE}" --switch_ips="${SWITCH_IPS}" --machines="${machines}" --switch_credential="${SWITCH_CREDENTIAL}" --deployment_timeout="${DEPLOYMENT_TIMEOUT}" +rc=$? +# Tear down machines after the test +if [[ $rc != 0 ]]; then + tear_down_machines + echo "deployment failed" exit 1 fi +if [[ $tempest == true ]]; then + ./tempest_run.sh + if [[ $? != 0 ]]; then + tear_down_machines + echo "tempest failed" + exit 1 + fi + tear_down_machines +fi diff --git a/regtest/regtest3.conf b/regtest/regtest3.conf index c9f9966e..ced120c1 100644 --- a/regtest/regtest3.conf +++ b/regtest/regtest3.conf @@ -4,7 +4,7 @@ export VIRT_CPUS=${VIRT_CPUS:-'4'} export VIRT_MEM=${VIRT_MEM:-'6144'} export VIRT_DISK=${VIRT_DISK:-'20G'} export HOST_ROLES=${HOST_ROLES:-'os-controller,os-image;os-ops-database,os-ops-messaging;os-network,os-block-storage-worker;os-ha;os-ha'} -export HA_VIP=${HA_VIP:-'172.16.1.253'} +export HA_VIP=${HA_VIP:-`echo $ipaddr |cut -d. -f'1 2 3'`.253} REGTEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source ${REGTEST_DIR}/regtest.conf diff --git a/regtest/regtest_dashboard.conf b/regtest/regtest_dashboard.conf new file mode 100644 index 00000000..bbc0c8d2 --- /dev/null +++ b/regtest/regtest_dashboard.conf @@ -0,0 +1,10 @@ +# Set test script variables +export VIRT_NUM=${VIRT_NUM:-'1'} +export VIRT_CPUS=${VIRT_CPUS:-'10'} +export VIRT_MEM=${VIRT_MEM:-'8192'} +export VIRT_DISK=${VIRT_DISK:-'20G'} +export HOST_ROLES=${HOST_ROLES:-'os-dashboard'} +export DASHBOARD_ROLE=${DASHBOARD_ROLE:-"os-dashboard"} +export DEPLOYMENT_TIMEOUT=${DEPLOYMENT_TIMEOUT:-'60'} +REGTEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source ${REGTEST_DIR}/regtest.conf