예제 #1
0
파일: engine.py 프로젝트: shakhat/act
def run():
    utils.init_config_and_logging(config.ENGINE_OPTS)

    redis_connection = utils.make_redis_connection(host=cfg.CONF.redis_host,
                                                   port=cfg.CONF.redis_port)

    scenario = utils.read_yaml_file(
        cfg.CONF.scenario,
        alias_mapper=(lambda f: config.SCENARIOS + '%s.yaml' % f))

    with rq.Connection(redis_connection):
        LOG.info('Connected to Redis')
        core.process(scenario, cfg.CONF.interval)
예제 #2
0
파일: test_engine.py 프로젝트: shakhat/act
    def test_dependent_create_actions(self):
        # this scenario should create 1 network and 1 subnet
        scenario = {
            'play': [
                {
                    'duration': 1,
                    'concurrency': 1,
                    'filter': 'Init.*',
                },
                {
                    'duration': 2,
                    'concurrency': 1,
                    'filter': 'CreateNetwork|CreateSubnet',
                }
            ],
            'title': __name__
        }

        timeline = [
            {  # step 0
                'options': [a.InitNeutronTypes],
                'choice': a.InitNeutronTypes,
            },
            {  # step 1
                'options': [a.CreateNetwork],
                'choice': a.CreateNetwork,
            },
            {  # step 2
                'options': [a.CreateNetwork, a.CreateSubnet],
                'choice': a.CreateSubnet,
            },
        ]
        self.choice.setup(timeline)
        self.world.reset()

        core.process(scenario, 0)

        self.assertEqual(1, len(self.world.get_items('network')))
        self.assertEqual(1, len(self.world.get_items('subnet')))
        self.assertEqual(1, self.world.get_one_item('meta_network').use_count)
        self.assertEqual(1, self.world.get_one_item('meta_subnet').use_count)

        net = self.world.get_one_item('network')
        self.assertEqual(1, net.use_count)
예제 #3
0
파일: test_engine.py 프로젝트: shakhat/act
    def test_one_create_action(self):
        # this scenario should create 2 networks
        scenario = {
            'play': [
                {
                    'duration': 1,
                    'concurrency': 1,
                    'filter': 'Init.*',
                },
                {
                    'duration': 2,
                    'concurrency': 1,
                    'filter': 'CreateNetwork',
                }
            ],
            'title': __name__
        }

        timeline = [
            {  # step 0
                'options': [a.InitNeutronTypes],
                'choice': a.InitNeutronTypes,
            },
            {  # step 1
                'options': [a.CreateNetwork],
                'choice': a.CreateNetwork,
            },
            {  # step 2
                'options': [a.CreateNetwork],
                'choice': a.CreateNetwork,
            },
        ]
        self.choice.setup(timeline)
        self.world.reset()

        core.process(scenario, 0)

        nets = self.world.get_items('network')
        self.assertEqual(2, len(nets))

        meta_net = self.world.get_one_item('meta_network')
        self.assertEqual(2, meta_net.use_count)