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:
Itamar Turner-Trauring 2021-04-16 11:21:28 -04:00 committed by GitHub
commit 19a3481e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

0
newsfragments/3626.minor Normal file
View File

View File

@ -92,7 +92,7 @@ class TestStreamingLogs(unittest.TestCase):
@inlineCallbacks
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(
@ -106,14 +106,18 @@ class TestStreamingLogs(unittest.TestCase):
proto.on("message", got_message)
@log_call(action_type=u"test:cli:some-exciting-action")
def do_a_thing():
def do_a_thing(arguments):
pass
do_a_thing()
do_a_thing(arguments=[u"hello", b"good-day", 123, {"a": 35}, [None]])
proto.transport.loseConnection()
yield proto.is_closed
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("succeeded", messages[1]["action_status"])

View File

@ -8,8 +8,6 @@ from __future__ import (
division,
)
import json
from autobahn.twisted.resource import WebSocketResource
from autobahn.twisted.websocket import (
WebSocketServerFactory,
@ -21,6 +19,8 @@ from twisted.web.resource import (
Resource,
)
from allmydata.util import jsonbytes as json
class TokenAuthenticatedWebSocketServerProtocol(WebSocketServerProtocol):
"""