Ejemplo n.º 1
0
def test():
    log_debug('install', 'start testing ')
    login_cnt = 0
    install_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('install->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('install->login', 'login_cnt=%d' % login_cnt)
        if SHOW_TIME:
            log_debug('install->login', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
            start_time = datetime.utcnow()
        
        if RANDOM_DRIVER:
            driver_num = randint(0, DRIVER_NUM - 1)
            package = DRIVER_PACKAGE + str(driver_num)
        else:
            package = DRIVER_PACKAGE + str(DRIVER_START + i)
        
        if not install_driver(uid, package, VERSION):
            log_err('instll', 'failed to install driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('install', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        install_cnt += 1
        log_debug('install', 'install_cnt=%d' % install_cnt)
Ejemplo n.º 2
0
def test():
    log_debug('install', 'start testing ')
    login_cnt = 0
    install_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('install->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('install->login', 'login_cnt=%d' % login_cnt)
        if SHOW_TIME:
            log_debug('install->login',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
            start_time = datetime.utcnow()

        if RANDOM_DRIVER:
            driver_num = randint(40, DRIVER_NUM)
            package = DRIVER_PACKAGE + str(driver_num)
        else:
            package = DRIVER_PACKAGE + str(DRIVER_START + i)

        if not install_driver(uid, package, VERSION):
            log_err('instll', 'failed to install driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('install',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        install_cnt += 1
        log_debug('install', 'install_cnt=%d' % install_cnt)
Ejemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--driver', action='store_true')
    parser.add_argument('-a', '--app', action='store_true')
    parser.add_argument('-i', dest='uid', default=None)
    parser.add_argument('-u', dest='username', default=None)
    parser.add_argument('-p', dest='password', default=None)
    parser.add_argument('-v', dest='version', default=None)
    parser.add_argument('-s', dest='source', default=None)

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()

    cmd = sys.argv[1]
    if cmd == 'login':
        args = parser.parse_args(sys.argv[2:])
        uid, key = login(args.username, args.password)
        log_debug('dpm',
                  'finished login, uid=%s, key=%s' % (str(uid), str(key)))
        sys.exit()
    else:
        package = sys.argv[2]
        args = parser.parse_args(sys.argv[3:])
        user = args.username
        password = args.password
        version = args.version
        path = args.source
        uid = args.uid

    if len(package.split('==')) > 1:
        package, version = get_version(package)

    if args.app:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_app(path, uid, package, version, key):
                log_debug('dpm', 'finished uploading app %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_app(uid, package, version):
                log_debug('dpm', 'finished installing app %s' % package)
        elif cmd == 'uninstall':
            uid, key = login(user, password)
            if uninstall_app(uid, package):
                log_debug('dpm', 'finished removing app %s' % package)

    elif args.driver:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_driver(path, uid, package, version):
                log_debug('dpm', 'finished uploading driver %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_driver(uid, package, version):
                log_debug('dpm', 'finished installing driver %s' % package)
Ejemplo n.º 4
0
Archivo: dpm.py Proyecto: tx626/dpm
def main(): 
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--driver', action='store_true')
    parser.add_argument('-a', '--app', action='store_true')
    parser.add_argument('-i',  dest='uid', default=None)
    parser.add_argument('-u',  dest='username', default=None)
    parser.add_argument('-p',  dest='password', default=None)
    parser.add_argument('-v',  dest='version', default=None)
    parser.add_argument('-s',  dest='source', default=None)
    
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()
    
    cmd = sys.argv[1]
    if cmd == 'login':
        args = parser.parse_args(sys.argv[2:])
        uid, key = login(args.username, args.password)
        log_debug('dpm', 'finished login, uid=%s, key=%s' % (str(uid), str(key)))
        sys.exit()
    else:
        package = sys.argv[2]
        args = parser.parse_args(sys.argv[3:])
        user = args.username
        password = args.password
        version = args.version
        path = args.source
        uid = args.uid
        
    if len(package.split('==')) > 1:
        package, version = get_version(package)
    
    if args.app:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_app(path, uid, package, version, key):
                log_debug('dpm', 'finished uploading app %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_app(uid, package, version):
                log_debug('dpm', 'finished installing app %s' % package)
        elif cmd == 'uninstall':
            uid, key = login(user, password)
            if uninstall_app(uid, package):
                log_debug('dpm', 'finished removing app %s' % package) 
    
    elif args.driver:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_driver(path, uid, package, version):
                log_debug('dpm', 'finished uploading driver %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_driver(uid, package, version):
                log_debug('dpm', 'finished installing driver %s' % package)
Ejemplo n.º 5
0
def test():
    log_debug('upload', 'start testing ')
    login_cnt = 0
    upload_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('upload->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('upload->login', 'login_cnt=%d' % login_cnt)
        
        package = DRIVER_PACKAGE + str(DRIVER_START + i)
        if not upload(DRIVER_PATH, uid, package, VERSION, DRIVER, key):
            log_err('upload', 'failed to upload driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('upload', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        upload_cnt += 1
        log_debug('upload', 'upload_cnt=%d' % upload_cnt)
Ejemplo n.º 6
0
def test():
    log_debug('upload', 'start testing ')
    login_cnt = 0
    upload_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('upload->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('upload->login', 'login_cnt=%d' % login_cnt)

        package = DRIVER_PACKAGE + str(DRIVER_START + i)
        if not upload(DRIVER_PATH, uid, package, VERSION, DRIVER, key):
            log_err('upload', 'failed to upload driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('upload',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        upload_cnt += 1
        log_debug('upload', 'upload_cnt=%d' % upload_cnt)
Ejemplo n.º 7
0
def test():
    log_debug('upload', 'start testing ')
    login_cnt = 0
    upload_cnt = 0
    get_pkgs_details_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('upload->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('upload->login', 'login_cnt=%d' % login_cnt)
        package = PACKAGE + str(50 + i)
        if not upload(PATH, uid, package, VERSION, APP, key):
            log_err('upload', 'failed to upload app %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('upload',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        upload_cnt += 1
        log_debug('upload', 'upload_cnt=%d' % upload_cnt)

        if SHOW_TIME:
            start_time = datetime.utcnow()
        message = json.dumps({'op': 'get_counter', 'category': CATEGORY})
        ws = create_connection("ws://%s:%d/ws" % (get_manager(), get_port()))
        ws.send(message)
        ret = ws.recv()
        ws.close()
        result = json.loads(ret)
        if not result or 'get_counter' != result['op'] or CATEGORY != result[
                'category'] or not result['data']:
            log_err('get_counter', 'failed to get counter')
            return False
        counter = result['data']
        if not counter:
            log_err('get_counter',
                    'failed to get the total number of %s ' % str(CATEGORY))
            return False
        if SHOW_TIME:
            log_debug('get_counter',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        log_debug('get_counter', 'counter=%s' % str(counter))
        if int(counter) < 1:
            rank = 0
        else:
            rank = randint(0, (int(counter) + PAGE_SIZE - 1) / PAGE_SIZE - 1)
        log_debug('get_counter', 'rank=%d' % rank)

        if SHOW_TIME:
            start_time = datetime.utcnow()
        message = json.dumps({
            'op': 'get_packages_details',
            'category': CATEGORY,
            'rank': rank
        })
        ws = create_connection("ws://%s:%d/ws" % (get_manager(), get_port()))
        ws.send(message)
        ret = ws.recv()
        ws.close()
        result = json.loads(ret)
        if not result or 'get_packages_details' != result[
                'op'] or CATEGORY != result['category'] or rank != result[
                    'rank'] or not result['data']:
            log_err('get_packages_details', 'failed to get packages details')
            return False
        ret = result['data']
        for item in ret:
            if not item['pkg'] or not item['title'] or not item['auth']:
                log_err('get_packages_details', 'failed to get valid details')
                return False
        if SHOW_TIME:
            log_debug('get_packages_details',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        get_pkgs_details_cnt += 1
        log_debug('get_packages_details',
                  'get_pkgs_details_cnt=%d' % get_pkgs_details_cnt)
        log_debug('get_packages_details', 'packages_details=%s' % str(ret))
Ejemplo n.º 8
0
def test():
    log_debug('upload', 'start testing ')
    login_cnt = 0
    upload_cnt = 0
    get_pkgs_details_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('upload->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('upload->login', 'login_cnt=%d' % login_cnt)
        package = PACKAGE + str(PKG_START + i)
        if not upload(PATH, uid, package, VERSION, APP, key):
            log_err('upload', 'failed to upload app %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('upload', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        upload_cnt += 1
        log_debug('upload', 'upload_cnt=%d' % upload_cnt)
        
        if SHOW_TIME:
            start_time = datetime.utcnow()
        message = json.dumps({'operator':'get_counter', 'category':CATEGORY})
        ws = create_connection("ws://%s:%d/" % (get_manager(), get_port()))
        ws.send(message)
        ret = ws.recv()
        ws.close()
        result = json.loads(ret)
        if not result or 'get_counter' != result['operator'] or CATEGORY != result['category'] or not  result['data']:
            log_err('get_counter', 'failed to get counter')
            return False
        counter = result['data']
        if not counter:
            log_err('get_counter', 'failed to get the total number of %s ' % str(CATEGORY))
            return False
        if SHOW_TIME:
            log_debug('get_counter', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        log_debug('get_counter', 'counter=%s' % str(counter))
        rank = randint(0, (int(counter)  + PAGE_SIZE  - 1) / PAGE_SIZE - 1)
        log_debug('get_counter', 'rank=%d' % rank)
        
        if SHOW_TIME:
            start_time = datetime.utcnow()
        message = json.dumps({'operator':'get_packages_details', 'category':CATEGORY, 'rank':rank})
        ws = create_connection("ws://%s:%d/" % (get_manager(), get_port()))
        ws.send(message)
        ret = ws.recv()
        ws.close()
        result = json.loads(ret)
        if not result or 'get_packages_details' != result['operator'] or CATEGORY != result['category'] or rank != result['rank'] or not  result['data']:
            log_err('get_packages_details', 'failed to get packages details')
            return False
        ret = result['data']
        for item in ret:
            if not item['pkg'] or not item['title'] or not item['auth']:
                log_err('get_packages_details', 'failed to get valid details')
                return False
        if SHOW_TIME:
            log_debug('get_packages_details', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        get_pkgs_details_cnt += 1
        log_debug('get_packages_details', 'get_pkgs_details_cnt=%d' % get_pkgs_details_cnt)
        log_debug('get_packages_details', 'packages_details=%s' % str(ret))