summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/functest.rst20
-rw-r--r--testcases/config_functest.py57
-rw-r--r--testcases/functest.yaml10
-rw-r--r--testcases/vPing/CI/libraries/vPing.py154
4 files changed, 75 insertions, 166 deletions
diff --git a/docs/functest.rst b/docs/functest.rst
index 7db6f250d..5dd3c53eb 100644
--- a/docs/functest.rst
+++ b/docs/functest.rst
@@ -180,10 +180,11 @@ The goal of this test can be described as follow::
| +------------------>| Test |
| | VM2 pings VM1 | |
| | | |
- | | If ping: | |
- | | shutdown VM2, OK | |
- | | else (timeout) | |
- | | test KO | |
+ | | Check console log | |
+ | | If ping: | |
+ | | exit OK | |
+ | | else (timeout) | |
+ | | exit KO | |
| | | |
| | | |
+-------------+ +-------------+
@@ -227,18 +228,19 @@ This script will:
* Install Tempest
* Retrieve test scenarios
* Setup ODL environment
- * Create temporary neutron external network
* Create temporary neutron private network
* Create router to connect both
* Create Glance images
Useful links:
+
.. _`OpenRC`: http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html
.. _`Rally installation procedure`: https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
.. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.py
+
.. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/functest.yaml
@@ -276,12 +278,6 @@ Do not change the directories structure
* image_url: URL of the image to be downloaded
* image_disk_format: glance image disk format (raw, qcow2, ...)
- * neutron_public_net_name: name of the OpenStack external network. If not existing, it will be created
- * neutron_public_subnet_name: external network subnet to be created if not existing
- * neutron_public_subnet_cidr: range of the external subnet. IMPORTANT: this subnet range must be reachable from the jumpstart server
- * neutron_public_subnet_start: start IP
- * neutron_public_subnet_end: end IP
-
* neutron_private_net_name: name of an OpenStack private network. If not existing, it will be created
* neutron_private_subnet_name: private subnet network to be created if not existing
* neutron_private_subnet_cidr: range of the private subnet.
@@ -448,7 +444,7 @@ vPing
=====
The test can be executed with command::
- #python ~./.functest/vPing.py
+ #python ~./.functest/vPing.py -d
.. _automatictest:
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index 76020046e..4ff3f7d48 100644
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -72,12 +72,6 @@ BENCH_TESTS_DIR = HOME + functest_yaml.get("general").get("directories").get("di
VPING_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_vping")
ODL_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_odl")
-# NEUTRON Public Network parameters
-NEUTRON_PUBLIC_NET_NAME = functest_yaml.get("general").get("openstack").get("neutron_public_net_name")
-NEUTRON_PUBLIC_SUBNET_NAME = functest_yaml.get("general").get("openstack").get("neutron_public_subnet_name")
-NEUTRON_PUBLIC_SUBNET_CIDR = functest_yaml.get("general").get("openstack").get("neutron_public_subnet_cidr")
-NEUTRON_PUBLIC_SUBNET_START = functest_yaml.get("general").get("openstack").get("neutron_public_subnet_start")
-NEUTRON_PUBLIC_SUBNET_END = functest_yaml.get("general").get("openstack").get("neutron_public_subnet_end")
# NEUTRON Private Network parameters
NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general").get("openstack").get("neutron_private_net_name")
@@ -145,18 +139,6 @@ def config_functest_start():
neutron_client = client.Client(**credentials)
logger.info("Configuring Neutron...")
- logger.info("Checking if public network '%s' exists..." % NEUTRON_PUBLIC_NET_NAME)
- #Now: if exists we don't create it again (the clean command does not clean the neutron networks yet)
- if check_neutron_net(neutron_client, NEUTRON_PUBLIC_NET_NAME):
- logger.info("Public network '%s' found. No need to create another one." % NEUTRON_PUBLIC_NET_NAME)
- else:
- logger.info("Public network '%s' not found. Creating..." % NEUTRON_PUBLIC_NET_NAME)
- if not create_public_neutron_net(neutron_client):
- logger.error("There has been a problem while creating the Neutron network.")
- #config_functest_clean()
- exit(-1)
-
-
logger.info("Checking if private network '%s' exists..." % NEUTRON_PRIVATE_NET_NAME)
#Now: if exists we don't create it again (the clean command does not clean the neutron networks yet)
if check_neutron_net(neutron_client, NEUTRON_PRIVATE_NET_NAME):
@@ -213,7 +195,7 @@ def config_functest_check():
logger.debug("Checking Rally deployment...")
if not check_rally():
- logger.debug("Rally deployment NOT found.")
+ logger.debug(" Rally deployment NOT found.")
errors_all = True
logger.debug("...FAIL")
else:
@@ -221,25 +203,13 @@ def config_functest_check():
logger.debug("Checking Neutron...")
- errors = False
if not check_neutron_net(neutron_client, NEUTRON_PRIVATE_NET_NAME):
logger.debug(" Private network '%s' NOT found." % NEUTRON_PRIVATE_NET_NAME)
- errors = True
+ logger.debug("...FAIL")
errors_all = True
else:
logger.debug(" Private network '%s' found." % NEUTRON_PRIVATE_NET_NAME)
-
- if not check_neutron_net(neutron_client, NEUTRON_PUBLIC_NET_NAME):
- logger.debug(" Public network '%s' NOT found." % NEUTRON_PUBLIC_NET_NAME)
- errors = True
- errors_all = True
- else:
- logger.debug(" Public network '%s' found." % NEUTRON_PUBLIC_NET_NAME)
-
- if not errors:
logger.debug("...OK")
- else:
- logger.debug("...FAIL")
logger.debug("Checking Image...")
@@ -464,27 +434,7 @@ def download_tests():
return True
-def create_public_neutron_net(neutron):
- try:
- neutron.format = 'json'
- logger.debug('Creating Neutron network %s...' % NEUTRON_PUBLIC_NET_NAME)
- json_body = {'network': {'name': NEUTRON_PUBLIC_NET_NAME, 'admin_state_up': True, 'router:external': True}}
- netw = neutron.create_network(body=json_body)
- net_dict = netw['network']
- network_id = net_dict['id']
- logger.debug("Network '%s' created successfully" % network_id)
-
- logger.debug('Creating Subnet....')
- json_body = {'subnets': [{'cidr': NEUTRON_PUBLIC_SUBNET_CIDR,
- 'ip_version': 4, 'network_id': network_id}]}
- subnet = neutron.create_subnet(body=json_body)
- logger.debug("Subnet '%s' created successfully" % subnet)
- except:
- print "Error:", sys.exc_info()[0]
- return False
- logger.info("Public Neutron network created successfully.")
- return True
def create_private_neutron_net(neutron):
try:
@@ -519,11 +469,14 @@ def create_private_neutron_net(neutron):
response = neutron.create_port(body=json_body)
logger.debug("Port created successfully.")
+ """
+ #No need to set up a gateway if there is no public network
logger.debug('Setting up gateway...')
public_network_id = get_network_id(neutron,NEUTRON_PUBLIC_NET_NAME)
json_body = {'network_id': public_network_id, 'enable_snat' : True}
gateway = neutron.add_gateway_router(router_id,body=json_body)
logger.debug("Gateway '%s' added successfully" % gateway)
+ """
except:
print "Error:", sys.exc_info()[0]
return False
diff --git a/testcases/functest.yaml b/testcases/functest.yaml
index cee07fcad..6175e6fcb 100644
--- a/testcases/functest.yaml
+++ b/testcases/functest.yaml
@@ -10,12 +10,10 @@ general:
dir_odl: .functest/ODL/
dir_rally_inst: .rally/
openstack:
- image_name: Ubuntu14.04
- image_url: https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
- image_disk_format: raw
- #Public network. Will be created by config_functest.py
- #It must be reachable from where the tests are ran
- #For Fuel deployment, it exists already and its called net04_ext
+ image_name: functest-img
+ image_url: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
+ image_disk_format: qcow2
+ #Public network. Optional
neutron_public_net_name: net04_ext
neutron_public_subnet_name: net04_ext__subnet
neutron_public_subnet_cidr: 172.16.9.0/24
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index b579830e7..3836a1a4c 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -16,9 +16,6 @@
import os, time, subprocess, logging, argparse, yaml
import pprint
import novaclient.v2.client as novaclient
-import neutronclient.client as neutronclient
-#import novaclient.v1_1.client as novaclient
-import cinderclient.v1.client as cinderclient
pp = pprint.PrettyPrinter(indent=4)
EXIT_CODE = -1
@@ -114,42 +111,43 @@ def get_status(nova,vm):
def main():
creds = get_credentials("nova")
nova = novaclient.Client(**creds)
- cinder = cinderclient.Client(**creds)
- """
- # print images and server resources
- # print nova_images
- print_title("images list")
- pMsg(nova.images.list())
- print_title("servers list")
- pMsg(nova.servers.list())
- """
- # Check if the given image is created
- images=nova.images.list()
- image_found = False
- for image in images:
- if image.name == GLANCE_IMAGE_NAME:
- logger.info("Glance image found '%s'" %image.name)
- image_found = True
- if not image_found:
- logger.error("ERROR: Glance image %s not found." % GLANCE_IMAGE_NAME)
+ image = None
+ network = None
+ flavor = None
+
+ # Check if the given image exists
+ try:
+ image = nova.images.find(name = GLANCE_IMAGE_NAME)
+ logger.info("Glance image found '%s'" % GLANCE_IMAGE_NAME)
+ except:
+ logger.error("ERROR: Glance image '%s' not found." % GLANCE_IMAGE_NAME)
logger.info("Available images are: ")
pMsg(nova.images.list())
exit(-1)
- # Check if the given neutron network is created
- networks=nova.networks.list()
- network_found = False
- for net in networks:
- if net.human_id == NEUTRON_PRIVATE_NET_NAME:
- logger.info("Network found '%s'" %net.human_id)
- network_found = True
- if not network_found:
- logger.error("Neutron network %s not found." % NEUTRON_PRIVATE_NET_NAME)
+ # Check if the given neutron network exists
+ try:
+ network = nova.networks.find(label = NEUTRON_PRIVATE_NET_NAME)
+ logger.info("Network found '%s'" % NEUTRON_PRIVATE_NET_NAME)
+ except:
+ logger.error("Neutron network '%s' not found." % NEUTRON_PRIVATE_NET_NAME)
logger.info("Available networks are: ")
pMsg(nova.networks.list())
exit(-1)
+ # Check if the given flavor exists
+ try:
+ flavor = nova.flavors.find(name = FLAVOR)
+ logger.info("Flavor found '%s'" % FLAVOR)
+ except:
+ logger.error("Flavor '%s' not found." % FLAVOR)
+ logger.info("Available flavors are: ")
+ pMsg(nova.flavor.list())
+ exit(-1)
+
+
+ # Deleting instances if they exist
servers=nova.servers.list()
for server in servers:
if server.name == NAME_VM_1 or server.name == NAME_VM_2:
@@ -160,106 +158,67 @@ def main():
# boot VM 1
# basic boot
- # tune (e.g. flavor, images, network) to your specific openstack configuration here
- m = NAME_VM_1
- f = nova.flavors.find(name = FLAVOR)
- i = nova.images.find(name = GLANCE_IMAGE_NAME)
- n = nova.networks.find(label = NEUTRON_PRIVATE_NET_NAME)
- u = "#cloud-config\npassword: opnfv\nchpasswd: { expire: False }\nssh_pwauth: True"
- #k = "demo-key"
+ # tune (e.g. flavor, images, network) to your specific openstack configuration here
# create VM
- logger.info("Creating instance '%s'..." %m)
- logger.debug("Configuration:\n name=%s \n flavor=%s \n image=%s \n network=%s \n userdata= \n%s" %(m,f,i,n,u))
+ logger.info("Creating instance '%s'..." % NAME_VM_1)
+ logger.debug("Configuration:\n name=%s \n flavor=%s \n image=%s \n network=%s \n" %(NAME_VM_1,flavor,image,network))
vm1 = nova.servers.create(
- name = m,
- flavor = f,
- image = i,
- nics = [{"net-id": n.id}],
- #key_name = k,
- userdata = u,
+ name = NAME_VM_1,
+ flavor = flavor,
+ image = image,
+ nics = [{"net-id": network.id}]
)
- #pMsg(vm1)
-
#wait until VM status is active
waitVmActive(nova,vm1)
#retrieve IP of first VM
logger.debug("Fetching IP...")
- server = get_server(creds, m)
- #pMsg(server.networks)
+ server = get_server(creds, NAME_VM_1)
# theoretically there is only one IP address so we take the first element of the table
# Dangerous! To be improved!
test_ip = server.networks.get(NEUTRON_PRIVATE_NET_NAME)[0]
- logger.debug("Instance '%s' got %s" %(m,test_ip))
- test_cmd = '/tmp/vping.sh %s'%test_ip
-
+ logger.debug("Instance '%s' got %s" %(NAME_VM_1,test_ip))
# boot VM 2
# we will boot then execute a ping script with cloud-init
# the long chain corresponds to the ping procedure converted with base 64
- # tune (e.g. flavor, images, network) to your specific openstack configuration here
- m = NAME_VM_2
- f = nova.flavors.find(name = FLAVOR)
- i = nova.images.find(name = GLANCE_IMAGE_NAME)
- n = nova.networks.find(label = NEUTRON_PRIVATE_NET_NAME)
- # use base 64 format becaus bad surprises with sh script with cloud-init but script is just pinging
- #k = "demo-key"
- u = "#cloud-config\npassword: opnfv\nchpasswd: { expire: False }\nssh_pwauth: True\nwrite_files:\n- encoding: b64\n path: /tmp/vping.sh\n permissions: '0777'\n owner: root:root\n content: IyEvYmluL2Jhc2gKCndoaWxlIHRydWU7IGRvCiBwaW5nIC1jIDEgJDEgMj4mMSA+L2Rldi9udWxsCiBSRVM9JD8KIGlmIFsgIlokUkVTIiA9ICJaMCIgXSA7IHRoZW4KICBlY2hvICJ2UGluZyBPSyIKICBzbGVlcCAxMAogIHN1ZG8gc2h1dGRvd24gLWggbm93CiAgYnJlYWsKIGVsc2UKICBlY2hvICJ2UGluZyBLTyIKIGZpCiBzbGVlcCAxCmRvbmUK\nruncmd:\n - [ sh, -c, %s]"%test_cmd
+ # tune (e.g. flavor, images, network) to your specific openstack configuration here
+ u = "#!/bin/sh\n\nwhile true; do\n ping -c 1 %s 2>&1 >/dev/null\n RES=$?\n if [ \"Z$RES\" = \"Z0\" ] ; then\n echo 'vPing OK'\n break\n else\n echo 'vPing KO'\n fi\n sleep 1\ndone\n"%test_ip
+
# create VM
- logger.info("Creating instance '%s'..." %m)
- logger.debug("Configuration:\n name=%s \n flavor=%s \n image=%s \n network=%s \n userdata= \n%s" %(m,f,i,n,u))
+ logger.info("Creating instance '%s'..." % NAME_VM_2)
+ logger.debug("Configuration:\n name=%s \n flavor=%s \n image=%s \n network=%s \n userdata= \n%s" %(NAME_VM_2,flavor,image,network,u))
vm2 = nova.servers.create(
- name = m,
- flavor = f,
- image = i,
- nics = [{"net-id": n.id}],
- #key_name = k,
+ name = NAME_VM_2,
+ flavor = flavor,
+ image = image,
+ nics = [{"net-id": network.id}],
userdata = u,
- #security_groups = s,
- #config_drive = v.id
)
- # The injected script will shutdown the VM2 when the ping works
- # The console-log method is more consistent but doesn't work yet
waitVmActive(nova,vm2)
- logger.info("Waiting for ping, timeout is %d sec..." % PING_TIMEOUT)
- sec = 0
- while True:
- status = get_status(nova, vm2)
- #print status
- if status == "SHUTOFF" :
- EXIT_CODE = 0
- logger.info("vPing SUCCESSFUL after %d sec" % sec)
- break
- if sec == PING_TIMEOUT:
- logger.info("Timeout. vPing UNSUCCESSFUL.")
- break
- time.sleep(1)
- sec+=1
-
- """
- # I leave this here until we fix the console-log output
sec = 0
console_log = vm2.get_console_output()
- while not ("vPing" in console_log):
+ while True:
time.sleep(1)
console_log = vm2.get_console_output()
- print "--"+console_log
-
+ #print "--"+console_log
# report if the test is failed
- if "vPing" in console_log:
- pMsg("vPing is OK")
+ if "vPing OK" in console_log:
+ logger.info("vPing is OK")
+ EXIT_CODE = 0
break
else:
- pMsg("no vPing detected....")
+ logger.info("No vPing detected...")
sec+=1
if sec == PING_TIMEOUT:
+ logger.info("Timeout reached.")
break
- """
+
# delete both VMs
logger.debug("Deleting Instances...")
@@ -268,8 +227,11 @@ def main():
nova.servers.delete(vm2)
logger.debug("Instance %s terminated." % NAME_VM_2)
+ if EXIT_CODE == 0:
+ logger.info("vPing OK")
+ else:
+ logger.error("vPing FAILED")
- logger.debug("EXIT_CODE=%d" % EXIT_CODE)
exit(EXIT_CODE)