summaryrefslogtreecommitdiffstats
path: root/testing/robot
diff options
context:
space:
mode:
authorJuraj Linkes <jlinkes@cisco.com>2016-08-11 14:08:57 +0200
committerJuraj Linkes <jlinkes@cisco.com>2016-08-11 14:08:57 +0200
commit6318a416890600c739208c228c2be8527aac61af (patch)
tree4f121566b23b095cf5f672bd0b770b09422c56b6 /testing/robot
parent6bbc3752ca506eb93db73cc89eced650bec52281 (diff)
added headers and added a non-working first draft of nodhcp ping test
Change-Id: I0c02184cc2b6f43cc8a8a6ede4ca3fcf3a2285d3 Signed-off-by: Juraj Linkes <jlinkes@cisco.com>
Diffstat (limited to 'testing/robot')
-rw-r--r--testing/robot/data/test_data.py13
-rw-r--r--testing/robot/lib/FDSLibrary.py49
-rw-r--r--testing/robot/smoke.robot46
3 files changed, 93 insertions, 15 deletions
diff --git a/testing/robot/data/test_data.py b/testing/robot/data/test_data.py
index cd3b170..d78ce4f 100644
--- a/testing/robot/data/test_data.py
+++ b/testing/robot/data/test_data.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2016 Juraj Linkes (Cisco) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
import uuid
run_uuid = str(uuid.uuid4())
@@ -12,3 +21,7 @@ port2_name = 'fds_smoke_port2_' + run_uuid
subnet_cidr = '192.168.10.0/24'
vm_flavor = 'm1.small'
vm_image = 'cirros-0.3.3'
+userdata1 = "#!/bin/sh\n\nsudo ip a add {}/24 dev eth0\n".format(vm1_address)
+userdata2 = "#!/bin/sh\n\nsudo ip a add {}/24 dev eth0\nwhile true; do\n ping -c 1 {} 2>&1 >/dev/null\n " \
+ "RES=$?\n if [ \"Z$RES\" = \"Z0\" ] ; then\n echo 'ping PASSED'\n break\n else\n echo " \
+ "'ping FAILED'\n fi\n sleep 1\ndone\n".format(vm2_address, vm1_address)
diff --git a/testing/robot/lib/FDSLibrary.py b/testing/robot/lib/FDSLibrary.py
index 2e29d6c..0cb43ee 100644
--- a/testing/robot/lib/FDSLibrary.py
+++ b/testing/robot/lib/FDSLibrary.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2016 Juraj Linkes (Cisco) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
from neutronclient.v2_0 import client as neutron
from novaclient import client as nova
from novaclient.exceptions import NotFound
@@ -19,6 +28,14 @@ class FDSLibrary():
os.getenv('OS_TENANT_NAME'),
os.getenv('OS_AUTH_URL'))
+ def check_flavor_exists(self, flavor):
+ flavor_list_names = [x.name for x in self.nova_client.flavors.list()]
+ return flavor in flavor_list_names
+
+ def check_image_exists(self, image):
+ image_list_names = [x.name for x in self.nova_client.images.list()]
+ return image in image_list_names
+
def create_network(self, name):
body = {'network': {'name': name}}
response = self.neutron_client.create_network(body=body)
@@ -52,16 +69,44 @@ class FDSLibrary():
response = self.neutron_client.create_port(body=body)
return response
- def create_server(self, name, image, flavor, port_ids, security_groups=None):
+ def create_server(self, name, image, flavor, port_ids, security_groups=None, userdata=None):
image = self.nova_client.images.find(name=image)
flavor = self.nova_client.flavors.find(name=flavor)
nics = [{'port-id': port_id} for port_id in port_ids]
response = self.nova_client.servers.create(name=name, image=image.id, flavor=flavor.id,
- security_groups=security_groups, nics=nics)
+ security_groups=security_groups, nics=nics,
+ userdata=userdata)
for key in dir(response):
print key, getattr(response, key)
return response
+ def format_string(self, string, substitute):
+ return string.format(substitute)
+
+ def check_server_console(self, vm_id, string):
+ vm_obj = self.nova_client.servers.get(vm_id)
+ timeout = 0
+ while timeout < 100:
+ console_out = vm_obj.get_console_output()
+ print "console output is: '{}'".format(console_out[-200:])
+ failed_to_read_metadata = 'failed to read iid from metadata'
+ if string in console_out:
+ return True
+ elif 'request failed' in console_out:
+ print 'retrying'
+ elif failed_to_read_metadata in console_out:
+ print failed_to_read_metadata
+ return False
+ timeout += 1
+ time.sleep(5)
+ return False
+
+ def create_security_group(self):
+ pass
+
+ def create_security_rule(self):
+ pass
+
def poll_server(self, vm_id, status, timeout=300):
try:
start = datetime.datetime.now()
diff --git a/testing/robot/smoke.robot b/testing/robot/smoke.robot
index 17b19bf..fddac5d 100644
--- a/testing/robot/smoke.robot
+++ b/testing/robot/smoke.robot
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2016 Juraj Linkes (Cisco) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
*** Settings ***
Library OperatingSystem
Library lib/FDSLibrary.py
@@ -24,27 +33,25 @@ Create port for VM2
Create VM1
${port_ids} = Create List ${port1_id}
- ${result} = Create vm ${vm1_name} ${port_ids}
+ ${result} = Create vm ${vm1_name} ${port_ids} userdata=${userdata1}
Set Suite Variable ${vm1_id} ${result}
-Create VM2
- ${port_ids} = Create List ${port2_id}
- ${result} = Create vm ${vm2_name} ${port_ids}
- Set Suite Variable ${vm2_id} ${result}
-
Wait for VM1 to be active
Should Be True $vm1_id is not $None
Poll vm ${vm1_id} active
+Create VM2
+ ${port_ids} = Create List ${port2_id}
+ ${result} = Create vm ${vm2_name} ${port_ids} userdata=${userdata2}
+ Set Suite Variable ${vm2_id} ${result}
+
Wait for VM2 to be active
Should Be True $vm2_id is not $None
Poll vm ${vm2_id} active
-Ping VM1
- Ping vm ${vm1_address}
-
-Ping VM2
- Ping vm ${vm2_address}
+Check VM2 userdata
+ ${result} = Check vm console ${vm2_id} PASSED
+ Should Be True ${result}
*** Keywords ***
Setup Suite
@@ -54,6 +61,12 @@ Setup Suite
Set Suite Variable ${port2_id} ${None}
Set Suite Variable ${vm1_id} ${None}
Set Suite Variable ${vm2_id} ${None}
+ ${result} = Check Flavor Exists ${vm_flavor}
+ Log ${vm_flavor}
+ Should be True ${result}
+ ${result} = Check Image Exists ${vm_image}
+ Log ${vm_image}
+ Should be True ${result}
Teardown Suite
Run Keyword If $vm1_id is not $None Delete vm ${vm1_id}
@@ -82,12 +95,19 @@ Create port with ip
[Return] ${response.port['id']}
Create vm
- [Arguments] ${vm_name} ${port_ids}
- ${response} = create server ${vm_name} ${vm_image} ${vm_flavor} ${port_ids}
+ [Arguments] ${vm_name} ${port_ids} ${security_groups}=${None} ${userdata}=${None}
+ Log Many ${vm_name} ${vm_image} ${vm_flavor} ${port_ids} ${userdata}
+ ${response} = create server ${vm_name} ${vm_image} ${vm_flavor} ${port_ids} ${security_groups}
+ ... ${userdata}
log many ${response}
log ${response.id}
[Return] ${response.id}
+Check vm console
+ [Arguments] ${vm_id} ${string}
+ ${response} = check server console ${vm_id} ${string}
+ [Return] ${response}
+
Poll vm
[Arguments] ${id} ${state}
poll server ${id} ${state}