Exemplo n.º 1
0
 def test_eventing_with_ephemeral_buckets_with_eviction_enabled(self):
     # delete src_bucket which will be created as part of setup
     self.rest.delete_bucket(self.src_bucket_name)
     # create source bucket as ephemeral bucket with the same name
     bucket_params = self._create_bucket_params(
         server=self.server,
         size=self.bucket_size,
         replicas=self.num_replicas,
         bucket_type='ephemeral',
         eviction_policy='nruEviction')
     self.cluster.create_standard_bucket(name=self.src_bucket_name,
                                         port=STANDARD_BUCKET_PORT + 1,
                                         bucket_params=bucket_params)
     body = self.create_save_function_body(self.function_name,
                                           self.handler_code)
     # deploy function
     self.deploy_function(body)
     # load data
     self.load(self.gens_load,
               buckets=self.src_bucket,
               flag=self.item_flag,
               verify_data=False,
               batch_size=self.batch_size)
     try:
         # delete all documents
         self.load(self.gens_load,
                   buckets=self.src_bucket,
                   flag=self.item_flag,
                   verify_data=False,
                   batch_size=self.batch_size,
                   op_type='delete')
     except:
         # since some of the docs are already ejected by eventing, load method will fails, hence ignoring failure
         pass
     # Wait for eventing to catch up with all the delete mutations and verify results
     stats_src = RestConnection(
         self.master).get_bucket_stats(bucket=self.src_bucket_name)
     self.verify_eventing_results(self.function_name,
                                  stats_src["curr_items"],
                                  skip_stats_validation=True)
     self.undeploy_and_delete_function(body)
     vb_active_auto_delete_count = StatsCommon.get_stats(
         [self.master], self.src_bucket_name, '',
         'vb_active_auto_delete_count')[self.master]
     if vb_active_auto_delete_count == 0:
         self.fail("No items were ejected from ephemeral bucket")
     else:
         log.info(
             "Number of items auto deleted from ephemeral bucket is {0}".
             format(vb_active_auto_delete_count))
     # sleep intentionally added , as it requires some time for eventing-consumers to shutdown
     self.sleep(30)
     self.assertTrue(
         self.check_if_eventing_consumers_are_cleaned_up(),
         msg=
         "eventing-consumer processes are not cleaned up even after undeploying the function"
     )
Exemplo n.º 2
0
 def test_eventing_with_ephemeral_buckets_with_eviction_enabled(self):
     # delete src_bucket which will be created as part of setup
     self.rest.delete_bucket(self.src_bucket_name)
     # create source bucket as ephemeral bucket with the same name
     bucket_params = self._create_bucket_params(server=self.server, size=self.bucket_size,
                                                replicas=self.num_replicas, bucket_type='ephemeral',
                                                eviction_policy='nruEviction')
     self.cluster.create_standard_bucket(name=self.src_bucket_name, port=STANDARD_BUCKET_PORT + 1,
                                         bucket_params=bucket_params)
     body = self.create_save_function_body(self.function_name, self.handler_code)
     # deploy function
     self.deploy_function(body)
     # load data
     self.load(self.gens_load, buckets=self.src_bucket, flag=self.item_flag, verify_data=False,
               batch_size=self.batch_size)
     try:
         # delete all documents
         self.load(self.gens_load, buckets=self.src_bucket, flag=self.item_flag, verify_data=False,
                   batch_size=self.batch_size, op_type='delete')
     except:
         # since some of the docs are already ejected by eventing, load method will fails, hence ignoring failure
         pass
     # Wait for eventing to catch up with all the delete mutations and verify results
     stats_src = RestConnection(self.master).get_bucket_stats(bucket=self.src_bucket_name)
     self.verify_eventing_results(self.function_name, stats_src["curr_items"], skip_stats_validation=True)
     self.undeploy_and_delete_function(body)
     vb_active_auto_delete_count = StatsCommon.get_stats([self.master], self.src_bucket_name, '',
                                                         'vb_active_auto_delete_count')[self.master]
     if vb_active_auto_delete_count == 0:
         self.fail("No items were ejected from ephemeral bucket")
     else:
         log.info("Number of items auto deleted from ephemeral bucket is {0}".format(vb_active_auto_delete_count))
     # sleep intentionally added , as it requires some time for eventing-consumers to shutdown
     self.sleep(30)
     self.assertTrue(self.check_if_eventing_consumers_are_cleaned_up(),
                     msg="eventing-consumer processes are not cleaned up even after undeploying the function")
 def bucket_stat(self, key, bucket):
     stats = StatsCommon.get_stats([self.master], bucket, "", key)
     val = stats.values()[0]
     if val.isdigit():
         val = int(val)
     return val
Exemplo n.º 4
0
 def bucket_stat(self, key, bucket):
     stats = StatsCommon.get_stats([self.master], bucket, "", key)
     val = stats.values()[0]
     if val.isdigit():
         val = int(val)
     return val