Beispiel #1
0
def step_impl(context, router, pkg_name):
    if pkg_name is None:
        pkg_name = "tests.testset.asdf"
    elif pkg_name == "random":
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "wrong":
        pkg_name = "noapp.package.name"
    else:
        pass

    params = {"operation": "test.change.params", "custom_router": router}
    common.run_request(context.mock_server, "POST", params)

    context.scenario.current_instance = context.scenario.current_user.start_instance(
        pkg_name)

    context.scenario.instances.append(context.scenario.current_instance)

    if pkg_name.lower().startswith("noapp"):
        context.scenario.deleted_instance = context.scenario.current_instance
        context.scenario.deleted_instances.append(
            context.scenario.current_instance)
        context.scenario.instances.remove(context.scenario.current_instance)

    time.sleep(10)
    params = {"operation": "test.unset.params", "param": 'custom_router'}
    common.run_request(context.mock_server, "POST", params)
Beispiel #2
0
def cloud_play(n):
    uid = "xiaom1" + formatdata.expand_int(n)
    utoken = formatdata.random_str(32)
    cloud_user = CloudUser(uid, utoken)
    playing_time = random.randint(12000, interval)
    inst = cloud_user.start_instance('test.test.te', playingTime=playing_time)
    sleep_time = random.randint(30, (end_time - now_time) / 1000 + 10)

    action = 'stop'
    for key in weight.keys():
        if __get_do(weight[key]):
            action = key
            break
    #print "User: {user}; playtime: {playtime}; WaitTime: {wait}; Action:{action}".format(user=uid, playtime=playing_time,


#                                                                        wait=sleep_time, action=action)
    gevent.sleep(sleep_time)
    if action == "stop":
        inst.stop_instance()
    elif action == "noinput":
        inst.notify_instance('20')
    elif action == "crash":
        inst.notify_instance('11')
    else:
        pass
    print getcurrent()
Beispiel #3
0
def step_impl(context, param, key, pkg_name=None):
    if pkg_name is None:
        pkg_name = "tests.testset.asdf"
    elif pkg_name == "random":
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "wrong":
        pkg_name = "noapp.package.name"
    else:
        pass

    if key == "priority":
        context.scenario.current_instance = context.scenario.current_user.start_instance(
            pkg_name, priority=param)
    elif key == "time":
        context.scenario.current_instance = context.scenario.current_user.start_instance(
            pkg_name, playingTime=param)
    else:
        context.scenario.current_instance = context.scenario.current_user.start_instance(
            pkg_name)

    context.scenario.instances.append(context.scenario.current_instance)

    if pkg_name.lower().startswith("noapp"):
        context.scenario.deleted_instance = context.scenario.current_instance
        context.scenario.deleted_instances.append(
            context.scenario.current_instance)
        context.scenario.instances.remove(context.scenario.current_instance)
Beispiel #4
0
def step_impl(context, pkg_name=None):
    if pkg_name is None:
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "random":
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "wrong":
        pkg_name = "noapp.package.name"
    else:
        pass
    context.scenario.current_instance = context.scenario.current_user.start_instance(
        pkg_name)
    context.scenario.instances.append(context.scenario.current_instance)
    if pkg_name.lower().startswith("noapp"):
        context.scenario.deleted_instance = context.scenario.current_instance
        context.scenario.deleted_instances.append(
            context.scenario.current_instance)
        context.scenario.instances.remove(context.scenario.current_instance)
Beispiel #5
0
def step_impl(context, status):
    #if context.games is None:
    #    pkg_name = "saas.test." + formatdata.random_str(5)
    #else:
    pkg_name = "saas.test." + formatdata.random_str(5)

    context.scenario.current_instance = context.scenario.current_user.start_instance(
        pkg_name, status=status)
    context.scenario.instances.append(context.scenario.current_instance)
Beispiel #6
0
def step_impl(context, access_key):
    cloud_db = CloudDB()
    cloud_redis = CloudRedis()
    user = "******" + formatdata.random_str(4)
    context.scenario.current_user = CloudUser(user, "password", access_key)
    context.scenario.users.append(context.scenario.current_user)
    context.scenario.order_id = cloud_db.get_order_by_accesskey(access_key)

    if access_key not in context.scenario.bids:
        cloud_db.set_concurrency_by_accesskey(access_key, 1000)
        cloud_redis.set_value(
            "cloudservice-count-" + context.scenario.order_id, "500")
        context.scenario.bids.append(access_key)
        time.sleep(2)
Beispiel #7
0
def step_impl(context, pkg_name=None):
    if pkg_name is None:
        #pkg_name = random.choice(context.games)
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "random":
        pkg_name = "tests.testset." + formatdata.random_str(5)
    elif pkg_name == "wrong":
        pkg_name = "noapp.package.name"
    else:
        pass

    params = {}
    for row in context.table:
        params[row['key']] = row['value']

    context.scenario.current_instance = context.scenario.current_user.start_instance(
        pkg_name, kargs=params)
    context.scenario.instances.append(context.scenario.current_instance)

    if pkg_name.lower().startswith("noapp"):
        context.scenario.deleted_instance = context.scenario.current_instance
        context.scenario.deleted_instances.append(
            context.scenario.current_instance)
        context.scenario.instances.remove(context.scenario.current_instance)