Ejemplo n.º 1
0
def random_play_back(starts, ends, sid, test_type):
    for k in range(random_size):
        # starts.append(datetime.datetime.now() - datetime.timedelta(seconds=random.randint(0, 345600)))
        starts.append(datetime.datetime(2016, 5, 5) + datetime.timedelta(seconds=random.randint(0, 43200)))
        ends.append(starts[k] + datetime.timedelta(seconds=15))
    for k in range(random_size):
        run_in_background(url_stat, urls[3] % (starts[k].year, starts[k].month, starts[k].day,
                                               starts[k].hour, starts[k].minute, starts[k].second,
                                               ends[k].year, ends[k].month, ends[k].day,
                                               ends[k].hour, ends[k].minute, ends[k].second, random.randint(2, 4),
                                               125, 216, 231, 164, 37777, sid), test_type)
        time.sleep(0.05)
Ejemplo n.º 2
0
    conn = sqlite3.connect(db_name)
    cursor = conn.cursor()
    cursor.execute(sql_fmt, *args)
    values = cursor.fetchall()
    cursor.close()
    conn.close()
    mutex.release()
    return values


def test_new_table():
    new_table('test.db', 'user', 'id varchar(20), name varchar(20)')


def test_insert():
    execute('test.db', 'insert into user (id, name) values (\'' + str(random.randint(0, 100)) + '\', \'test' + str(
        random.randint(0, 100)) + '\')')


def test_query():
    print(query('test.db', 'select * from user'))


if __name__ == '__main__':
    test_new_table()
    for i in range(9):
        if i % 2 == 0:
            run_in_background(test_query)
        else:
            run_in_background(test_insert)
Ejemplo n.º 3
0
    #     back_cache_stat()
    #
    #     # 直播缓存测试
    #     real_cache_stat()
    #
    #     # 回播缓存测试
    #     long_cache_stat()
    #
    #     print_data_set(query_stat_all())
    #
    # # 模拟正常流程测试
    # sample_stat("3")
    #
    # # 模拟单客户端多次测试
    # for i in range(30):
    #     sample_stat("3")
    #     print_data_set(query_stat_all())
    #     print('range : ' + str(i))
    #
    # 模拟多客户端测试
    for i in range(4):
        run_in_background(sample_stat, "4")
    sample_stat("4")
    input('请按回车退出')
    print_data_set(query_stat_all())

    # 测试删
    # sqlite.execute('url_stat.db', 'delete from single WHERE id > 2099')
    # 测试改
    # sqlite.execute('url_stat.db', 'update single set type = 3 WHERE type = 1')
Ejemplo n.º 4
0
    cursor.execute(sql_fmt, *args)
    values = cursor.fetchall()
    cursor.close()
    conn.close()
    mutex.release()
    return values


def test_new_table():
    new_table('test.db', 'user', 'id varchar(20), name varchar(20)')


def test_insert():
    execute(
        'test.db', 'insert into user (id, name) values (\'' +
        str(random.randint(0, 100)) + '\', \'test' +
        str(random.randint(0, 100)) + '\')')


def test_query():
    print(query('test.db', 'select * from user'))


if __name__ == '__main__':
    test_new_table()
    for i in range(9):
        if i % 2 == 0:
            run_in_background(test_query)
        else:
            run_in_background(test_insert)