Adds basic fuzz testing for compute

* Added basic fuzz tests for some flavor, image, and server
  requests
* Added datasets to be used in fuzzing

Change-Id: Ie1398adad3afc29cedc7023c3de1c3eb8e1c57cc
This commit is contained in:
Daryl Walleck
2013-08-28 11:16:00 -05:00
parent 25d293d96d
commit f1e7cc1449
5 changed files with 172 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

View File

@@ -0,0 +1,31 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from cafe.drivers.unittest.decorators import (tags, data_driven_test,
DataDrivenFixture)
from cloudcafe.compute.common.exceptions import ItemNotFound
from cloudroast.compute.fixtures import (ComputeFixture,
FlavorIdNegativeDataList)
@DataDrivenFixture
class FuzzFlavorsAPI(ComputeFixture):
@data_driven_test(dataset_source=FlavorIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_get_flavor(self, flavor_id=None):
with self.assertRaises(ItemNotFound):
self.flavors_client.get_flavor_details(flavor_id)

View File

@@ -0,0 +1,44 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from cafe.drivers.unittest.decorators import (tags, data_driven_test,
DataDrivenFixture)
from cloudcafe.compute.common.exceptions import ItemNotFound
from cloudroast.compute.fixtures import (ComputeFixture,
ImageIdNegativeDataList,
ServerIdNegativeDataList)
@DataDrivenFixture
class FuzzImageAPI(ComputeFixture):
@data_driven_test(dataset_source=ImageIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_get_image(self, image_id=None):
with self.assertRaises(ItemNotFound):
self.images_client.get_image(image_id)
@data_driven_test(dataset_source=ImageIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_delete_image(self, image_id=None):
with self.assertRaises(ItemNotFound):
self.images_client.delete_image(image_id)
@data_driven_test(dataset_source=ServerIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_create_image(self, server_id=None):
with self.assertRaises(ItemNotFound):
self.servers_client.create_image(server_id, 'test')

View File

@@ -0,0 +1,53 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from cafe.drivers.unittest.decorators import (tags, data_driven_test,
DataDrivenFixture)
from cloudcafe.compute.common.exceptions import BadRequest, ItemNotFound
from cloudroast.compute.fixtures import (ComputeFixture,
FlavorIdNegativeDataList,
ImageIdNegativeDataList,
ServerIdNegativeDataList)
@DataDrivenFixture
class FuzzServersAPI(ComputeFixture):
@data_driven_test(dataset_source=ServerIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_get_server(self, server_id=None):
with self.assertRaises(ItemNotFound):
self.servers_client.get_server(server_id)
@data_driven_test(dataset_source=ServerIdNegativeDataList())
@tags(type='negative')
def ddtest_negative_delete_server(self, server_id=None):
with self.assertRaises(ItemNotFound):
self.servers_client.delete_server(server_id)
@data_driven_test(dataset_source=FlavorIdNegativeDataList())
@tags(type='negative', net='no')
def test_create_server_with_unknown_flavor(self, flavor_id):
with self.assertRaises(BadRequest):
self.servers_client.create_server(
'testserver', self.image_ref, flavor_id)
@data_driven_test(dataset_source=ImageIdNegativeDataList())
@tags(type='negative', net='no')
def test_create_server_with_unknown_image(self, image_id):
with self.assertRaises(BadRequest):
self.servers_client.create_server(
'testserver', image_id, self.flavor_ref)