Move negative action tests to right place
Negative tests of server should be written on test_servers_negative.py,
but some negative tests are written on positive tests file, then that
would mislead developers who add new negative tests.
This patch moves these negative tests to a right place.
Change-Id: If3ddb2a0a5d27a87d610c6d8e7783d400fd32606
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 5b46792..1e4f1ca 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -197,41 +197,6 @@
required time (%s s).' % (self.server_id, self.build_timeout)
raise exceptions.TimeoutException(message)
- @attr(type=['negative', 'gate'])
- def test_resize_server_using_nonexist_flavor(self):
- flavor_id = -1
- self.assertRaises(exceptions.BadRequest,
- self.client.resize, self.server_id, flavor_id)
-
- @attr(type=['negative', 'gate'])
- def test_resize_server_using_null_flavor(self):
- flavor_id = ""
- self.assertRaises(exceptions.BadRequest,
- self.client.resize, self.server_id, flavor_id)
-
- @attr(type=['negative', 'gate'])
- def test_reboot_nonexistent_server_soft(self):
- # Negative Test: The server reboot on non existent server should return
- # an error
- self.assertRaises(exceptions.NotFound, self.client.reboot, 999, 'SOFT')
-
- @attr(type=['negative', 'gate'])
- def test_rebuild_nonexistent_server(self):
- # Negative test: The server rebuild for a non existing server
- # should not be allowed
- meta = {'rebuild': 'server'}
- new_name = rand_name('server')
- file_contents = 'Test server rebuild.'
- personality = [{'path': '/etc/rebuild.txt',
- 'contents': base64.b64encode(file_contents)}]
- self.assertRaises(exceptions.NotFound,
- self.client.rebuild,
- 999, self.image_ref_alt,
- name=new_name,
- metadata=meta,
- personality=personality,
- adminPass='rebuild')
-
@attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
@@ -245,14 +210,6 @@
self.assertEqual(lines, 10)
self.wait_for(get_output)
- @attr(type=['negative', 'gate'])
- def test_get_console_output_invalid_server_id(self):
- # Negative test: Should not be able to get the console output
- # for an invalid server_id
- self.assertRaises(exceptions.NotFound,
- self.servers_client.get_console_output,
- '!@#$%^&*()', 10)
-
@skip_because(bug="1014683")
@attr(type='gate')
def test_get_console_output_server_id_in_reboot_status(self):
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index c896224..7062a3b 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import base64
import sys
import uuid
@@ -99,6 +100,26 @@
self.create_server, accessIPv6=IPv6)
@attr(type=['negative', 'gate'])
+ def test_resize_server_with_non_existent_flavor(self):
+ # Resize a server with non-existent flavor
+ nonexistent_flavor = str(uuid.uuid4())
+ self.assertRaises(exceptions.BadRequest, self.client.resize,
+ self.server_id, flavor_ref=nonexistent_flavor)
+
+ @attr(type=['negative', 'gate'])
+ def test_resize_server_with_null_flavor(self):
+ # Resize a server with null flavor
+ self.assertRaises(exceptions.BadRequest, self.client.resize,
+ self.server_id, flavor_ref="")
+
+ @attr(type=['negative', 'gate'])
+ def test_reboot_non_existent_server(self):
+ # Reboot a non existent server
+ nonexistent_server = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound, self.client.reboot,
+ nonexistent_server, 'SOFT')
+
+ @attr(type=['negative', 'gate'])
def test_reboot_deleted_server(self):
# Reboot a deleted server
self.client.delete_server(self.server_id)
@@ -126,6 +147,23 @@
self.server_id, self.image_ref_alt)
@attr(type=['negative', 'gate'])
+ def test_rebuild_non_existent_server(self):
+ # Rebuild a non existent server
+ nonexistent_server = str(uuid.uuid4())
+ meta = {'rebuild': 'server'}
+ new_name = rand_name('server')
+ file_contents = 'Test server rebuild.'
+ personality = [{'path': '/etc/rebuild.txt',
+ 'contents': base64.b64encode(file_contents)}]
+ self.assertRaises(exceptions.NotFound,
+ self.client.rebuild,
+ nonexistent_server,
+ self.image_ref_alt,
+ name=new_name, meta=meta,
+ personality=personality,
+ adminPass='rebuild')
+
+ @attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
if self.__class__._interface == "xml":
@@ -258,20 +296,23 @@
@attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
+ nonexistent_server = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
- str(uuid.uuid4()))
+ nonexistent_server)
@attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
+ nonexistent_server = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.pause_server,
- str(uuid.uuid4()))
+ nonexistent_server)
@attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
+ nonexistent_server = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
- str(uuid.uuid4()))
+ nonexistent_server)
@attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
@@ -283,8 +324,9 @@
@attr(type=['negative', 'gate'])
def test_suspend_non_existent_server(self):
# suspend a non existent server
+ nonexistent_server = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.suspend_server,
- str(uuid.uuid4()))
+ nonexistent_server)
@attr(type=['negative', 'gate'])
def test_suspend_server_invalid_state(self):
@@ -299,8 +341,9 @@
@attr(type=['negative', 'gate'])
def test_resume_non_existent_server(self):
# resume a non existent server
+ nonexistent_server = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.resume_server,
- str(uuid.uuid4()))
+ nonexistent_server)
@attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
@@ -309,6 +352,14 @@
self.client.resume_server,
self.server_id)
+ @attr(type=['negative', 'gate'])
+ def test_get_console_output_of_non_existent_server(self):
+ # get the console output for a non existent server
+ nonexistent_server = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_console_output,
+ nonexistent_server, 10)
+
class ServersNegativeTestXML(ServersNegativeTestJSON):
_interface = 'xml'