Beispiel #1
0
def analyze_sync():
    videofolder = tempfile.mkdtemp()
    video_path = join(videofolder, "Video.mp4")
    if "video" in request.files:
        request.files["video"].save(video_path)
    else:
        return "No Video = No Report"
    report = prepareReport(video_path, loads(request.form.get("data")),
                           videofolder, True)
    rmtree(videofolder)
    return report.get_report()
Beispiel #2
0
def analyze_sync():
    if request.method == "POST":
        videofolder = tempfile.mkdtemp()
        video_path = join(videofolder, "Video.mp4")
        if 'video' in request.files:
            request.files['video'].save(video_path)
        else:
            return "No Video = No Report"
        report = prepareReport(video_path, loads(request.form.get('data')), videofolder, True)
        rmtree(videofolder)
        return report.get_report()
Beispiel #3
0
def run_test(project: Project):
    current_app.logger.info(request.form)
    url = request.form.get("url")
    remote_driver_address = request.form.get("remote_address",
                                             "127.0.0.1:4444")
    listener_address = request.form.get("perfui_listener", "127.0.0.1:9999")
    from selenium import webdriver
    from requests import get
    from time import time
    start_time = time()
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--window-size=1360,1020")
    driver = webdriver.Remote(
        command_executor=f"http://{remote_driver_address}/wd/hub",
        desired_capabilities=chrome_options.to_capabilities())
    get(f"http://{listener_address}/record/start")
    current_time = time() - start_time
    driver.get(url)
    while not driver.execute_script(
            "return document.readyState === \"complete\" && performance.timing.loadEventEnd > 0"
    ):
        sleep(0.1)
    results = driver.execute_script(check_ui_performance)
    video_results = get(f"http://{listener_address}/record/stop").content
    results["info"]["testStart"] = int(current_time)
    driver.quit()
    videofolder = tempfile.mkdtemp()
    video_path = join(videofolder, "Video.mp4")
    current_app.logger.info(videofolder)
    with open(video_path, "w+b") as f:
        f.write(video_results)
    video_name = f"{results['info']['title']}_{int(start_time)}.mp4"
    MinioClient(project=project).upload_file("reports", open(video_path, "rb"),
                                             video_name)
    report = prepareReport(video_path, results, videofolder, True)
    report = report.get_report()
    report_name = f"{results['info']['title']}_{int(start_time)}.html"
    MinioClient(project=project).upload_file("reports", report, report_name)
    rmtree(videofolder)
    return redirect(url_for(
        "observer.index",
        message=f"/api/v1/artifacts/{project.id}/reports/{report_name}"),
                    code=302)
Beispiel #4
0
def run_test():
    current_app.logger.info(request.form)
    url = request.form.get('url')
    remote_driver_address = request.form.get("remote_address",
                                             "127.0.0.1:4444")
    listener_address = request.form.get("perfui_listener", "127.0.0.1:9999")
    from selenium import webdriver
    from requests import get
    from time import time
    start_time = time()
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--window-size=1360,1020')
    driver = webdriver.Remote(
        command_executor=f'http://{remote_driver_address}/wd/hub',
        desired_capabilities=chrome_options.to_capabilities())
    get(f'http://{listener_address}/record/start')
    current_time = time() - start_time
    driver.get(url)
    while not driver.execute_script(
            'return document.readyState === "complete" && performance.timing.loadEventEnd > 0'
    ):
        sleep(0.1)
    results = driver.execute_script(check_ui_performance)
    video_results = get(f'http://{listener_address}/record/stop').content
    results['info']['testStart'] = int(current_time)
    driver.quit()
    videofolder = tempfile.mkdtemp()
    video_path = join(videofolder, "Video.mp4")
    current_app.logger.info(videofolder)
    with open(video_path, 'w+b') as f:
        f.write(video_results)
    report = prepareReport(video_path, results, videofolder, True)
    # rmtree(videofolder)
    report = report.get_report()
    report_name = f'{results["info"]["title"]}_{int(start_time)}.html'
    upload_file('reports', report, report_name)
    return redirect(url_for('observer.index',
                            message=f"/artifacts/reports/{report_name}"),
                    code=302)