def test_multiple_servers(self): """Test multiple concurrent servers.""" pid2 = buffer_server.start(self.channels, self._next_buf_name()) n_records = 200 for count, data in enumerate(mock_data(n_records, self.channel_count)): if count % 2 == 0: buffer_server.append(self.pid, Record(data, count, None)) else: buffer_server.append(pid2, Record(data, count, None)) self.assertEqual(buffer_server.count(self.pid), n_records / 2) self.assertEqual(buffer_server.count(pid2), n_records / 2) server1_data = buffer_server.get_data(self.pid, 0, 5) server2_data = buffer_server.get_data(pid2, 0, 5) self.assertNotEqual(server1_data, server2_data) buffer_server.stop(pid2)
def test_multiple_servers(self): pid2 = buffer_server.start(self.channels, self._next_buf_name()) n = 200 for i in range(n): d = [ np.random.uniform(-1000, 1000) for cc in range(self.channel_count) ] if i % 2 == 0: buffer_server.append(self.pid, Record(d, i, None)) else: buffer_server.append(pid2, Record(d, i, None)) self.assertEqual(buffer_server.count(self.pid), n / 2) self.assertEqual(buffer_server.count(pid2), n / 2) server1_data = buffer_server.get_data(self.pid, 0, 5) server2_data = buffer_server.get_data(pid2, 0, 5) self.assertNotEqual(server1_data, server2_data) buffer_server.stop(pid2)
def cleanup(self): """Performs cleanup tasks, such as deleting the buffer archive. Note that data will be unavailable after calling this method.""" if self._buf: buffer_server.stop(self._buf, delete_archive=self.delete_archive) self._buf = None
def tearDown(self): """Run after each test.""" buffer_server.stop(self.pid) self.pid = None