コード例 #1
0
    def gen_doc(self, key_num, key_str, min_value_size, json=None, cache=None):
        global mongoDocCache

        if json is None:
            json = self.cfg.get('json', 1) > 0
        if cache is None:
            cache = self.cfg.get('doc-cache', 0)

        d = None
        if cache:
            d = mongoDocCache.get(key_num, None)
        if d is None:
            d = {
                "_id": key_str,
                "key_num": key_num,
                "name": mcsoda.key_to_name(key_num, key_str),
                "email": mcsoda.key_to_email(key_num, key_str),
                "city": mcsoda.key_to_city(key_num, key_str),
                "country": mcsoda.key_to_country(key_num, key_str),
                "realm": mcsoda.key_to_realm(key_num, key_str),
                "coins": mcsoda.key_to_coins(key_num, key_str),
                "achievements": mcsoda.key_to_achievements(key_num, key_str)
            }
        if cache:
            mongoDocCache[key_num] = d

        d = copy.deepcopy(d)
        d['body'] = self.cfg['body'][min_value_size]
        return d
コード例 #2
0
ファイル: mcsoda_mongo.py プロジェクト: steveyen/testrunner
    def gen_doc(self, key_num, key_str, min_value_size, json=None, cache=None):
        global mongoDocCache

        if json is None:
           json = self.cfg.get('json', 1) > 0
        if cache is None:
           cache = self.cfg.get('doc-cache', 0)

        d = None
        if cache:
            d = mongoDocCache.get(key_num, None)
        if d is None:
            d = { "_id": key_str,
                  "key_num": key_num,
                  "name": mcsoda.key_to_name(key_num, key_str),
                  "email": mcsoda.key_to_email(key_num, key_str),
                  "city": mcsoda.key_to_city(key_num, key_str),
                  "country": mcsoda.key_to_country(key_num, key_str),
                  "realm": mcsoda.key_to_realm(key_num, key_str),
                  "coins": mcsoda.key_to_coins(key_num, key_str),
                  "category": mcsoda.key_to_category(key_num, key_str),
                  "achievements": mcsoda.key_to_achievements(key_num, key_str) }
        if cache:
            mongoDocCache[key_num] = d

        d = copy.deepcopy(d)
        d['body'] = self.cfg['body'][min_value_size]
        return d
コード例 #3
0
ファイル: cbsoda.py プロジェクト: IrynaMironava/testrunner
    def cmd_append(self, cmd, key_num, key_str, data, expiration, grp):
        if cmd[0] == 'q':
            self.cmds += 1
            m = grp['queries']

            prefix = "GET "
            suffix = " HTTP/1.1\r\n\r\n"

            # A sample queries array might be...
            #
            #   ["/default/_design/my_ddoc/_views/by_email?startkey={email}",
            #    "/default/_design/my_ddoc/_views/by_country?startkey={country}&limit=10"]
            #
            queries = self.cfg.get("queries", "")
            queries = queries.split(';')
            if len(queries) == 0 or len(queries[0]) == 0:
                queries = ["/default/{key}"]

            query = queries[self.cur.get("cur-queries", 0) % len(queries)]

            message = query.format(
                key_str,
                key=key_str,
                name=mcsoda.key_to_name(key_num, key_str).replace(" ", "+"),
                email=mcsoda.key_to_email(key_num, key_str),
                city=mcsoda.key_to_city(key_num, key_str),
                country=mcsoda.key_to_country(key_num, key_str),
                realm=mcsoda.key_to_realm(key_num, key_str),
                coins=mcsoda.key_to_coins(key_num, key_str),
                category=mcsoda.key_to_category(key_num, key_str),
                cmds=self.cmds,
                int10=self.cmds % 10,
                int100=self.cmds % 100,
                int1000=self.cmds % 1000)

            m.append(prefix + message + suffix)

            return 0, 0, 0, 0, 1

        return mcsoda.StoreMembaseBinary.cmd_append(self, cmd, key_num,
                                                    key_str, data, expiration,
                                                    grp)
コード例 #4
0
ファイル: cbsoda.py プロジェクト: IrynaMironava/testrunner
    def cmd_append(self, cmd, key_num, key_str, data, expiration, grp):
        if cmd[0] == 'q':
            self.cmds += 1
            m = grp['queries']

            prefix = "GET "
            suffix = " HTTP/1.1\r\n\r\n"

            # A sample queries array might be...
            #
            #   ["/default/_design/my_ddoc/_views/by_email?startkey={email}",
            #    "/default/_design/my_ddoc/_views/by_country?startkey={country}&limit=10"]
            #
            queries = self.cfg.get("queries", "")
            queries = queries.split(';')
            if len(queries) == 0 or len(queries[0]) == 0:
                queries = [ "/default/{key}" ]

            query = queries[self.cur.get("cur-queries", 0) % len(queries)]

            message = query.format(key_str,
                                   key=key_str,
                                   name=mcsoda.key_to_name(key_num, key_str).replace(" ", "+"),
                                   email=mcsoda.key_to_email(key_num, key_str),
                                   city=mcsoda.key_to_city(key_num, key_str),
                                   country=mcsoda.key_to_country(key_num, key_str),
                                   realm=mcsoda.key_to_realm(key_num, key_str),
                                   coins=mcsoda.key_to_coins(key_num, key_str),
                                   category=mcsoda.key_to_category(key_num, key_str),
                                   cmds=self.cmds,
                                   int10=self.cmds % 10,
                                   int100=self.cmds % 100,
                                   int1000=self.cmds % 1000)

            m.append(prefix + message + suffix)

            return 0, 0, 0, 0, 1

        return mcsoda.StoreMembaseBinary.cmd_append(self, cmd, key_num, key_str,
                                                    data, expiration, grp)