Beispiel #1
0
    def test_valid_unnamed_update(self):
        test_config = (
            BASE_CONFIG
            + """
jobs:
    -
        name: "test_job0"
        node: node0
        schedule: "interval 20s"
        actions:
            -
                name: "action0_0"
                command: "test_command0.0"
        cleanup_action:
            command: "test_command0.1"
services:
    -
        name: "test_service0"
        node: node0
        command: "service_command0"
        count: 2
        pid_file: "/var/run/%(name)s-%(instance_number)s.pid"
        monitor_interval: 20
        """
        )
        expected_result = (
            "MASTER",
            {
                "config_name": "MASTER",
                "jobs": [
                    {
                        "node": "node0",
                        "schedule": "interval 20s",
                        "name": "test_job0",
                        "actions": [{"command": "test_command0.0", "name": "action0_0"}],
                        "cleanup_action": {"command": "test_command0.1"},
                    }
                ],
                "node_pools": [{"nodes": ["node0", "node1"], "name": "NodePool"}],
                "ssh_options": {"identities": ["tests/test_id_rsa"], "agent": True},
                "services": [
                    {
                        "node": "node0",
                        "count": 2,
                        "command": "service_command0",
                        "name": "test_service0",
                        "monitor_interval": 20,
                        "pid_file": "/var/run/%(name)s-%(instance_number)s.pid",
                    }
                ],
                "nodes": [{"hostname": "node0", "name": "node0"}, {"hostname": "node1", "name": "node1"}],
            },
        )
        assert_equal(expected_result, _initialize_namespaced_update(test_config))
Beispiel #2
0
    def test_valid_named_update(self):
        test_config = """
config_name: test_config
jobs:
    -
        name: "test_job0"
        node: node0
        schedule: "interval 20s"
        actions:
            -
                name: "action0_0"
                command: "test_command0.0"
        cleanup_action:
            command: "test_command0.1"
services:
    -
        name: "test_service0"
        node: node0
        command: "service_command0"
        count: 2
        pid_file: "/var/run/%(name)s-%(instance_number)s.pid"
        monitor_interval: 20
        """
        expected_result = (
            "test_config",
            {
                "services": [
                    {
                        "node": "node0",
                        "count": 2,
                        "command": "service_command0",
                        "name": "test_service0",
                        "monitor_interval": 20,
                        "pid_file": "/var/run/%(name)s-%(instance_number)s.pid",
                    }
                ],
                "config_name": "test_config",
                "jobs": [
                    {
                        "node": "node0",
                        "schedule": "interval 20s",
                        "name": "test_job0",
                        "actions": [{"command": "test_command0.0", "name": "action0_0"}],
                        "cleanup_action": {"command": "test_command0.1"},
                    }
                ],
            },
        )
        assert_equal(expected_result, _initialize_namespaced_update(test_config))