Merge "Correct getchildren() usage in list_addresses()"
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 955d97e..5f33e8b 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -182,13 +182,13 @@
server = Element("server")
doc.append(server)
- if name:
+ if name is not None:
server.add_attr("name", name)
- if accessIPv4:
+ if accessIPv4 is not None:
server.add_attr("accessIPv4", accessIPv4)
- if accessIPv6:
+ if accessIPv6 is not None:
server.add_attr("accessIPv6", accessIPv6)
- if meta:
+ if meta is not None:
metadata = Element("metadata")
server.append(metadata)
for k, v in meta:
@@ -228,10 +228,26 @@
flavorRef=flavor_ref,
name=name)
- for attr in ["adminPass", "accessIPv4", "accessIPv6", "key_name"]:
+ for attr in ["adminPass", "accessIPv4", "accessIPv6", "key_name",
+ "user_data", "availability_zone"]:
if attr in kwargs:
server.add_attr(attr, kwargs[attr])
+ if 'security_groups' in kwargs:
+ secgroups = Element("security_groups")
+ server.append(secgroups)
+ for secgroup in kwargs['security_groups']:
+ s = Element("security_group", name=secgroup['name'])
+ secgroups.append(s)
+
+ if 'networks' in kwargs:
+ networks = Element("networks")
+ server.append(networks)
+ for network in kwargs['networks']:
+ s = Element("network", uuid=network['uuid'],
+ fixed_ip=network['fixed_ip'])
+ networks.append(s)
+
if 'meta' in kwargs:
metadata = Element("metadata")
server.append(metadata)
diff --git a/tempest/tests/compute/security_groups/test_security_group_rules.py b/tempest/tests/compute/security_groups/test_security_group_rules.py
index 32ac52b..dc85f4b 100644
--- a/tempest/tests/compute/security_groups/test_security_group_rules.py
+++ b/tempest/tests/compute/security_groups/test_security_group_rules.py
@@ -37,18 +37,19 @@
#Creating a Security Group to add rules to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
securitygroup_id = securitygroup['id']
#Adding rules to the created Security Group
parent_group_id = securitygroup['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol, from_port,
- to_port)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port)
self.assertEqual(200, resp.status)
finally:
#Deleting the Security Group rule, created in this method
@@ -70,14 +71,14 @@
#Creating a Security Group to add rules to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
secgroup1 = securitygroup['id']
#Creating a Security Group so as to assign group_id to the rule
s_name2 = rand_name('securitygroup-')
s_description2 = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name2, s_description2)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name2, s_description2)
secgroup2 = securitygroup['id']
#Adding rules to the created Security Group with optional arguments
parent_group_id = secgroup1
@@ -86,12 +87,13 @@
to_port = 22
cidr = '10.2.3.124/24'
group_id = secgroup2
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port,
- cidr=cidr,
- group_id=group_id)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port,
+ cidr=cidr,
+ group_id=group_id)
rule_id = rule['id']
self.assertEqual(200, resp.status)
finally:
@@ -112,18 +114,19 @@
#Creating a Security Group to add rule to it
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
securitygroup_id = securitygroup['id']
#Adding rules to the created Security Group
parent_group_id = securitygroup['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, rule =\
- self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port, to_port)
+ resp, rule = \
+ self.client.create_security_group_rule(parent_group_id,
+ ip_protocol,
+ from_port,
+ to_port)
finally:
#Deleting the Security Group rule, created in this method
group_rule_id = rule['id']
@@ -203,6 +206,25 @@
parent_group_id, ip_protocol, from_port, to_port)
@attr(type='negative')
+ def test_security_group_rules_create_with_invalid_port_range(self):
+ # Negative test: Creation of Security Group rule should FAIL
+ # with invalid port range.
+ # Creating a Security Group to add rule to it.
+ s_name = rand_name('securitygroup-')
+ s_description = rand_name('description-')
+ resp, securitygroup = self.client.create_security_group(s_name,
+ s_description)
+ # Adding a rule to the created Security Group
+ secgroup_id = securitygroup['id']
+ ip_protocol = 'tcp'
+ from_port = 22
+ to_port = 21
+ self.addCleanup(self.client.delete_security_group, securitygroup['id'])
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group_rule,
+ secgroup_id, ip_protocol, from_port, to_port)
+
+ @attr(type='negative')
def test_security_group_rules_delete_with_invalid_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
# with invalid rule id
diff --git a/tempest/tests/compute/security_groups/test_security_groups.py b/tempest/tests/compute/security_groups/test_security_groups.py
index e5b0380..70a01a0 100644
--- a/tempest/tests/compute/security_groups/test_security_groups.py
+++ b/tempest/tests/compute/security_groups/test_security_groups.py
@@ -38,8 +38,8 @@
for i in range(3):
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
security_group_list.append(securitygroup)
#Fetch all Security Groups and verify the list
@@ -47,8 +47,8 @@
resp, fetched_list = self.client.list_security_groups()
self.assertEqual(200, resp.status)
#Now check if all the created Security Groups are in fetched list
- missing_sgs =\
- [sg for sg in security_group_list if sg not in fetched_list]
+ missing_sgs = \
+ [sg for sg in security_group_list if sg not in fetched_list]
self.assertFalse(missing_sgs,
"Failed to find Security Group %s in fetched "
"list" % ', '.join(m_group['name']
@@ -56,8 +56,8 @@
finally:
#Delete all the Security Groups created in this method
for securitygroup in security_group_list:
- resp, _ =\
- self.client.delete_security_group(securitygroup['id'])
+ resp, _ = \
+ self.client.delete_security_group(securitygroup['id'])
self.assertEqual(202, resp.status)
@attr(type='positive')
@@ -67,7 +67,7 @@
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
resp, securitygroup = \
- self.client.create_security_group(s_name, s_description)
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
self.assertTrue('id' in securitygroup)
securitygroup_id = securitygroup['id']
@@ -88,12 +88,12 @@
try:
s_name = rand_name('securitygroup-')
s_description = rand_name('description-')
- resp, securitygroup =\
- self.client.create_security_group(s_name, s_description)
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
self.assertEqual(200, resp.status)
#Now fetch the created Security Group by its 'id'
- resp, fetched_group =\
- self.client.get_security_group(securitygroup['id'])
+ resp, fetched_group = \
+ self.client.get_security_group(securitygroup['id'])
self.assertEqual(200, resp.status)
self.assertEqual(securitygroup, fetched_group,
"The fetched Security Group is different "
@@ -172,6 +172,20 @@
s_description)
@attr(type='negative')
+ def test_delete_the_default_security_group(self):
+ # Negative test:Deletion of the "default" Security Group should Fail
+ default_security_group_id = None
+ resp, body = self.client.list_security_groups()
+ for i in range(len(body)):
+ if body[i]['name'] == 'default':
+ default_security_group_id = body[i]['id']
+ break
+ #Deleting the "default" Security Group
+ self.assertRaises(exceptions.BadRequest,
+ self.client.delete_security_group,
+ default_security_group_id)
+
+ @attr(type='negative')
def test_delete_nonexistant_security_group(self):
# Negative test:Deletion of a nonexistant Security Group should Fail
security_group_id = []
diff --git a/tempest/tests/compute/servers/test_servers_negative.py b/tempest/tests/compute/servers/test_servers_negative.py
index 366b630..9013b36 100644
--- a/tempest/tests/compute/servers/test_servers_negative.py
+++ b/tempest/tests/compute/servers/test_servers_negative.py
@@ -29,7 +29,6 @@
@classmethod
def setUpClass(cls):
- raise cls.skipException("Until Bug 1046870 is fixed")
super(ServersNegativeTest, cls).setUpClass()
cls.client = cls.servers_client
cls.img_client = cls.images_client
@@ -115,6 +114,8 @@
@attr(type='negative')
def test_create_numeric_server_name(self):
# Create a server with a numeric name
+ if self.__class__._interface == "xml":
+ raise self.skipException("Not testable in XML")
server_name = 12345
self.assertRaises(exceptions.BadRequest,
@@ -182,7 +183,7 @@
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
new_name = server['id'] + '_new'
self.assertRaises(exceptions.NotFound,
self.alt_client.update_server, server['id'],
@@ -192,7 +193,7 @@
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
new_name = 'a' * 256
self.assertRaises(exceptions.BadRequest,
self.client.update_server,
@@ -210,7 +211,7 @@
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
try:
- server = self.create_server()
+ resp, server = self.create_server(wait_until='ACTIVE')
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
server['id'])
@@ -245,3 +246,7 @@
self.assertRaises(exceptions.NotFound, self.client.get_server,
'999erra43')
+
+
+class ServersNegativeTestXML(ServersNegativeTest):
+ _interface = 'xml'