Esempio n. 1
0
    def __init__(self,
                 workload_settings,
                 target_settings,
                 shutdown_event=None):
        super().__init__(workload_settings, target_settings, shutdown_event)

        self.new_queries = N1QLQueryGen(workload_settings.n1ql_queries)

        self.reservoir = Reservoir(num_workers=self.ws.n1ql_workers)
Esempio n. 2
0
 def test_query_formatting(self):
     docgen = NewNestedDocument(avg_size=self.SIZE)
     doc = docgen.next('test-key')
     queries = [
         'SELECT * from `bucket-1`;', 'SELECT count(*) from `bucket-1`;'
     ]
     qgen = N1QLQueryGen(queries=queries)
     _, _, query = qgen.next(doc)
     query.format(bucket='bucket-1')
Esempio n. 3
0
    def __init__(self, workload_settings, target_settings, shutdown_event):
        self.new_queries = N1QLQueryGen(workload_settings.n1ql_queries)
        self.total_workers = workload_settings.n1ql_workers
        self.throughput = workload_settings.n1ql_throughput

        self.reservoir = Reservoir(num_workers=workload_settings.n1ql_workers)

        super().__init__(workload_settings, target_settings, shutdown_event)

        self.init_creds()
Esempio n. 4
0
 def __init__(self,
              workload_settings,
              target_settings,
              shutdown_event=None):
     super().__init__(workload_settings, target_settings, shutdown_event)
     self.new_queries = N1QLQueryGen(workload_settings.n1ql_queries)
     self.reservoir = Reservoir(num_workers=self.ws.n1ql_workers)
     self.gen_duration = 0.0
     self.batch_duration = 0.0
     self.delta = 0.0
     self.op_delay = 0.0
     self.first = True
Esempio n. 5
0
    def test_n1ql_query_gen_q2(self):
        queries = [{
            'statement': 'SELECT * FROM `bucket-1` WHERE email = $1;',
            'args': '["{email}"]',
            'scan_consistency': 'request_plus',
        }]

        qg = N1QLQueryGen(queries=queries)

        for doc in {'email': '*****@*****.**'}, {'email': '*****@*****.**'}:
            query = qg.next(key='n1ql-0123456789', doc=doc)
            self.assertEqual(query.consistency, 'request_plus')
            self.assertEqual(query._body['args'], [doc['email']])
Esempio n. 6
0
    def test_n1ql_query_gen_q1(self):
        queries = [{
            'statement': 'SELECT * FROM `bucket-1` USE KEYS[$1];',
            'args': '["{key}"]',
        }]

        qg = N1QLQueryGen(queries=queries)

        for key in 'n1ql-0123456789', 'n1ql-9876543210':
            query = qg.next(key, doc={})
            self.assertEqual(query.adhoc, False)
            self.assertEqual(query.consistency, 'not_bounded')
            self.assertEqual(query._body['args'], [key])
Esempio n. 7
0
    def __init__(self, settings, workload, prefix=None):
        super(SpringN1QLQueryLatency, self).__init__(settings, workload,
                                                     prefix)
        self.clients = []
        queries = settings.new_n1ql_queries
        if queries:
            logger.info("CBAgent will collect latencies for these queries:")
            logger.info(queries)
            for bucket in self.get_buckets():
                client = N1QLGen(bucket=bucket,
                                 host=settings.master_node,
                                 username=bucket,
                                 password=settings.bucket_password)
                self.clients.append((bucket, client))

            self.new_queries = N1QLQueryGen(queries)
Esempio n. 8
0
    def __init__(self, workload_settings, target_settings, shutdown_event):
        super(N1QLWorker, self).__init__(workload_settings, target_settings,
                                          shutdown_event)
        self.new_queries = N1QLQueryGen(workload_settings.n1ql_queries)
        self.total_workers = self.ws.n1ql_workers
        self.throughput = self.ws.n1ql_throughput
        self.name = 'n1ql-worker'

        host, port = self.ts.node.split(':')
        bucket = self.ts.bucket
        if workload_settings.n1ql_op == 'ryow':
                bucket += '?fetch_mutation_tokens=true'

        params = {'bucket': bucket, 'host': host, 'port': port,
                  'username': self.ts.bucket, 'password': self.ts.password}

        self.existing_keys = ExistingKey(self.ws.working_set,
                                         self.ws.working_set_access,
                                         'n1ql')
        self.new_keys = NewKey('n1ql', self.ws.expiration)
        self.keys_for_removal = KeyForRemoval('n1ql')
        self.keys_for_casupdate = KeyForCASUpdate(self.total_workers, self.ws.working_set,
                                                  self.ws.working_set_access,
                                                  'n1ql')

        if self.ws.doc_gen == 'merge':
            self.docs = MergeDocument(self.ws.size,
                                              self.ws.doc_partitions,
                                              False)
        elif self.ws.doc_gen == 'reverse_lookup':
            self.docs = ReverseLookupDocument(self.ws.size,
                                              self.ws.doc_partitions,
                                              False)
        elif self.ws.doc_gen == 'reverse_lookup_array_indexing':
            if self.ws.updates:
                self.docs = ReverseLookupDocumentArrayIndexing(
                    self.ws.size, self.ws.doc_partitions, self.ws.items,
                    delta=random.randint(0, 10))
            else:
                 self.docs = ReverseLookupDocumentArrayIndexing(
                    self.ws.size, self.ws.doc_partitions, self.ws.items)
        self.cb = N1QLGen(**params)
Esempio n. 9
0
    def test_n1ql_query_gen_q2(self):
        queries = [{
            'statement': 'SELECT * FROM `bucket-1` WHERE email = $1;',
            'args': '["{email}"]',
            'scan_consistency': 'request_plus',
        }]

        qg = N1QLQueryGen(queries=queries)

        for doc in {'email': '*****@*****.**'}, {'email': '*****@*****.**'}:
            if cb_version[0] == '3':
                stmt, queryopts = qg.next(key='n1ql-0123456789', doc=doc)
                self.assertEqual(str(queryopts['scan_consistency']),
                                 'QueryScanConsistency.REQUEST_PLUS')
                self.assertEqual(queryopts['positional_parameters'],
                                 [doc['email']])
            else:
                query = qg.next(key='n1ql-0123456789', doc=doc)
                self.assertEqual(query.consistency, 'request_plus')
                self.assertEqual(query._body['args'], [doc['email']])
Esempio n. 10
0
    def test_n1ql_query_gen_q1(self):
        queries = [{
            'statement': 'SELECT * FROM `bucket-1` USE KEYS[$1];',
            'args': '["{key}"]',
        }]

        qg = N1QLQueryGen(queries=queries)

        for key in 'n1ql-0123456789', 'n1ql-9876543210':
            if cb_version[0] == '3':
                stmt, queryopts = qg.next(key, doc={})
                self.assertEqual(queryopts['adhoc'], False)
                self.assertEqual(str(queryopts['scan_consistency']),
                                 'QueryScanConsistency.NOT_BOUNDED')
                self.assertEqual(queryopts['positional_parameters'], [key])
            else:
                query = qg.next(key, doc={})
                self.assertEqual(query.adhoc, False)
                self.assertEqual(query.consistency, 'not_bounded')
                self.assertEqual(query._body['args'], [key])