def test_bad_body_datastore_create_instance(self): tests_utils.skip_if_xml() datastore = "*" datastore_version = "*" try: self.dbaas.instances.create("test_instance", 3, {"size": 2}, datastore=datastore, datastore_version=datastore_version) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal(httpCode, 400, "Create instance failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.compat.xml.TroveXmlClient): assert_equal(e.message, "Validation error: instance['datastore']['type']" " u'%s' does not match '^.*[0-9a-zA-Z]+.*$'; " "instance['datastore']['version'] u'%s' does not" " match '^.*[0-9a-zA-Z]+.*$'" % (datastore, datastore_version))
def test_bad_body_flavorid_create_instance(self): tests_utils.skip_if_xml() flavorId = ["?"] try: self.dbaas.instances.create("test_instance", flavorId, 2) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal( httpCode, 400, "Create instance failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.xml.TroveXmlClient): flavorId = [u'?'] assert_equal( e.message, "Validation error: " "instance['flavorRef'] %s is not valid under any " "of the given schemas; " "%s is not of type 'string'; " "%s is not of type 'string'; " "%s is not of type 'integer'; " "instance['volume'] 2 is not of type 'object'" % (flavorId, flavorId, flavorId, flavorId))
def test_bad_body_flavorid_create_instance(self): tests_utils.skip_if_xml() flavorId = ["?"] try: self.dbaas.instances.create("test_instance", flavorId, 2) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal(httpCode, 400, "Create instance failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.compat.xml.TroveXmlClient): flavorId = [u'?'] assert_equal(e.message, "Validation error: " "instance['flavorRef'] %s is not valid under any " "of the given schemas; " "%s is not of type 'string'; " "%s is not of type 'string'; " "%s is not of type 'integer'; " "instance['volume'] 2 is not of type 'object'" % (flavorId, flavorId, flavorId, flavorId))
def test_update_hosts(self): # FIXME: (rmyers) Update hosts is broken in xml skip_if_xml() ids = self._get_ids() assert_not_equal(ids, [], "No active instances found") before_versions = {} for _id in ids: diagnostics = self.client.diagnostics.get(_id) before_versions[_id] = diagnostics.version hosts = self.client.hosts.index() for host in hosts: self.client.hosts.update_all(host.name) after_versions = {} for _id in ids: diagnostics = self.client.diagnostics.get(_id) after_versions[_id] = diagnostics.version assert_not_equal(before_versions, {}, "No versions found before update") assert_not_equal(after_versions, {}, "No versions found after update") if CONFIG.fake_mode: for _id in after_versions: assert_not_equal(before_versions[_id], after_versions[_id])
def test_bad_body_datastore_create_instance(self): tests_utils.skip_if_xml() datastore = "*" datastore_version = "*" try: self.dbaas.instances.create("test_instance", 3, {"size": 2}, datastore=datastore, datastore_version=datastore_version) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal( httpCode, 400, "Create instance failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.compat.xml.TroveXmlClient): assert_equal( e.message, "Validation error: instance['datastore']['type']" " u'%s' does not match '^.*[0-9a-zA-Z]+.*$'; " "instance['datastore']['version'] u'%s' does not" " match '^.*[0-9a-zA-Z]+.*$'" % (datastore, datastore_version))
def test_bad_database_data(self): tests_utils.skip_if_xml() _bad_db_data = "{foo}" try: self.dbaas.databases.create(self.instance.id, _bad_db_data) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal(httpCode, 400, "Create database failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.xml.TroveXmlClient): _bad_db_data = "u'{foo}'" assert_equal(e.message, "Validation error: %s is not of type 'array'" % _bad_db_data)
def test_bad_database_data(self): tests_utils.skip_if_xml() _bad_db_data = "{foo}" try: self.dbaas.databases.create(self.instance.id, _bad_db_data) except Exception as e: resp, body = self.dbaas.client.last_response httpCode = resp.status assert_equal( httpCode, 400, "Create database failed with code %s, exception %s" % (httpCode, e)) if not isinstance(self.dbaas.client, troveclient.xml.TroveXmlClient): _bad_db_data = "u'{foo}'" assert_equal( e.message, "Validation error: " "databases %s is not of type 'array'" % _bad_db_data)