コード例 #1
0
 async def testPinnedCpus(self, sched_setaffinity_mock,
                          sched_getaffinity_mock, *_):
     runner_cls = latency_runner.EndToEndLatencyRunner
     try:
         self._SetupWorkerMocks(1_000_000_000, 1_500_000_000, 2_000_000_000)
         self.publisher_mock.CPUS_REQUIRED = 1
         self.receiver_mock.CPUS_REQUIRED = 1
         runner_cls.on_startup()
         sched_getaffinity_mock.assert_called_once_with(0)
         main_pinned_cpus = runner_cls.MAIN_PINNED_CPUS
         publisher_pinned_cpus = runner_cls.PUBLISHER_PINNED_CPUS
         receiver_pinned_cpus = runner_cls.RECEIVER_PINNED_CPUS
         self.assertTrue(main_pinned_cpus, 'non-empty and non-none')
         self.assertTrue(publisher_pinned_cpus, 'non-empty and non-none')
         self.assertTrue(receiver_pinned_cpus, 'non-empty and non-none')
         self.assertLess(main_pinned_cpus, {1, 2, 3, 4, 5, 6})
         self.assertLess(publisher_pinned_cpus, {1, 2, 3, 4, 5, 6})
         self.assertLess(receiver_pinned_cpus, {1, 2, 3, 4, 5, 6})
         self.assertLen(
             main_pinned_cpus | publisher_pinned_cpus
             | receiver_pinned_cpus,
             len(main_pinned_cpus) + len(publisher_pinned_cpus) +
             len(receiver_pinned_cpus), 'test for disjointness')
         sched_setaffinity_mock.assert_called_once_with(0, main_pinned_cpus)
         runner = latency_runner.EndToEndLatencyRunner(mock.Mock())
         await runner._async_run_phase(1, 42)
         self.publisher_mock.assert_called_once_with(publisher_pinned_cpus)
         self.receiver_mock.assert_called_once_with(receiver_pinned_cpus)
     finally:
         runner_cls.MAIN_PINNED_CPUS = None
         runner_cls.PUBLISHER_PINNED_CPUS = None
         runner_cls.RECEIVER_PINNED_CPUS = None
コード例 #2
0
 async def testPinnedCpusNotEnoughCpus(self, sched_setaffinity_mock,
                                       sched_getaffinity_mock, *_):
     self._SetupWorkerMocks(1_000_000_000, 1_500_000_000, 2_000_000_000)
     self.publisher_mock.CPUS_REQUIRED = 1
     self.receiver_mock.CPUS_REQUIRED = 1
     runner_cls = latency_runner.EndToEndLatencyRunner
     runner_cls.on_startup()
     sched_getaffinity_mock.assert_called_once_with(0)
     self.assertIsNone(runner_cls.MAIN_PINNED_CPUS)
     self.assertIsNone(runner_cls.PUBLISHER_PINNED_CPUS)
     self.assertIsNone(runner_cls.RECEIVER_PINNED_CPUS)
     sched_setaffinity_mock.assert_not_called()
     runner = latency_runner.EndToEndLatencyRunner(mock.Mock())
     await runner._async_run_phase(1, 42)
     self.publisher_mock.assert_called_once_with(None)
     self.receiver_mock.assert_called_once_with(None)
コード例 #3
0
 async def testAsyncRunPhase(self, print_mock):
     self._SetupWorkerMocks(1_000_000_000, 1_500_000_000, 2_000_000_000)
     runner = latency_runner.EndToEndLatencyRunner(mock.Mock())
     metrics = await runner._async_run_phase(1, 42)
     print_mock.assert_called_once_with(json.dumps(metrics))
     self.assertEqual(metrics, AGGREGATE_E2E_METRICS)
コード例 #4
0
 def testRunPhase(self, asyncio_run_mock):
     runner = latency_runner.EndToEndLatencyRunner(mock.Mock())
     runner.run_phase(13, 14)
     asyncio_run_mock.assert_called_once()
     self.mock_coro.assert_called_once_with(13, 14)