示例#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, "{}")
    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, "{}")