def setUp(self): self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) # The test config.yaml references files in `xos-synchronizer-tests/` so make sure we're in the parent # directory of the test directory. os.chdir(os.path.join(test_path, "..")) import xossynchronizer.event_loop reload(xossynchronizer.event_loop) import xossynchronizer.backend reload(xossynchronizer.backend) from xossynchronizer.modelaccessor import model_accessor b = xossynchronizer.backend.Backend(model_accessor=model_accessor) steps_dir = Config.get("steps_dir") self.steps = b.load_sync_step_modules(steps_dir) self.synchronizer = xossynchronizer.event_loop.XOSObserver( self.steps, model_accessor)
def setUp(self): self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) # The test config.yaml references files in `xos-synchronizer-tests/` so make sure we're in the parent # directory of the test directory. os.chdir(os.path.join(test_path, "..")) import xossynchronizer.event_loop reload(xossynchronizer.event_loop) import xossynchronizer.backend reload(xossynchronizer.backend) from xossynchronizer.modelaccessor import model_accessor b = xossynchronizer.backend.Backend(model_accessor=model_accessor) steps_dir = Config.get("steps_dir") self.steps = b.load_sync_step_modules(steps_dir) self.synchronizer = xossynchronizer.event_loop.XOSObserver(self.steps, model_accessor)
def setUp(self): global XOSKafkaThread, Config, log self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) from xossynchronizer.modelaccessor import model_accessor # The test config.yaml references files in `xos-synchronizer-tests/` so make sure we're in the parent # directory of the test directory. os.chdir(os.path.join(test_path, "..")) from xossynchronizer.event_engine import XOSKafkaThread, XOSEventEngine self.event_steps_dir = Config.get("event_steps_dir") self.event_engine = XOSEventEngine(model_accessor=model_accessor, log=log)
def setUp(self): self.sys_path_save = sys.path # Setting up the config module from xosconfig import Config config = os.path.join(test_path, "test_config.yaml") Config.clear() Config.init(config, "synchronizer-config-schema.yaml") # END Setting up the config module from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) # FIXME this is to get jenkins to pass the tests, somehow it is running tests in a different order # and apparently it is not overriding the generated model accessor build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir, []) import xossynchronizer.modelaccessor # import all class names to globals for ( k, v, ) in (xossynchronizer.modelaccessor.model_accessor.all_model_classes. items()): globals()[k] = v self.log = Mock()
def setUp(self): self.sys_path_save = sys.path # Setting up the config module from xosconfig import Config config = os.path.join(test_path, "test_config.yaml") Config.clear() Config.init(config, "synchronizer-config-schema.yaml") # END Setting up the config module from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor # FIXME this is to get jenkins to pass the tests, somehow it is running tests in a different order # and apparently it is not overriding the generated model accessor build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir, []) import xossynchronizer.modelaccessor # import all class names to globals for ( k, v, ) in xossynchronizer.modelaccessor.model_accessor.all_model_classes.items(): globals()[k] = v self.log = Mock()
def setUp(self): self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) os.chdir(os.path.join(test_path, "..")) # config references xos-synchronizer-tests/model-deps import xossynchronizer.event_loop reload(xossynchronizer.event_loop) import xossynchronizer.backend reload(xossynchronizer.backend) from xossynchronizer.modelaccessor import model_accessor # import all class names to globals for (k, v) in model_accessor.all_model_classes.items(): globals()[k] = v b = xossynchronizer.backend.Backend(model_accessor=model_accessor) steps_dir = Config.get("steps_dir") self.steps = b.load_sync_step_modules(steps_dir) self.synchronizer = xossynchronizer.event_loop.XOSObserver(self.steps, model_accessor)
def setUp(self): self.sys_path_save = sys.path # Setting up the config module from xosconfig import Config config = os.path.join(test_path, "../test_config.yaml") Config.clear() Config.init(config, "synchronizer-config-schema.yaml") # END Setting up the config module from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor # Can't use mock_modelaccessor_config because we're not in the xos-services directory, so do it # the long way... xos_dir = os.path.join(test_path, "../../../../xos") services_dir = os.path.join(test_path, "../../../..") service_xprotos = [ os.path.join(test_path, "../models/testservice.xproto") ] build_mock_modelaccessor(None, xos_dir, services_dir, service_xprotos) # mock_modelaccessor_config(test_path, [("testservice", "testservice.xproto")]) import xossynchronizer.modelaccessor import mock_modelaccessor imp.reload( mock_modelaccessor) # in case nose2 loaded it in a previous test imp.reload(xossynchronizer.modelaccessor ) # in case nose2 loaded it in a previous test from model_policy_testservice_serviceinstance import TestserviceServiceInstancePolicy from xossynchronizer.modelaccessor import model_accessor self.model_accessor = model_accessor # import all class names to globals for (k, v) in model_accessor.all_model_classes.items(): globals()[k] = v # Some of the functions we call have side-effects, reset the world. model_accessor.reset_all_object_stores() self.policy = TestserviceServiceInstancePolicy(self.model_accessor) self.si = Mock(sync_after_policy=False, sync_during_policy=False, policy_after_sync=False, policy_during_sync=False, update_during_sync=False, update_during_policy=False, create_duplicate=False)
def setUp(self): self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = os.path.join(test_path, "test_config.yaml") from xosconfig import Config Config.clear() Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor build_mock_modelaccessor( sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[] ) os.chdir( os.path.join(test_path, "..") ) # config references xos-synchronizer-tests/model-deps import xossynchronizer.event_loop reload(xossynchronizer.event_loop) import xossynchronizer.backend reload(xossynchronizer.backend) from xossynchronizer.modelaccessor import model_accessor # import all class names to globals for (k, v) in model_accessor.all_model_classes.items(): globals()[k] = v from xossynchronizer.modelaccessor import model_accessor b = xossynchronizer.backend.Backend(model_accessor=model_accessor) steps_dir = Config.get("steps_dir") self.steps = b.load_sync_step_modules(steps_dir) self.synchronizer = xossynchronizer.event_loop.XOSObserver( self.steps, model_accessor ) try: os.remove("/tmp/sync_ports") except OSError: pass try: os.remove("/tmp/delete_ports") except OSError: pass
def setUp(self): self.sys_path_save = sys.path # Setting up the config module from xosconfig import Config config = os.path.join(test_path, "../test_config.yaml") Config.clear() Config.init(config, "synchronizer-config-schema.yaml") # END Setting up the config module from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor # Can't use mock_modelaccessor_config because we're not in the xos-services directory, so do it # the long way... xos_dir = os.path.join(test_path, "../../../../xos") services_dir = os.path.join(test_path, "../../../..") service_xprotos = [os.path.join(test_path, "../models/testservice.xproto")] build_mock_modelaccessor(None, xos_dir, services_dir, service_xprotos) import xossynchronizer.modelaccessor import mock_modelaccessor imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test from sync_testservice_serviceinstance import SyncTestserviceServiceInstance from xossynchronizer.modelaccessor import model_accessor self.model_accessor = model_accessor # import all class names to globals for (k, v) in model_accessor.all_model_classes.items(): globals()[k] = v self.sync_step = SyncTestserviceServiceInstance # TODO: Use modelaccessor instead # create a mock instance instance self.model = Mock(name="Example", some_integer=0, sync_after_policy=False, sync_during_policy=False, policy_after_sync=False, policy_during_sync=False, update_during_sync=False, update_during_policy=False, create_duplicate=False)
def setUp(self): self.sys_path_save = sys.path # Setting up the config module from xosconfig import Config config = os.path.join(test_path, "../test_config.yaml") Config.clear() Config.init(config, "synchronizer-config-schema.yaml") # END Setting up the config module from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor # Can't use mock_modelaccessor_config because we're not in the xos-services directory, so do it # the long way... xos_dir = os.path.join(test_path, "../../../../xos") services_dir = os.path.join(test_path, "../../../..") service_xprotos = [os.path.join(test_path, "../models/testservice.xproto")] build_mock_modelaccessor(None, xos_dir, services_dir, service_xprotos) # mock_modelaccessor_config(test_path, [("testservice", "testservice.xproto")]) import xossynchronizer.modelaccessor import mock_modelaccessor imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test from model_policy_testservice_serviceinstance import TestserviceServiceInstancePolicy from xossynchronizer.modelaccessor import model_accessor self.model_accessor = model_accessor # import all class names to globals for (k, v) in model_accessor.all_model_classes.items(): globals()[k] = v # Some of the functions we call have side-effects, reset the world. model_accessor.reset_all_object_stores() self.policy = TestserviceServiceInstancePolicy(self.model_accessor) self.si = Mock(sync_after_policy=False, sync_during_policy=False, policy_after_sync=False, policy_during_sync=False, update_during_sync=False, update_during_policy=False, create_duplicate=False)
def setUp(self): global TenantWithContainerPolicy, LeastLoadedNodeScheduler, MockObjectList self.sys_path_save = sys.path self.cwd_save = os.getcwd() config = basic_conf = os.path.abspath( os.path.dirname(os.path.realpath(__file__)) + "/test_config.yaml" ) Config.clear() # in case left unclean by a previous test case Config.init(config, "synchronizer-config-schema.yaml") from xossynchronizer.mock_modelaccessor_build import ( build_mock_modelaccessor, ) build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]) import xossynchronizer.model_policies.model_policy_tenantwithcontainer from xossynchronizer.model_policies.model_policy_tenantwithcontainer import ( TenantWithContainerPolicy, LeastLoadedNodeScheduler, ) from mock_modelaccessor import MockObjectList # import all class names to globals for ( k, v, ) in xossynchronizer.model_policies.model_policy_tenantwithcontainer.model_accessor.all_model_classes.items(): globals()[k] = v from xossynchronizer.modelaccessor import model_accessor self.policy = TenantWithContainerPolicy(model_accessor=model_accessor) self.user = User(email="*****@*****.**") self.tenant = TenantWithContainer(creator=self.user) self.flavor = Flavor(name="m1.small")