def couchbase_backend_setup(self): self.rest_client = RestClient(self.host, port=self.rest_port) for bucket in self.rest_client.get_all_buckets(): logging.info("Deleting bucket %s" % bucket) assert self.rest_client.delete_bucket(bucket) logging.info("Creating default bucket") assert self.rest_client.create_default_bucket() Stats.wait_for_warmup(self.host, self.port) self.upr_client = UprClient(self.host, self.port) self.mcd_client = McdClient(self.host, self.port)
def test_delete(self): op = self.mcd_client.set('key1', 'value', 0, 0, 0) resp = op.next_response() assert resp['status'] == SUCCESS op = self.mcd_client.delete('key1', 0) resp = op.next_response() assert resp['status'] == SUCCESS assert Stats.wait_for_stat(self.mcd_client, 'curr_items', 0)
def test_start_stop_persistence(self): op = self.mcd_client.stop_persistence() resp = op.next_response() assert resp['status'] == SUCCESS op = self.mcd_client.set('key', 'value', 0, 0, 0) resp = op.next_response() assert resp['status'] == SUCCESS time.sleep(2) op = self.mcd_client.stats() resp = op.next_response() assert resp['status'] == SUCCESS assert resp['value']['ep_flusher_state'] == 'paused' op = self.mcd_client.start_persistence() resp = op.next_response() assert resp['status'] == SUCCESS Stats.wait_for_persistence(self.mcd_client)
def test_stream_request_disk_and_memory_read(self): for i in range(15000): op = self.mcd_client.set('key' + str(i), 'value', 0, 0, 0) resp = op.next_response() assert resp['status'] == SUCCESS op = self.mcd_client.stats('vbucket-seqno') resp = op.next_response() assert resp['status'] == SUCCESS end_seqno = int(resp['value']['vb_0_high_seqno']) Stats.wait_for_persistence(self.mcd_client) assert Stats.wait_for_stat(self.mcd_client, 'vb_0:num_checkpoints', 2, 'checkpoint') op = self.upr_client.open_producer("mystream") response = op.next_response() assert response['status'] == SUCCESS mutations = 0 markers = 0 last_by_seqno = 0 op = self.upr_client.stream_req(0, 0, 0, end_seqno, 0, 0) while op.has_response(): response = op.next_response() if response['opcode'] == 83: assert response['status'] == SUCCESS if response['opcode'] == 83: state = Stats.get_stat(self.mcd_client, 'eq_uprq:mystream:stream_0_state', 'upr') assert state == 'backfilling' if response['opcode'] == 86: markers = markers + 1 if response['opcode'] == 87: assert response['by_seqno'] > last_by_seqno last_by_seqno = response['by_seqno'] mutations = mutations + 1 assert mutations == 15000 assert markers > 1