Exemplo n.º 1
0
 def test_valid(self):
     config = {
         'container_path': '/nail/srv',
         'host_path': '/tmp',
         'mode': schema.VolumeModes.RO.value,
     }
     assert_equal(
         schema.ConfigVolume(**config),
         config_parse.valid_volume.validate(config, self.context),
     )
Exemplo n.º 2
0
    def test_valid_jobs_success(self):
        test_config = dict(jobs=[
            dict(name="test_job0",
                 node='node0',
                 schedule='daily',
                 expected_runtime="20m",
                 actions=[
                     dict(name="action",
                          command="command",
                          expected_runtime="20m"),
                     dict(
                         name="action_mesos",
                         command="command",
                         executor='mesos',
                         cpus=4,
                         mem=300,
                         disk=600,
                         constraints=[
                             dict(attribute='pool',
                                  operator='LIKE',
                                  value='default')
                         ],
                         docker_image='my_container:latest',
                         docker_parameters=[
                             dict(key='label', value='labelA'),
                             dict(key='label', value='labelB')
                         ],
                         env=dict(USER='******'),
                         extra_volumes=[
                             dict(container_path='/tmp',
                                  host_path='/home/tmp',
                                  mode='RO')
                         ],
                     ),
                     dict(
                         name="test_trigger_attrs",
                         command="foo",
                         triggered_by=["foo.bar"],
                         trigger_downstreams=True,
                     ),
                 ],
                 cleanup_action=dict(command="command"))
        ],
                           **BASE_CONFIG)

        expected_jobs = {
            'MASTER.test_job0':
            make_job(
                name='MASTER.test_job0',
                schedule=make_mock_schedule(),
                actions={
                    'action':
                    make_action(expected_runtime=datetime.timedelta(0,
                                                                    1200), ),
                    'action_mesos':
                    make_action(
                        name='action_mesos',
                        executor=schema.ExecutorTypes.mesos.value,
                        cpus=4.0,
                        mem=300.0,
                        disk=600.0,
                        constraints=(schema.ConfigConstraint(
                            attribute='pool',
                            operator='LIKE',
                            value='default',
                        ), ),
                        docker_image='my_container:latest',
                        docker_parameters=(
                            schema.ConfigParameter(
                                key='label',
                                value='labelA',
                            ),
                            schema.ConfigParameter(
                                key='label',
                                value='labelB',
                            ),
                        ),
                        env={'USER': '******'},
                        extra_volumes=(schema.ConfigVolume(
                            container_path='/tmp',
                            host_path='/home/tmp',
                            mode=schema.VolumeModes.RO.value,
                        ), ),
                        expected_runtime=datetime.timedelta(hours=24),
                    ),
                    'test_trigger_attrs':
                    make_action(
                        name="test_trigger_attrs",
                        command="foo",
                        triggered_by=("foo.bar", ),
                        trigger_downstreams=True,
                    ),
                },
                expected_runtime=datetime.timedelta(0, 1200),
            ),
        }

        context = config_utils.ConfigContext(
            'config',
            ['node0'],
            None,
            MASTER_NAMESPACE,
        )
        config_parse.validate_jobs(test_config, context)
        assert expected_jobs == test_config['jobs']