def test_create_volume_from_image(self): try: volume_created = \ self.volume.create_volume() except Exception as e: LOG.warning(_LW('Create volume before snapshot failed, ' 'msg: %(msg)s, traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) self.volume.delete_all() raise exceptions.VolumeBuildErrorException() try: kwargs = dict(force=True) snapshot = self.volume.create_snapshot(volume_created['id'], **kwargs) except Exception as e: LOG.warning(_LE('create volume snapshot failed, msg: ' '%(msg)s, traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) self.volume.delete_all() raise exceptions.SnapshotBuildErrorException() try: volume_created = self.volume.\ create_volume(snapshot_id=snapshot.get('id')) status = self.volume._get_volume_status(volume_created['id']) if status != "available": raise exceptions.VolumeBuildErrorException() except Exception as e: LOG.warning(_LW('Create volume from snapshot failed, ' 'msg: %(msg)s, traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) raise e finally: self.volume.delete_all()
def test_create_volume_snapshot(self): try: volume = Base() except Exception as e: LOG.warning(_LW('Init test env failed, msg: %(msg)s, ' 'traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) raise exceptions.InitFailed try: volume_created = \ volume.create_volume() except Exception as e: LOG.warning(_LW('Create volume before snapshot failed, ' 'msg: %(msg)s, traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) volume.delete_all() raise exceptions.VolumeBuildErrorException() try: kwargs = dict(force=True) volume.create_snapshot(volume_created['id'], **kwargs) except Exception as e: LOG.warning(_LE('create volume snapshot failed, msg: ' '%(msg)s, traceback: %(tb)s.'), {'msg': e, 'tb': traceback.format_exc()}) volume.delete_all() raise exceptions.SnapshotBuildErrorException() finally: volume.delete_all()
def live_migration_test(self): try: compute = Base() except Exception as err: LOG.error(_LE('init env failed for %s'), str(err)) raise exceptions.ServerFault try: instance = compute.create_server() compute.show_server(instance['id']) orig_host = compute.get_server_host(instance['id']) # when migrate, the status transfer from MIGRATING # TO ACTIVE # do not use block migration and no host is assigned self.manager.servers_client.live_migrate_server( instance['id'], None, False) compute._check_server_status_interval(instance['id'], 'ACTIVE', interval=10, timeout=60) # check the host attributes curr_host = compute.get_server_host(instance['id']) LOG.debug(('the origin host %(orig)s the current host' ' %(curr)s'), {'orig': orig_host, 'curr': curr_host}) if curr_host is not None and orig_host == curr_host: raise exceptions.ServerMigrateFailed() LOG.info(_LI('live migrate of %s successful'), instance['id']) except Exception as err: LOG.error(_LE('migrate server failed for %s'), str(err)) compute.delete_all() raise exceptions.ServerMigrateFailed() finally: compute.delete_all()
def run_all_tests(self, cycle=1): testcases = self.load_tests() run_times = cycle if cycle > 0 else self._LONG_RUN_TIMES if isinstance(run_times, basestring): run_times = int(run_times) path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) python_path = os.environ.get("PYTHONPATH") if not python_path: python_path = path else: python_path += ';' + path os.environ['PYTHONPATH'] = python_path while run_times > 0: total_cases_num = len(testcases) failed_cases_num = 0 failed_cases = [] for case in testcases: try: cmd = "python " + case LOG.info(_LI('TESTCASE begin to run: %s') % case) ret = os.system(cmd) if ret == 0: LOG.info(('TESTCASE run successfully: %s'), case) else: raise except Exception: LOG.error(_LE('TESTCASE failed: %s'), case) failed_cases.append(case) failed_cases_num += 1 LOG.info(_LI('RUN ALL CASES Total: %(total)s Fail: %(fail)s'), { 'total': total_cases_num, 'fail': failed_cases_num }) for case in failed_cases: LOG.info(_LI('RUN ALL CASES FAILED: %s'), case) run_times -= 1
def test_create_qos_type(self): try: volume = Base() except Exception as e: LOG.warning( _LW('Init test env failed, msg: %(msg)s, ' 'traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) raise exceptions.InitFailed try: qos_type_created = \ volume.create_test_qos_specs(**self.__disk_qos_low) except Exception as e: LOG.warning( _LW('Create qos type for volume tests failed, ' 'msg: %(msg)s, traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) volume.delete_all() raise try: volume.show_qos_type(qos_type_created['id']) except Exception as e: LOG.warning( _LE('show volume type failed, msg: ' '%(msg)s, traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) raise finally: volume.delete_all()
def test_rename_volume(self): try: volume = Base() except Exception as e: LOG.warning( _LW('Init test env failed, msg: %(msg)s, ' 'traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) raise exceptions.InitFailed try: volume_created = volume.create_volume() except Exception as e: LOG.warning( _LW('Create volume failed, ' 'msg: %(msg)s, traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) volume.delete_all() raise try: params = {'name': 'newname'} volume.update_volume(volume_created['id'], **params) except Exception as e: LOG.warning( _LE('Update volume name failed, msg: ' '%(msg)s, traceback: %(tb)s.'), { 'msg': e, 'tb': traceback.format_exc() }) raise finally: volume.delete_all()