Exemplo n.º 1
0
 def test_from_hex(self):
     cases = [('ffffffffffffffff', -1),
              ('c564d8606f4400', 55561450905617408), ('aa', 170)]
     for hex, expected_binary in cases:
         zid = ZipkinId.from_hex(hex)
         self.assertEqual(zid.get_binary(), expected_binary, hex)
         self.assertEqual(zid.get_hex(), hex.zfill(16))
Exemplo n.º 2
0
 def test_from_hex(self):
     cases = [
         ('ffffffffffffffff', -1),
         ('c564d8606f4400', 55561450905617408),
         ('aa', 170)
     ]
     for hex, expected_binary in cases:
         zid = ZipkinId.from_hex(hex)
         self.assertEqual(zid.get_binary(), expected_binary, hex)
         self.assertEqual(zid.get_hex(), hex.zfill(16))
Exemplo n.º 3
0
 def test_nonascii_input(self):
     timestamp, duration = Mock(), Mock()
     uri_in = u'\ufffd\ufffd/\x01'
     uri_out = uri_in.encode('utf-8')
     self.store.get.return_value = ZipkinData(trace_id=ZipkinId(42),
                                              span_id=ZipkinId(4242),
                                              parent_span_id=ZipkinId(1773),
                                              sampled=True)
     self.store.get_binary_annotations.return_value = [
         self.api._build_binary_annotation('http.uri', uri_in)
     ]
     self.store.get_annotations.return_value = [
         self.api._build_annotation(uri_in)
     ]
     self.store.get_rpc_name.return_value = 'test-rpc-name'
     self.assertEqual(
         self.api._build_span(timestamp, duration).annotations[0].value,
         uri_out)
     self.assertEqual(
         self.api._build_span(timestamp,
                              duration).binary_annotations[0].value,
         uri_out)
Exemplo n.º 4
0
 def test_integration(self):
     self.api.endpoint.ipv4 = 2130706433
     binary_annotations = [
         self.api._build_binary_annotation('awesome', True)
     ]
     annotations = [
         self.api._build_annotation('sr'),
         self.api._build_annotation('ss'),
     ]
     self.store.get_annotations.return_value = annotations
     self.store.get_binary_annotations.return_value = binary_annotations
     self.store.get.return_value = ZipkinData(trace_id=ZipkinId(42),
                                              span_id=ZipkinId(4242),
                                              parent_span_id=ZipkinId(1773),
                                              sampled=True)
     self.store.get_rpc_name.return_value = 'test-name'
     self.mock_time.time.return_value = 1024
     self.assertEqual(self.api.build_log_message(),
                      self.api.build_log_message())
     self.assertEqual(
         self.api.build_log_message(),
         '''CgABAAAAAAAAACoLAAMAAAAJdGVzdC1uYW1lCgAEAAAAAAAAEJIKAAUAAAAAAAAG7Q8AB'''
         '''gwAAAACCgABAAAAAAAAAAELAAIAAAACc3IMAAMIAAF/AAABAAAKAAEAAAAAAAAAAQsAAgAAAAJzcwwAAwgAAX8AAAEAAA8ACAwAAAABCwABAAAAB'''
         '''2F3ZXNvbWULAAIAAAABMQgAAwAAAAAMAAQIAAF/AAABAAACAAkAAA==''')
Exemplo n.º 5
0
 def test_raises_excepion_if_value_is_too_big(self):
     with self.assertRaises(ValueError):
         ZipkinId(2**63)
     with self.assertRaises(ValueError):
         ZipkinId(-(2**63))
Exemplo n.º 6
0
 def test_None_input(self):
     self.assertIsNone(ZipkinId.from_hex(None))
     self.assertIsNone(ZipkinId.from_binary(None))
Exemplo n.º 7
0
 def test_from_binary(self):
     val = 2 * 63 - 1
     self.assertEqual(ZipkinId.from_binary(val).get_binary(), val)
Exemplo n.º 8
0
 def test_getters(self):
     val = 42
     zid = ZipkinId(val)
     self.assertEqual(zid.get_binary(), val)
     self.assertEqual(zid.get_hex(), '000000000000002a')
Exemplo n.º 9
0
 def test_None_input(self):
     self.assertIsNone(ZipkinId.from_hex(None))
     self.assertIsNone(ZipkinId.from_binary(None))
Exemplo n.º 10
0
 def test_from_binary(self):
     val = 2 * 63 - 1
     self.assertEqual(ZipkinId.from_binary(val).get_binary(), val)
Exemplo n.º 11
0
 def test_getters(self):
     val = 42
     zid = ZipkinId(val)
     self.assertEqual(zid.get_binary(), val)
     self.assertEqual(zid.get_hex(), '000000000000002a')