Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Fix invoke_rust_agent test in CI
Browse files Browse the repository at this point in the history
Signed-off-by: johnsonw <wjohnson@whamcloud.com>
  • Loading branch information
johnsonw committed Nov 30, 2020
1 parent 7ca6372 commit ffab735
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions tests/unit/chroma_core/lib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,43 @@
@mock.patch("chroma_core.lib.util.requests_unixsocket.post")
@mock.patch("chroma_core.lib.util.requests.post")
class TestInvokeRustAgent(TestCase):
def test_send_action(self, post, a, b):
def test_send_action(self, post, socket_post, uuid):
invoke_rust_agent("mds1.local", "ls")

if runningInDocker():
call = "http://127.0.0.1:8009"
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:
call = "http+unix://%2Fvar%2Frun%2Fiml-action-runner.sock/"
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"})},
)

post.assert_called_once_with(
call,
json={"REMOTE": ("mds1.local", {"action": "ls", "args": {}, "type": "ACTION_START", "id": "1-2-3-4"})},
)

def test_get_data(self, post, a, b):
post.return_value.content = "{}"
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 test_cancel(self, post, a, b):
def test_cancel(self, post, socket_post, uuid):
trigger = threading.Event()

trigger.set()

with self.assertRaises(RustAgentCancellation):
invoke_rust_agent("mds1.local", "ls", {}, trigger)

def test_error_raises(self, post, a, b):
post.side_effect = Exception("ruh-roh")
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")

0 comments on commit ffab735

Please sign in to comment.