# # 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. import time import unittest import nova.virt.fake from nova.log import logging from nova.tests.integrated import integrated_helpers from nova.tests.integrated.api import client LOG = logging.getLogger(__name__) class ServersTest(integrated_helpers._IntegratedTestBase): def _wait_for_state_change(self, server, from_status): for i in xrange(0, 50): server = self.api.get_server(server['id']) if server['status'] != from_status: break time.sleep(.1) return server def _restart_compute_service(self, periodic_interval=None): """restart compute service. NOTE: fake driver forgets all instances.""" self.compute.kill()
# # 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 lxml import etree from nova.log import logging from nova.tests.integrated import integrated_helpers from nova.api.openstack import common from nova.api.openstack import xmlutil LOG = logging.getLogger(__name__) class XmlTests(integrated_helpers._IntegratedTestBase): """"Some basic XML sanity checks.""" def test_namespace_limits(self): headers = {} headers['Accept'] = 'application/xml' response = self.api.api_request('/limits', headers=headers) data = response.read() LOG.debug("data: %s" % data) root = etree.XML(data) self.assertEqual(root.nsmap.get(None), xmlutil.XMLNS_COMMON_V10)
""" Provides common functionality for integrated unit tests """ import random import string from nova import service from nova import test # For the flags import nova.image.glance from nova.log import logging from nova.tests.integrated.api import client LOG = logging.getLogger('nova.tests.integrated') def generate_random_alphanumeric(length): """Creates a random alphanumeric string of specified length.""" return ''.join(random.choice(string.ascii_uppercase + string.digits) for _x in range(length)) def generate_random_numeric(length): """Creates a random numeric string of specified length.""" return ''.join(random.choice(string.digits) for _x in range(length)) def generate_new_element(items, prefix, numeric=False):
# 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. import unittest import time from nova.log import logging from nova.tests.integrated import integrated_helpers from nova.tests.integrated.api import client from nova.volume import driver LOG = logging.getLogger("nova.tests.integrated") class VolumesTest(integrated_helpers._IntegratedTestBase): def setUp(self): super(VolumesTest, self).setUp() driver.LoggingVolumeDriver.clear_logs() def _get_flags(self): f = super(VolumesTest, self)._get_flags() f["use_local_volumes"] = False # Avoids calling local_path f["volume_driver"] = "nova.volume.driver.LoggingVolumeDriver" return f def test_get_volumes_summary(self): """Simple check that listing volumes works."""
# # 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. import time import unittest import nova.virt.fake from nova.log import logging from nova.tests.integrated import integrated_helpers from nova.tests.integrated.api import client LOG = logging.getLogger('nova.tests.integrated') class ServersTest(integrated_helpers._IntegratedTestBase): def _wait_for_state_change(self, server, status): for i in xrange(0, 50): server = self.api.get_server(server['id']) if server['status'] != status: break time.sleep(.1) return server def _restart_compute_service(self, periodic_interval=None): """restart compute service. NOTE: fake driver forgets all instances.""" self.compute.kill()