def setUp(self): MongoDBTestCase.setUp(self) # Generate some fake workload sessions for i in xrange(0, NUM_SESSIONS): sess = self.metadata_db.Session() sess['session_id'] = i sess['ip_client'] = "client:%d" % (1234+i) sess['ip_server'] = "server:5678" sess['start_time'] = time.time() sess['end_time'] = time.time() + 5 for j in xrange(0, NUM_OPS_PER_SESSION): _id = str(random.random()) queryId = long((i<<16) + j) responseContent = {"_id": _id} responseId = (queryId<<8) for f in xrange(0, NUM_FIELDS): f_name = "field%02d" % f if f % 2 == 0: responseContent[f_name] = random.randint(0, 100) else: responseContent[f_name] = str(random.randint(1000, 100000)) ## FOR queryContent = { constants.REPLACE_KEY_DOLLAR_PREFIX + "query": responseContent } op = workload.Session.operationFactory() op['collection'] = COLLECTION_NAME op['type'] = constants.OP_TYPE_QUERY op['query_id'] = queryId op['query_content'] = [ queryContent ] op['resp_content'] = [ responseContent ] op['resp_id'] = responseId sess['operations'].append(op) ## FOR (ops) sess.save() ## FOR (sess) self.assertEqual(NUM_SESSIONS, self.metadata_db.Session.find().count()) self.converter = AbstractConverter(self.metadata_db, self.dataset_db)