示例#1
0
 def setup_container(self):
     other_config = yaml.load(NamedConfigTestCase.config)
     self.config_mapping = {
         MASTER_NAMESPACE: valid_config(yaml.load(self.config)),
         'other': validate_fragment('other', other_config)
     }
     self.container = config_parse.ConfigContainer(self.config_mapping)
示例#2
0
 def test_attributes_with_master_context(self):
     expected = make_named_tron_config(
         jobs={
             'test_namespace.test_job':
             make_job(
                 name="test_namespace.test_job",
                 namespace="test_namespace",
                 schedule=make_mock_schedule(),
                 expected_runtime=datetime.timedelta(1),
             )
         })
     master_config = dict(
         nodes=[dict(
             name="node0",
             hostname="node0",
         )],
         node_pools=[dict(
             name="nodepool0",
             nodes=["node0"],
         )])
     test_config = validate_fragment(
         'test_namespace',
         dict(jobs=[
             dict(
                 name="test_job",
                 namespace='test_namespace',
                 node="node0",
                 schedule="daily 00:00:00",
                 actions=[dict(name="action", command="command")],
                 cleanup_action=dict(command="command"),
             )
         ]),
         master_config=master_config)
     assert_equal(test_config, expected)
示例#3
0
 def setup_container(self):
     other_config = TestNamedConfig.config
     self.config_mapping = {
         MASTER_NAMESPACE: valid_config(self.config),
         'other': validate_fragment('other', other_config),
     }
     self.container = config_parse.ConfigContainer(self.config_mapping)
示例#4
0
 def test_attributes(self):
     expected = make_named_tron_config(
         jobs={
             'test_job':
                 make_job(
                     name="test_job",
                     namespace='test_namespace',
                     schedule=ConfigIntervalScheduler(
                         timedelta=datetime.timedelta(0, 20),
                         jitter=None,
                     ),
                     expected_runtime=datetime.timedelta(1),
                 )
         }
     )
     test_config = validate_fragment(
         'test_namespace',
         dict(
             jobs=[
                 dict(
                     name="test_job",
                     namespace='test_namespace',
                     node="node0",
                     schedule="interval 20s",
                     actions=[dict(name="action", command="command")],
                     cleanup_action=dict(command="command"),
                 )
             ]
         )
     )
     assert_equal(test_config, expected)
示例#5
0
 def setup_container(self):
     other_config = TestNamedConfig.config
     self.config_mapping = {
         MASTER_NAMESPACE: valid_config(self.config),
         'other': validate_fragment('other', other_config),
     }
     self.container = config_parse.ConfigContainer(self.config_mapping)
示例#6
0
 def test_attributes(self):
     expected = make_named_tron_config(jobs=FrozenDict({
         'test_job':
         make_job(
             name="test_job",
             namespace='test_namespace',
             schedule=ConfigIntervalScheduler(
                 timedelta=datetime.timedelta(0, 20),
                 jitter=None,
             ),
             expected_runtime=datetime.timedelta(1),
         )
     }))
     test_config = validate_fragment(
         'test_namespace',
         dict(jobs=[
             dict(
                 name="test_job",
                 namespace='test_namespace',
                 node="node0",
                 schedule="interval 20s",
                 actions=[dict(name="action", command="command")],
                 cleanup_action=dict(command="command"),
             )
         ]))
     assert_equal(test_config, expected)
示例#7
0
 def test_attributes_with_master_context(self):
     expected = make_named_tron_config(
         jobs={
             'test_namespace.test_job':
                 make_job(
                     name="test_namespace.test_job",
                     namespace="test_namespace",
                     schedule=ConfigConstantScheduler(),
                     expected_runtime=datetime.timedelta(1),
                 )
         }
     )
     master_config = dict(
         nodes=[dict(
             name="node0",
             hostname="node0",
         )],
         node_pools=[dict(
             name="nodepool0",
             nodes=["node0"],
         )]
     )
     test_config = validate_fragment(
         'test_namespace',
         dict(
             jobs=[
                 dict(
                     name="test_job",
                     namespace='test_namespace',
                     node="node0",
                     schedule="constant",
                     actions=[dict(name="action", command="command")],
                     cleanup_action=dict(command="command"),
                 )
             ]
         ),
         master_config=master_config
     )
     assert_equal(test_config, expected)
示例#8
0
 def test_attributes(self):
     expected = make_named_tron_config(
         jobs={
             'test_job':
             make_job(
                 name="test_job",
                 namespace='test_namespace',
                 schedule=make_mock_schedule(),
                 expected_runtime=datetime.timedelta(1),
             )
         })
     test_config = validate_fragment(
         'test_namespace',
         dict(jobs=[
             dict(
                 name="test_job",
                 namespace='test_namespace',
                 node="node0",
                 schedule="daily 00:00:00 ",
                 actions=[dict(name="action", command="command")],
                 cleanup_action=dict(command="command"),
             )
         ]))
     assert_equal(test_config, expected)
示例#9
0
    def test_attributes(self):
        expected = schema.NamedTronConfig(
            jobs=FrozenDict({
                'test_job0': schema.ConfigJob(
                    name='test_job0',
                    namespace='test_namespace',
                    node='node0',
                    schedule=ConfigIntervalScheduler(
                        timedelta=datetime.timedelta(0, 20),
                        jitter=None,
                    ),
                    actions=FrozenDict({
                        'action0_0': schema.ConfigAction(
                            name='action0_0',
                            command='test_command0.0',
                            requires=(),
                            node=None)
                    }),
                    queueing=True,
                    run_limit=50,
                    all_nodes=False,
                    cleanup_action=schema.ConfigCleanupAction(
                        name='cleanup',
                        command='test_command0.1',
                        node=None),
                    enabled=True,
                    max_runtime=None,
                    allow_overlap=False),
                'test_job1': schema.ConfigJob(
                    name='test_job1',
                    namespace='test_namespace',
                    node='node0',
                    enabled=True,
                    schedule=schedule_parse.ConfigDailyScheduler(
                        days=set([1, 3, 5]),
                        hour=0,
                        minute=30,
                        second=0,
                        original="00:30:00 MWF",
                        jitter=None,
                    ),
                    actions=FrozenDict({
                        'action1_1': schema.ConfigAction(
                            name='action1_1',
                            command='test_command1.1',
                            requires=('action1_0',),
                            node=None),
                        'action1_0': schema.ConfigAction(
                            name='action1_0',
                            command='test_command1.0 %(some_var)s',
                            requires=(),
                            node=None)
                    }),
                    queueing=True,
                    run_limit=50,
                    all_nodes=False,
                    cleanup_action=None,
                    max_runtime=None,
                    allow_overlap=True),
                'test_job2': schema.ConfigJob(
                    name='test_job2',
                    namespace='test_namespace',
                    node='node1',
                    enabled=True,
                    schedule=schedule_parse.ConfigDailyScheduler(
                        days=set(),
                        hour=16,
                        minute=30,
                        second=0,
                        original="16:30:00 ",
                        jitter=None,
                    ),
                    actions=FrozenDict({
                        'action2_0': schema.ConfigAction(
                            name='action2_0',
                            command='test_command2.0',
                            requires=(),
                            node=None)
                    }),
                    queueing=True,
                    run_limit=50,
                    all_nodes=False,
                    cleanup_action=None,
                    max_runtime=None,
                    allow_overlap=False),
                'test_job3': schema.ConfigJob(
                    name='test_job3',
                    namespace='test_namespace',
                    node='node1',
                    schedule=ConfigConstantScheduler(),
                    enabled=True,
                    actions=FrozenDict({
                        'action3_1': schema.ConfigAction(
                            name='action3_1',
                            command='test_command3.1',
                            requires=(),
                            node=None),
                        'action3_0': schema.ConfigAction(
                            name='action3_0',
                            command='test_command3.0',
                            requires=(),
                            node=None),
                        'action3_2': schema.ConfigAction(
                            name='action3_2',
                            command='test_command3.2',
                            requires=('action3_0', 'action3_1'),
                            node='node0')
                    }),
                    queueing=True,
                    run_limit=50,
                    all_nodes=False,
                    cleanup_action=None,
                    max_runtime=None,
                    allow_overlap=False),
                'test_job4': schema.ConfigJob(
                    name='test_job4',
                    namespace='test_namespace',
                    node='NodePool',
                    schedule=schedule_parse.ConfigDailyScheduler(
                        days=set(),
                        hour=0, minute=0, second=0,
                        original="00:00:00 ",
                        jitter=None,
                    ),
                    actions=FrozenDict({
                        'action4_0': schema.ConfigAction(
                            name='action4_0',
                            command='test_command4.0',
                            requires=(),
                            node=None)}),
                    queueing=True,
                    run_limit=50,
                    all_nodes=True,
                    cleanup_action=None,
                    enabled=False,
                    max_runtime=None,
                    allow_overlap=False)
                }),
                services=FrozenDict({
                    'service0': schema.ConfigService(
                        namespace='test_namespace',
                        name='service0',
                        node='NodePool',
                        pid_file='/var/run/%(name)s-%(instance_number)s.pid',
                        command='service_command0',
                        monitor_interval=20,
                        monitor_retries=5,
                        restart_delay=None,
                        count=2)
                }
            )
        )

        test_config = validate_fragment('test_namespace', yaml.load(self.config))
        assert_equal(test_config.jobs['test_job0'], expected.jobs['test_job0'])
        assert_equal(test_config.jobs['test_job1'], expected.jobs['test_job1'])
        assert_equal(test_config.jobs['test_job2'], expected.jobs['test_job2'])
        assert_equal(test_config.jobs['test_job3'], expected.jobs['test_job3'])
        assert_equal(test_config.jobs['test_job4'], expected.jobs['test_job4'])
        assert_equal(test_config.jobs, expected.jobs)
        assert_equal(test_config.services, expected.services)
        assert_equal(test_config, expected)
        assert_equal(test_config.jobs['test_job4'].enabled, False)
示例#10
0
 def setup_container(self):
     other_config = yaml.load(NamedConfigTestCase.config)
     self.config_mapping = {
         MASTER_NAMESPACE: valid_config(yaml.load(self.config)),
         'other': validate_fragment('other', other_config)}
     self.container = config_parse.ConfigContainer(self.config_mapping)
示例#11
0
    def test_attributes(self):
        expected = schema.NamedTronConfig(
            jobs=FrozenDict(
                {
                    'test_job0':
                    schema.ConfigJob(name='test_job0',
                                     namespace='test_namespace',
                                     node='node0',
                                     schedule=ConfigIntervalScheduler(
                                         timedelta=datetime.timedelta(0, 20),
                                         jitter=None,
                                     ),
                                     actions=FrozenDict({
                                         'action0_0':
                                         schema.ConfigAction(
                                             name='action0_0',
                                             command='test_command0.0',
                                             requires=(),
                                             node=None)
                                     }),
                                     queueing=True,
                                     run_limit=50,
                                     all_nodes=False,
                                     cleanup_action=schema.ConfigCleanupAction(
                                         name='cleanup',
                                         command='test_command0.1',
                                         node=None),
                                     enabled=True,
                                     max_runtime=None,
                                     allow_overlap=False),
                    'test_job1':
                    schema.ConfigJob(
                        name='test_job1',
                        namespace='test_namespace',
                        node='node0',
                        enabled=True,
                        schedule=schedule_parse.ConfigDailyScheduler(
                            days=set([1, 3, 5]),
                            hour=0,
                            minute=30,
                            second=0,
                            original="00:30:00 MWF",
                            jitter=None,
                        ),
                        actions=FrozenDict(
                            {
                                'action1_1':
                                schema.ConfigAction(name='action1_1',
                                                    command='test_command1.1',
                                                    requires=('action1_0', ),
                                                    node=None),
                                'action1_0':
                                schema.ConfigAction(
                                    name='action1_0',
                                    command='test_command1.0 %(some_var)s',
                                    requires=(),
                                    node=None)
                            }),
                        queueing=True,
                        run_limit=50,
                        all_nodes=False,
                        cleanup_action=None,
                        max_runtime=None,
                        allow_overlap=True),
                    'test_job2':
                    schema.ConfigJob(
                        name='test_job2',
                        namespace='test_namespace',
                        node='node1',
                        enabled=True,
                        schedule=schedule_parse.ConfigDailyScheduler(
                            days=set(),
                            hour=16,
                            minute=30,
                            second=0,
                            original="16:30:00 ",
                            jitter=None,
                        ),
                        actions=FrozenDict(
                            {
                                'action2_0':
                                schema.ConfigAction(name='action2_0',
                                                    command='test_command2.0',
                                                    requires=(),
                                                    node=None)
                            }),
                        queueing=True,
                        run_limit=50,
                        all_nodes=False,
                        cleanup_action=None,
                        max_runtime=None,
                        allow_overlap=False),
                    'test_job3':
                    schema.ConfigJob(
                        name='test_job3',
                        namespace='test_namespace',
                        node='node1',
                        schedule=ConfigConstantScheduler(),
                        enabled=True,
                        actions=FrozenDict(
                            {
                                'action3_1':
                                schema.ConfigAction(name='action3_1',
                                                    command='test_command3.1',
                                                    requires=(),
                                                    node=None),
                                'action3_0':
                                schema.ConfigAction(name='action3_0',
                                                    command='test_command3.0',
                                                    requires=(),
                                                    node=None),
                                'action3_2':
                                schema.ConfigAction(name='action3_2',
                                                    command='test_command3.2',
                                                    requires=('action3_0',
                                                              'action3_1'),
                                                    node='node0')
                            }),
                        queueing=True,
                        run_limit=50,
                        all_nodes=False,
                        cleanup_action=None,
                        max_runtime=None,
                        allow_overlap=False),
                    'test_job4':
                    schema.ConfigJob(
                        name='test_job4',
                        namespace='test_namespace',
                        node='NodePool',
                        schedule=schedule_parse.ConfigDailyScheduler(
                            days=set(),
                            hour=0,
                            minute=0,
                            second=0,
                            original="00:00:00 ",
                            jitter=None,
                        ),
                        actions=FrozenDict({
                            'action4_0':
                            schema.ConfigAction(name='action4_0',
                                                command='test_command4.0',
                                                requires=(),
                                                node=None)
                        }),
                        queueing=True,
                        run_limit=50,
                        all_nodes=True,
                        cleanup_action=None,
                        enabled=False,
                        max_runtime=None,
                        allow_overlap=False)
                }),
            services=FrozenDict({
                'service0':
                schema.ConfigService(
                    namespace='test_namespace',
                    name='service0',
                    node='NodePool',
                    pid_file='/var/run/%(name)s-%(instance_number)s.pid',
                    command='service_command0',
                    monitor_interval=20,
                    monitor_retries=3,
                    restart_delay=None,
                    count=2)
            }))

        test_config = validate_fragment('test_namespace',
                                        yaml.load(self.config))
        assert_equal(test_config.jobs['test_job0'], expected.jobs['test_job0'])
        assert_equal(test_config.jobs['test_job1'], expected.jobs['test_job1'])
        assert_equal(test_config.jobs['test_job2'], expected.jobs['test_job2'])
        assert_equal(test_config.jobs['test_job3'], expected.jobs['test_job3'])
        assert_equal(test_config.jobs['test_job4'], expected.jobs['test_job4'])
        assert_equal(test_config.jobs, expected.jobs)
        assert_equal(test_config.services, expected.services)
        assert_equal(test_config, expected)
        assert_equal(test_config.jobs['test_job4'].enabled, False)