mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 07:31:07 +00:00
Merge pull request #1042 from tahoe-lafs/3626.streaming-logs-with-bytes
Handle bytes in log messages streamed over websocket Fixes ticket:3626
This commit is contained in:
commit
19a3481e5f
0
newsfragments/3626.minor
Normal file
0
newsfragments/3626.minor
Normal file
@ -92,7 +92,7 @@ class TestStreamingLogs(unittest.TestCase):
|
|||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_one_log(self):
|
def test_one_log(self):
|
||||||
"""
|
"""
|
||||||
write a single Eliot log and see it streamed via websocket
|
Write a single Eliot log actin and see it streamed via websocket.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proto = yield self.agent.open(
|
proto = yield self.agent.open(
|
||||||
@ -106,14 +106,18 @@ class TestStreamingLogs(unittest.TestCase):
|
|||||||
proto.on("message", got_message)
|
proto.on("message", got_message)
|
||||||
|
|
||||||
@log_call(action_type=u"test:cli:some-exciting-action")
|
@log_call(action_type=u"test:cli:some-exciting-action")
|
||||||
def do_a_thing():
|
def do_a_thing(arguments):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
do_a_thing()
|
do_a_thing(arguments=[u"hello", b"good-day", 123, {"a": 35}, [None]])
|
||||||
|
|
||||||
proto.transport.loseConnection()
|
proto.transport.loseConnection()
|
||||||
yield proto.is_closed
|
yield proto.is_closed
|
||||||
|
|
||||||
self.assertEqual(len(messages), 2)
|
self.assertEqual(len(messages), 2)
|
||||||
|
self.assertEqual(messages[0]["action_type"], "test:cli:some-exciting-action")
|
||||||
|
self.assertEqual(messages[0]["arguments"],
|
||||||
|
["hello", "good-day", 123, {"a": 35}, [None]])
|
||||||
|
self.assertEqual(messages[1]["action_type"], "test:cli:some-exciting-action")
|
||||||
self.assertEqual("started", messages[0]["action_status"])
|
self.assertEqual("started", messages[0]["action_status"])
|
||||||
self.assertEqual("succeeded", messages[1]["action_status"])
|
self.assertEqual("succeeded", messages[1]["action_status"])
|
||||||
|
@ -8,8 +8,6 @@ from __future__ import (
|
|||||||
division,
|
division,
|
||||||
)
|
)
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from autobahn.twisted.resource import WebSocketResource
|
from autobahn.twisted.resource import WebSocketResource
|
||||||
from autobahn.twisted.websocket import (
|
from autobahn.twisted.websocket import (
|
||||||
WebSocketServerFactory,
|
WebSocketServerFactory,
|
||||||
@ -21,6 +19,8 @@ from twisted.web.resource import (
|
|||||||
Resource,
|
Resource,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from allmydata.util import jsonbytes as json
|
||||||
|
|
||||||
|
|
||||||
class TokenAuthenticatedWebSocketServerProtocol(WebSocketServerProtocol):
|
class TokenAuthenticatedWebSocketServerProtocol(WebSocketServerProtocol):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user