Пример #1
0
    def test_send_action(self, post, socket_post, uuid):
        invoke_rust_agent("mds1.local", "ls")

        if runningInDocker():
            post.assert_called_once_with(
                "http://127.0.0.1:8009",
                json={
                    "REMOTE": ("mds1.local", {
                        "action": "ls",
                        "args": {},
                        "type": "ACTION_START",
                        "id": "1-2-3-4"
                    })
                },
            )
        else:
            socket_post.assert_called_once_with(
                "http+unix://%2Fvar%2Frun%2Fiml-action-runner.sock/",
                json={
                    "REMOTE": ("mds1.local", {
                        "action": "ls",
                        "args": {},
                        "type": "ACTION_START",
                        "id": "1-2-3-4"
                    })
                },
            )
Пример #2
0
    def test_cancel(self, post, _):
        trigger = threading.Event()

        trigger.set()

        with self.assertRaises(RustAgentCancellation):
            invoke_rust_agent("mds1.local", "ls", {}, trigger)
Пример #3
0
    def test_error_raises(self, post, socket_post, uuid):
        if runningInDocker():
            post.side_effect = Exception("ruh-roh")
        else:
            socket_post.side_effect = Exception("ruh-roh")

        with self.assertRaises(Exception):
            invoke_rust_agent("mds1.local", "ls")
Пример #4
0
    def test_send_action(self, post, _):
        invoke_rust_agent("mds1.local", "ls")

        post.assert_called_once_with(
            "http+unix://%2Fvar%2Frun%2Fiml-action-runner.sock/",
            json={
                "REMOTE": ("mds1.local", {
                    "action": "ls",
                    "args": {},
                    "type": "ACTION_START",
                    "id": "1-2-3-4"
                })
            },
        )
Пример #5
0
    def test_get_data(self, post, socket_post, uuid):
        if runningInDocker():
            post.return_value.content = "{}"
        else:
            socket_post.return_value.content = "{}"

        r = invoke_rust_agent("mds1.local", "ls")

        self.assertEqual(r, "{}")
Пример #6
0
    def invoke_rust_agent(self, host, command, args={}):
        """
        Talks to the iml-action-runner service
        """

        from chroma_core.services.job_scheduler.agent_rpc import AgentException

        try:
            return invoke_rust_agent(host, command, args, self._cancel_event)
        except RustAgentCancellation as e:
            raise AgentException(
                host, command, args,
                "Cancelled: {}; command: {}; args: {}".format(
                    e, command, args))
        except Exception as e:
            raise AgentException(
                host, command, args,
                "Unexpected error: {}; command: {}; args: {}".format(
                    e, command, args))
Пример #7
0
    def invoke_rust_agent(self, host, command, args={}):
        """
        Talks to the iml-action-runner service
        """

        return invoke_rust_agent(host, command, args, self._cancel_event)
Пример #8
0
    def test_error_raises(self, post, _):
        post.side_effect = Exception("ruh-roh")

        with self.assertRaises(Exception):
            invoke_rust_agent("mds1.local", "ls")
Пример #9
0
    def test_get_data(self, post, _):
        post.return_value.content = "{}"

        r = invoke_rust_agent("mds1.local", "ls")

        self.assertEqual(r, "{}")