def create_default_index(self, index_name, bucket_name): index = FTSIndex(self.cb_cluster, name=index_name, source_name=bucket_name) rest = RestConnection(self.cb_cluster.get_random_fts_node()) index.create(rest) return index
def create_index_with_credentials(self, username, password, index_name, bucket_name="default"): index = FTSIndex(self._cb_cluster, name=index_name, source_name=bucket_name) rest = self.get_rest_handle_for_credentials(username,password) index.create(rest) return index
def query_index_with_no_credentials(self): server = self._cb_cluster.get_random_fts_node() self.load_sample_buckets(server=server, bucketName="travel-sample") index = FTSIndex(self._cb_cluster, name="travel", source_name="travel-sample") rest = self.get_rest_handle_for_credentials("Administrator", "password") index.create(rest) self.wait_for_indexing_complete() api = "http://{0}:8094/api/index/travel/query?".format(server.ip) query = {"match": "Wick", "field": "city"} import urllib api = api + urllib.urlencode(query) response, content = httplib2.Http(timeout=120).request(api, "POST", headers=None) self.log.info( "Querying returned : {0}".format(str(response) + content)) if response['status'] in ['200', '201', '202']: self.log.error(content) self.fail("FAIL: Querying possible without credentials!") else: self.log.info("Querying without credentials failed as expected!")
def create_alias_with_credentials(self, username, password, alias_name, target_indexes): alias_def = {"targets": {}} for index in target_indexes: alias_def['targets'][index.name] = {} alias_def['targets'][index.name]['indexUUID'] = index.get_uuid() alias = FTSIndex(self._cb_cluster, name=alias_name, index_type='fulltext-alias',index_params=alias_def) rest = self.get_rest_handle_for_credentials(username, password) alias.create(rest) return alias
def get_index_with_no_credentials(self): server = self._cb_cluster.get_random_fts_node() self.load_sample_buckets(server=server, bucketName="travel-sample") index = FTSIndex(self._cb_cluster, name="travel", source_name="travel-sample") rest = self.get_rest_handle_for_credentials("Administrator", "password") index.create(rest) api = "http://{0}:8094/api/index/travel".format(server.ip) response, content = httplib2.Http(timeout=120).request(api, "GET", headers=None) self.log.info("Getting index definition returned : {0}".format(str(response)+content)) if response['status'] in ['200', '201', '202']: self.log.error(content) self.fail("FAIL: Get index definition passed without credentials!") else: self.log.info("Get index definition without credentials failed as expected!")
def query_index_with_no_credentials(self): server = self._cb_cluster.get_random_fts_node() self.load_sample_buckets(server=server, bucketName="travel-sample") index = FTSIndex(self._cb_cluster, name="travel", source_name="travel-sample") rest = self.get_rest_handle_for_credentials("Administrator", "password") index.create(rest) self.wait_for_indexing_complete() api = "http://{0}:8094/api/index/travel/query?".format(server.ip) query = {"match": "Wick", "field": "city"} import urllib api = api + urllib.urlencode(query) response, content = httplib2.Http(timeout=120).request(api, "POST", headers=None) self.log.info("Querying returned : {0}".format(str(response) + content)) if response['status'] in ['200', '201', '202']: self.log.error(content) self.fail("FAIL: Querying possible without credentials!") else: self.log.info("Querying without credentials failed as expected!")