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:
@@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from cafe.drivers.unittest.datasets import DatasetList
|
||||
from cafe.drivers.unittest.fixtures import BaseTestFixture
|
||||
|
||||
from cloudcafe.common.resources import ResourcePool
|
||||
from cloudcafe.compute.common.exceptions import TimeoutException, \
|
||||
BuildErrorException
|
||||
@@ -24,7 +24,7 @@ from cloudcafe.compute.common.types import NovaServerStatusTypes \
|
||||
|
||||
from cloudcafe.common.tools.datagen import rand_name
|
||||
from cloudcafe.compute.config import ComputeEndpointConfig, \
|
||||
ComputeAdminEndpointConfig, MarshallingConfig
|
||||
ComputeAdminEndpointConfig, MarshallingConfig, ComputeFuzzingConfig
|
||||
|
||||
from cloudcafe.compute.common.exception_handler import ExceptionHandler
|
||||
from cloudcafe.compute.extensions.vnc_console_api.client\
|
||||
@@ -291,3 +291,30 @@ class ComputeAdminFixture(ComputeFixture):
|
||||
super(ComputeAdminFixture, cls).tearDownClass()
|
||||
cls.flavors_client.delete_exception_handler(ExceptionHandler())
|
||||
cls.resources.release()
|
||||
|
||||
|
||||
class FlavorIdNegativeDataList(DatasetList):
|
||||
def __init__(self):
|
||||
super(FlavorIdNegativeDataList, self).__init__()
|
||||
fuzz_config = ComputeFuzzingConfig()
|
||||
with open(fuzz_config.input_fuzzing_file) as f:
|
||||
for line in f:
|
||||
self.append_new_dataset(line, {'flavor_id': line})
|
||||
|
||||
|
||||
class ImageIdNegativeDataList(DatasetList):
|
||||
def __init__(self):
|
||||
super(ImageIdNegativeDataList, self).__init__()
|
||||
fuzz_config = ComputeFuzzingConfig()
|
||||
with open(fuzz_config.input_fuzzing_file) as f:
|
||||
for line in f:
|
||||
self.append_new_dataset(line, {'image_id': line})
|
||||
|
||||
|
||||
class ServerIdNegativeDataList(DatasetList):
|
||||
def __init__(self):
|
||||
super(ServerIdNegativeDataList, self).__init__()
|
||||
fuzz_config = ComputeFuzzingConfig()
|
||||
with open(fuzz_config.input_fuzzing_file) as f:
|
||||
for line in f:
|
||||
self.append_new_dataset(line, {'server_id': line})
|
||||
|
||||
15
cloudroast/compute/fuzz/__init__.py
Normal file
15
cloudroast/compute/fuzz/__init__.py
Normal 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.
|
||||
"""
|
||||
31
cloudroast/compute/fuzz/flavors_fuzz.py
Normal file
31
cloudroast/compute/fuzz/flavors_fuzz.py
Normal 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)
|
||||
44
cloudroast/compute/fuzz/images_fuzz.py
Normal file
44
cloudroast/compute/fuzz/images_fuzz.py
Normal 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')
|
||||
53
cloudroast/compute/fuzz/servers_fuzz.py
Normal file
53
cloudroast/compute/fuzz/servers_fuzz.py
Normal 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)
|
||||
Reference in New Issue
Block a user