def setUp(self): super(CbasStats, self).setUp() self.log.info("Add Json documents to default bucket") self.perform_doc_ops_in_all_cb_buckets(self.num_items, "create", 0, self.num_items) self.log.info("Create reference to SDK client") client = SDKClient(scheme="couchbase", hosts=[self.master.ip], bucket=self.cb_bucket_name, password=self.master.rest_password) self.log.info("Insert binary data into default bucket") keys = ["%s" % (uuid.uuid4()) for i in range(0, self.num_items)] client.insert_binary_document(keys) self.log.info("Create connection") self.cbas_util.createConn(self.cb_bucket_name) self.log.info("Create bucket on CBAS") self.assertTrue( self.cbas_util.create_bucket_on_cbas( cbas_bucket_name=self.cbas_bucket_name, cb_bucket_name=self.cb_bucket_name, cb_server_ip=self.cb_server_ip), "bucket creation failed on cbas") self.log.info("Create dataset on the CBAS bucket") self.cbas_util.create_dataset_on_bucket( cbas_bucket_name=self.cb_bucket_name, cbas_dataset_name=self.cbas_dataset_name) self.log.info("Connect to Bucket") self.cbas_util.connect_to_bucket( cbas_bucket_name=self.cbas_bucket_name, cb_bucket_password=self.cb_bucket_password) statement = "select count(*) from {0} where mutated=0;".format( self.cbas_dataset_name) status, metrics, errors, results, response_handle = self.cbas_util.execute_statement_on_cbas_util( statement, mode=self.mode, timeout=75, analytics_timeout=120) if not self.cbas_util.validate_cbas_dataset_items_count( self.cbas_dataset_name, self.num_items): self.fail( "No. of items in CBAS dataset do not match that in the CB bucket" )
def test_cbas_bucket_connect_with_more_than_eight_active_datasets(self): """ 1. Create a cb bucket 2. Create a cbas bucket 3. Create 9 datasets 4. Connect to cbas bucket must fail with error - Maximum number of active writable datasets (8) exceeded 5. Delete 1 dataset, now the count must be 8 6. Re-connect the cbas bucket and this time connection must succeed 7. Verify count in dataset post connect """ self.log.info("Fetch test case arguments") self.fetch_test_case_arguments() self.log.info("Load data in the default bucket") self.perform_doc_ops_in_all_cb_buckets(self.num_items, "create", 0, self.num_items) self.log.info("Create reference to SDK client") client = SDKClient(scheme="couchbase", hosts=[self.master.ip], bucket=self.cb_bucket_name, password=self.master.rest_password) self.log.info("Insert binary data into default bucket") keys = ["%s" % (uuid.uuid4()) for i in range(0, self.num_items)] client.insert_binary_document(keys) self.log.info("Insert Non-Json string data into default bucket") keys = ["%s" % (uuid.uuid4()) for i in range(0, self.num_items)] client.insert_string_document(keys) self.log.info("Create connection") self.cbas_util.createConn(self.cb_bucket_name) self.log.info("Create a CBAS bucket") self.assertTrue(self.cbas_util.create_bucket_on_cbas( cbas_bucket_name=self.cbas_bucket_name, cb_bucket_name=self.cb_bucket_name), msg="Failed to create CBAS bucket") self.log.info("Create datasets") for i in range(1, self.num_of_dataset + 1): self.assertTrue( self.cbas_util.create_dataset_on_bucket( cbas_bucket_name=self.cb_bucket_name, cbas_dataset_name=self.dataset_prefix + str(i)), msg="Failed to create dataset {0}".format(self.dataset_prefix + str(i))) self.log.info("Verify connect to CBAS bucket must fail") self.assertTrue( self.cbas_util.connect_to_bucket( cbas_bucket_name=self.cbas_bucket_name, cb_bucket_password=self.cb_bucket_password, validate_error_msg=True, expected_error=BucketOperations.CBAS_BUCKET_CONNECT_ERROR_MSG), msg="Incorrect error msg while connecting to cbas bucket") self.log.info("Drop the last dataset created") self.assertTrue( self.cbas_util.drop_dataset(cbas_dataset_name=self.dataset_prefix + str(self.num_of_dataset)), msg="Failed to drop dataset {0}".format(self.dataset_prefix + str(self.num_of_dataset))) self.log.info("Connect to CBAS bucket") self.assertTrue(self.cbas_util.connect_to_bucket( cbas_bucket_name=self.cbas_bucket_name), msg="Failed to connect to cbas bucket") self.log.info("Wait for ingestion to complete and validate count") for i in range(1, self.num_of_dataset): self.cbas_util.wait_for_ingestion_complete( [self.dataset_prefix + str(i)], self.num_items) self.assertTrue( self.cbas_util.validate_cbas_dataset_items_count( self.dataset_prefix + str(i), self.num_items))