Skip to content

Commit 339be0e

Browse files
wcharginbileschi
authored andcommitted
uploader: fix graph RPC test (#3507)
Summary: The graph uploader test wasn’t actually covering the blob writing code, and was set up incorrectly such that the request iterator would throw when forced. Test Plan: The new assertions pass, but fail if the RPC changes are reverted. wchargin-branch: uploader-graph-write-test
1 parent 57a547a commit 339be0e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tensorboard/uploader/uploader_test.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import print_function
2020

2121
import collections
22+
import itertools
2223
import os
2324

2425
import grpc
@@ -81,6 +82,12 @@ def _create_mock_client():
8182
experiment_id="123", url="should not be used!"
8283
)
8384
mock_client.CreateExperiment.return_value = fake_exp_response
85+
mock_client.GetOrCreateBlobSequence.side_effect = (
86+
write_service_pb2.GetOrCreateBlobSequenceResponse(
87+
blob_sequence_id="blob%d" % i
88+
)
89+
for i in itertools.count()
90+
)
8491
return mock_client
8592

8693

@@ -281,7 +288,6 @@ def test_start_uploading_graphs(self):
281288
graph_event = event_pb2.Event(
282289
graph_def=_create_example_graph_bytes(950)
283290
)
284-
285291
mock_logdir_loader = mock.create_autospec(logdir_loader.LogdirLoader)
286292
mock_logdir_loader.get_run_events.side_effect = [
287293
{
@@ -302,6 +308,13 @@ def test_start_uploading_graphs(self):
302308
uploader.start_uploading()
303309
self.assertEqual(1, mock_client.CreateExperiment.call_count)
304310
self.assertEqual(10, mock_client.WriteBlob.call_count)
311+
for (i, call) in enumerate(mock_client.WriteBlob.call_args_list):
312+
requests = list(call[0][0])
313+
data = b"".join(r.data for r in requests)
314+
self.assertEqual(data, graph_event.graph_def)
315+
self.assertEqual(
316+
set(r.blob_sequence_id for r in requests), {"blob%d" % i},
317+
)
305318
self.assertEqual(0, mock_rate_limiter.tick.call_count)
306319
self.assertEqual(10, mock_blob_rate_limiter.tick.call_count)
307320

0 commit comments

Comments
 (0)