diff options
author | 2017-03-03 01:08:36 -0800 | |
---|---|---|
committer | 2017-03-03 01:08:36 -0800 | |
commit | eccb06d7f47dea1b2bfe7b94348b4a3a3ca0a510 (patch) | |
tree | a76c9c60a73f5ead698ba9fdfad279ae1dfcee69 | |
parent | 70aff432c893fc3ae1e04c08a1ba81082193a14a (diff) |
Various fixes so tests run on constrained envs, e.g. Devstack
JIRA: MODELS-23
vHello_3node blueprint.yaml:
Switch to pre-built image to speed up VDU activation.
Various updates to webserver setup procedure.
Fix docker setup.
Address line wrapping issues with blueprint user data.
vHello blueprint.yaml:
Switch to pre-built image to speed up VDU activation.
tacker-setup.sh
Correct nfv-orchestration endpoint setup.
vHello_3Node_Tacker.sh:
Copy script on setup and start steps.
Add create image models-xenial-server.
Increase timeout onwebserver response.
Wait for VDU1 to startup before testing all webservers.
vHello_Tacker.sh:
Copy script on setup and start steps.
Add create image models-xenial-server.
Increase timeout onwebserver response.
Wait for VDU1 to startup before testing all webservers.
Change-Id: I97c26248de45845afb30ada3bc284b4389be1b63
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
-rw-r--r-- | tests/blueprints/tosca-vnfd-3node-tacker/blueprint.yaml | 60 | ||||
-rw-r--r-- | tests/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml | 12 | ||||
-rw-r--r-- | tests/utils/tacker-setup.sh | 2 | ||||
-rw-r--r-- | tests/vHello_3Node_Tacker.sh | 50 | ||||
-rw-r--r-- | tests/vHello_Tacker.sh | 35 |
5 files changed, 100 insertions, 59 deletions
diff --git a/tests/blueprints/tosca-vnfd-3node-tacker/blueprint.yaml b/tests/blueprints/tosca-vnfd-3node-tacker/blueprint.yaml index 2210a28..b3063d2 100644 --- a/tests/blueprints/tosca-vnfd-3node-tacker/blueprint.yaml +++ b/tests/blueprints/tosca-vnfd-3node-tacker/blueprint.yaml @@ -9,10 +9,6 @@ topology_template: node_templates: VDU1: type: tosca.nodes.nfv.VDU.Tacker - artifacts: - VNFImage: - type: tosca.artifacts.Deployment.Image.VM - file: http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img capabilities: nfv_compute: properties: @@ -20,6 +16,7 @@ topology_template: mem_size: 1024 MB disk_size: 4 GB properties: + image: models-xenial-server availability_zone: nova mgmt_driver: noop config_drive: true @@ -34,15 +31,16 @@ topology_template: <pubkey> EOM sudo mount /dev/sr0 /mnt/ - mkdir ~/www - mkdir ~/www/html - cat > ~/www/Dockerfile <<EOM + mkdir /tmp/www + cd /tmp/www + mkdir html + cat >Dockerfile <<EOM FROM nginx COPY html /usr/share/nginx/html EOM host=$(hostname) id=$(cut -d ',' -f 3 /mnt/openstack/latest/meta_data.json) - cat << EOM | sudo tee index.html + cat <<EOM >html/index.html <!DOCTYPE html> <html> <head> @@ -64,16 +62,16 @@ topology_template: </div> </body></html> EOM - wget https://git.opnfv.org/models/plain/tests/blueprints/tosca-vnfd-3node-tacker/favicon.ico -O ~/www/html/favicon.ico + wget -O /tmp/www/html/favicon.ico https://git.opnfv.org/models/plain/tests/blueprints/tosca-vnfd-3node-tacker/favicon.ico sudo apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - sudo apt-key update - echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee -a /etc/apt/sources.list.d/docker.list - sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-$(lsb_release -cs) main" + echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" >~/dockerrepo + sudo tee -a /etc/apt/sources.list.d/docker.list ~/dockerrepo + sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-xenial main" sudo apt-get update sudo apt-get install -y docker-engine sudo docker pull nginx - cd ~/www sudo docker build -t vhello . sudo docker run --name vHello -d -p 80:80 vhello config: | @@ -103,10 +101,6 @@ topology_template: VDU2: type: tosca.nodes.nfv.VDU.Tacker - artifacts: - VNFImage: - type: tosca.artifacts.Deployment.Image.VM - file: http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img capabilities: nfv_compute: properties: @@ -114,6 +108,7 @@ topology_template: mem_size: 1024 MB disk_size: 4 GB properties: + image: models-xenial-server availability_zone: nova mgmt_driver: noop config_drive: true @@ -128,15 +123,16 @@ topology_template: <pubkey> EOM sudo mount /dev/sr0 /mnt/ - mkdir ~/www - mkdir ~/www/html - cat > ~/www/Dockerfile <<EOM + mkdir /tmp/www + cd /tmp/www + mkdir html + cat >Dockerfile <<EOM FROM nginx COPY html /usr/share/nginx/html EOM host=$(hostname) id=$(cut -d ',' -f 3 /mnt/openstack/latest/meta_data.json) - cat << EOM | sudo tee index.html + cat <<EOM >html/index.html <!DOCTYPE html> <html> <head> @@ -158,16 +154,16 @@ topology_template: </div> </body></html> EOM - wget https://git.opnfv.org/models/plain/tests/blueprints/tosca-vnfd-3node-tacker/favicon.ico -O ~/www/html/favicon.ico + wget -O /tmp/www/html/favicon.ico https://git.opnfv.org/models/plain/tests/blueprints/tosca-vnfd-3node-tacker/favicon.ico sudo apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - sudo apt-key update - echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee -a /etc/apt/sources.list.d/docker.list - sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-$(lsb_release -cs) main" + echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" >~/dockerrepo + sudo tee -a /etc/apt/sources.list.d/docker.list ~/dockerrepo + sudo add-apt-repository "deb https://apt.dockerproject.org/repo/ ubuntu-xenial main" sudo apt-get update sudo apt-get install -y docker-engine sudo docker pull nginx - cd ~/www sudo docker build -t vhello . sudo docker run --name vHello -d -p 80:80 vhello config: | @@ -197,10 +193,6 @@ topology_template: VDU3: type: tosca.nodes.nfv.VDU.Tacker - artifacts: - VNFImage: - type: tosca.artifacts.Deployment.Image.VM - file: http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img capabilities: nfv_compute: properties: @@ -208,6 +200,7 @@ topology_template: mem_size: 1024 MB disk_size: 4 GB properties: + image: models-xenial-server availability_zone: nova mgmt_driver: noop user_data_format: RAW @@ -220,11 +213,18 @@ topology_template: cat << EOM >/home/ubuntu/.ssh/authorized_keys <pubkey> EOM + cat << EOF >/tmp/setup.sh echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward sudo sysctl net.ipv4.ip_forward=1 - sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -m state --state NEW -m statistic --mode nth --every 2 --packet 0 -j DNAT --to-destination <vdu1_ip>:80 - sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -m state --state NEW -m statistic --mode nth --every 2 --packet 0 -j DNAT --to-destination <vdu2_ip>:80 + sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -m state \\ + --state NEW -m statistic --mode nth --every 2 --packet 0 \\ + -j DNAT --to-destination <vdu1_ip>:80 + sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -m state \\ + --state NEW -m statistic --mode nth --every 2 --packet 0 \\ + -j DNAT --to-destination <vdu2_ip>:80 sudo iptables -t nat -A POSTROUTING -j MASQUERADE + EOF + bash /tmp/setup.sh config: | param0: key1 param1: key2 diff --git a/tests/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml b/tests/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml index edd2042..96b923d 100644 --- a/tests/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml +++ b/tests/blueprints/tosca-vnfd-hello-world-tacker/blueprint.yaml @@ -9,10 +9,11 @@ topology_template: node_templates: VDU1: type: tosca.nodes.nfv.VDU.Tacker - artifacts: - VNFImage: - type: tosca.artifacts.Deployment.Image.VM - file: https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img +# commented out as this option seems to cause instance creation to timeout. These options will be covered in separate tests. +# artifacts: +# VNFImage: +# type: tosca.artifacts.Deployment.Image.VM +# file: http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img capabilities: nfv_compute: properties: @@ -20,8 +21,7 @@ topology_template: mem_size: 1024 MB disk_size: 4 GB properties: -# commented out to test the VNFImage attribute above. These options will be covered in separate tests. -# image: models-xenial-server + image: models-xenial-server availability_zone: nova mgmt_driver: noop config_drive: true diff --git a/tests/utils/tacker-setup.sh b/tests/utils/tacker-setup.sh index f5ac095..c05b18c 100644 --- a/tests/utils/tacker-setup.sh +++ b/tests/utils/tacker-setup.sh @@ -192,7 +192,7 @@ function setup () { openstack endpoint create --region $region \ --publicurl "http://$ip:9890/" \ --adminurl "http://$ip:9890/" \ - --internalurl "http://$ip:9890/" $sid + --internalurl "http://$ip:9890/" nfv-orchestration echo "$0: $(date) Clone Tacker" if [[ -d /opt/tacker/tacker ]]; then rm -rf /opt/tacker/tacker; fi diff --git a/tests/vHello_3Node_Tacker.sh b/tests/vHello_3Node_Tacker.sh index 08375b9..ece5bba 100644 --- a/tests/vHello_3Node_Tacker.sh +++ b/tests/vHello_3Node_Tacker.sh @@ -136,17 +136,24 @@ try () { setup () { trap 'fail' ERR - echo "$0: $(date) Setup temp test folder /opt/tacker and copy this script there" + + echo "$0: $(date) Setup shared test folder /opt/tacker" if [ -d /opt/tacker ]; then sudo rm -rf /opt/tacker; fi sudo mkdir -p /opt/tacker sudo chown $USER /opt/tacker chmod 777 /opt/tacker/ + + echo "$0: $(date) copy test script and openrc to /opt/tacker" cp $0 /opt/tacker/. cp $1 /opt/tacker/admin-openrc.sh source /opt/tacker/admin-openrc.sh chmod 755 /opt/tacker/*.sh + echo "$0: $(date) Create image models-xenial-server" + image_id=$(openstack image list | awk "/ models-xenial-server / { print \$2 }") + if [[ -z "$image_id" ]]; then glance --os-image-api-version 1 image-create --name models-xenial-server --disk-format qcow2 --location http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img --container-format bare; fi + echo "$0: $(date) tacker-setup part 1" bash utils/tacker-setup.sh init if [ $? -eq 1 ]; then fail; fi @@ -181,10 +188,10 @@ setup () { say_hello() { echo "$0: $(date) Testing $1" pass=false - count=6 + count=10 while [[ $count > 0 && $pass != true ]] do - sleep 10 + sleep 30 let count=$count-1 if [[ $(curl $1 | grep -c "Hello World") > 0 ]]; then echo "$0: $(date) Hello World found at $1" @@ -195,6 +202,9 @@ say_hello() { } copy_blueprint() { + echo "$0: $(date) copy test script to /opt/tacker" + cp $0 /opt/tacker/. + echo "$0: $(date) reset blueprints folder" if [[ -d /opt/tacker/blueprints/tosca-vnfd-3node-tacker ]]; then rm -rf /opt/tacker/blueprints/tosca-vnfd-3node-tacker @@ -207,7 +217,8 @@ copy_blueprint() { start() { - trap 'fail' ERR +# Disable trap for now, need to test to ensure premature fail does not occur +# trap 'fail' ERR echo "$0: $(date) setup OpenStack CLI environment" source /opt/tacker/admin-openrc.sh @@ -310,8 +321,18 @@ start() { vdu_url[2]="http://${vdu_ip[2]}" vdu_url[3]="http://${vdu_ip[2]}" - echo "$0: $(date) verify vHello server is running at each web server and via the LB" apt-get install -y curl + + count=0 + resp=$(curl http://${vdu_ip[1]}) + while [[ $count < 10 && "$resp" == "" ]]; do + echo "$0: $(date) waiting for web server at VDU1 to startup" + sleep 60 + let count=$count+1 + resp=$(curl http://${vdu_ip[1]}) + done + + echo "$0: $(date) verify vHello server is running at each web server and via the LB" say_hello http://${vdu_ip[1]} say_hello http://${vdu_ip[2]} say_hello http://${vdu_ip[3]} @@ -363,15 +384,16 @@ stop() { else echo "$0: $(date) No hello-3node VNFD found" fi - if [[ ! -z $(openstack image list|grep VNFImage|awk '{print $2}') ]]; then - iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id}; done - if [[ "$(openstack image list|grep VNFImage|awk '{print $2}')" == '' ]]; then - assert "models-tacker-vnfd-004 (artifacts deletion)" true - else - assert "models-tacker-vnfd-004 (artifacts deletion)" false - fi - else echo "$0: $(date) No VNFImage found" - fi +# This part will apply for tests that dynamically create the VDU base image +# if [[ ! -z $(openstack image list|grep VNFImage|awk '{print $2}') ]]; then +# iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id}; done +# if [[ "$(openstack image list|grep VNFImage|awk '{print $2}')" == '' ]]; then +# assert "models-tacker-vnfd-004 (artifacts deletion)" true +# else +# assert "models-tacker-vnfd-004 (artifacts deletion)" false +# fi +# else echo "$0: $(date) No VNFImage found" +# fi # Cleanup for workarounds fip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${fip[@]}; do neutron floatingip-delete ${id}; done diff --git a/tests/vHello_Tacker.sh b/tests/vHello_Tacker.sh index aee8442..f7a89d0 100644 --- a/tests/vHello_Tacker.sh +++ b/tests/vHello_Tacker.sh @@ -134,17 +134,25 @@ try () { } setup () { - echo "$0: $(date) Setup temp test folder /opt/tacker and copy this script there" + trap 'fail' ERR + + echo "$0: $(date) Setup shared test folder /opt/tacker" if [ -d /opt/tacker ]; then sudo rm -rf /opt/tacker; fi sudo mkdir -p /opt/tacker sudo chown $USER /opt/tacker chmod 777 /opt/tacker/ + + echo "$0: $(date) copy test script and openrc to /opt/tacker" cp $0 /opt/tacker/. cp $1 /opt/tacker/admin-openrc.sh source /opt/tacker/admin-openrc.sh chmod 755 /opt/tacker/*.sh + echo "$0: $(date) Create image models-xenial-server" + image_id=$(openstack image list | awk "/ models-xenial-server / { print \$2 }") + if [[ -z "$image_id" ]]; then glance --os-image-api-version 1 image-create --name models-xenial-server --disk-format qcow2 --location http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img --container-format bare; fi + echo "$0: $(date) tacker-setup part 1" bash utils/tacker-setup.sh init if [ $? -eq 1 ]; then fail; fi @@ -177,6 +185,9 @@ setup () { } copy_blueprint() { + echo "$0: $(date) copy test script to /opt/tacker" + cp $0 /opt/tacker/. + echo "$0: $(date) reset blueprints folder" if [[ -d /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker ]]; then rm -rf /opt/tacker/blueprints/tosca-vnfd-hello-world-tacker @@ -188,6 +199,9 @@ copy_blueprint() { } start() { +# Disable trap for now, need to test to ensure premature fail does not occur +# trap 'fail' ERR + echo "$0: $(date) setup OpenStack CLI environment" source /opt/tacker/admin-openrc.sh @@ -270,7 +284,7 @@ start() { SERVER_IP=$(openstack server show $SERVER_ID | awk "/ addresses / { print \$6 }") SERVER_URL="http://$SERVER_IP" - echo "$0: $(date) wait 30 seconds for vHello server to startup" + echo "$0: $(date) wait 30 seconds for vHello server to startup at $SERVER_URL" sleep 30 echo "$0: $(date) verify vHello server is running" @@ -297,6 +311,8 @@ start() { } stop() { + trap 'fail' ERR + echo "$0: $(date) setup OpenStack CLI environment" source /opt/tacker/admin-openrc.sh @@ -306,6 +322,7 @@ stop() { # It can take some time to delete a VNF - thus wait 2 minutes count=12 while [[ $count > 0 && "$(tacker vnf-list|grep hello-world-tacker|awk '{print $2}')" != '' ]]; do + echo "$0: $(date) waiting for hello-world-tacker VNF delete to complete" sleep 10 let count=$count-1 done @@ -318,6 +335,7 @@ stop() { # It can take some time to delete a VNFD - thus wait 2 minutes if [[ "$(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}')" != '' ]]; then + echo "$0: $(date) trying to delete the hello-world-tacker VNFD" try 12 10 "tacker vnfd-delete hello-world-tacker" if [[ "$(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}')" == '' ]]; then assert "models-tacker-005 (VNFD deletion)" true @@ -326,12 +344,13 @@ stop() { fi fi - iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id}; done - if [[ "$(openstack image list|grep VNFImage|awk '{print $2}')" == '' ]]; then - assert "models-tacker-vnfd-004 (artifacts deletion)" true - else - assert "models-tacker-vnfd-004 (artifacts deletion)" false - fi +# This part will apply for tests that dynamically create the VDU base image +# iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id}; done +# if [[ "$(openstack image list|grep VNFImage|awk '{print $2}')" == '' ]]; then +# assert "models-tacker-vnfd-004 (artifacts deletion)" true +# else +# assert "models-tacker-vnfd-004 (artifacts deletion)" false +# fi # Cleanup for workarounds fip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${fip[@]}; do neutron floatingip-delete ${id}; done |