diff --git a/.vpython3 b/.vpython3 index 5390a9c287bd2..83879a4434eb6 100644 --- a/.vpython3 +++ b/.vpython3 @@ -394,3 +394,10 @@ wheel: < platform: "linux_aarch64" > > + +# Used by: +# testing/script/run_variations_smoke_tests.py +wheel: < + name: "infra/python/wheels/selenium-py3" + version: "version:3.14.0" +> diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 0e59e3964ecef..693b3ac9dd2c4 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -9941,7 +9941,6 @@ if (is_chromeos_ash) { if (is_linux || is_mac || is_win) { script_test("variations_smoke_tests") { - run_under_python2 = true if (is_linux) { script = "//testing/xvfb.py" @@ -9960,8 +9959,8 @@ if (is_linux || is_mac || is_win) { ] data = [ + "//.vpython3", "//testing/scripts/run_variations_smoke_tests.py", - "//testing/scripts/variations_http_test_server.py", "//testing/scripts/variations_seed_access_helper.py", "//testing/scripts/variations_smoke_test_data/", "//testing/scripts/variations_smoke_test_data/http_server/", diff --git a/testing/scripts/get_compile_targets.py b/testing/scripts/get_compile_targets.py index 247c66d680ec0..76ef48a584c3d 100755 --- a/testing/scripts/get_compile_targets.py +++ b/testing/scripts/get_compile_targets.py @@ -33,10 +33,10 @@ def main(argv): 'PRESUBMIT.py', 'sizes_common.py', 'variations_seed_access_helper.py', - 'variations_http_test_server.py', 'wpt_android_lib.py', 'wpt_common.py', 'wpt_common_unittest.py', + 'run_variations_smoke_tests.py', 'run_performance_tests_unittest.py'): continue diff --git a/testing/scripts/run_variations_smoke_tests.py b/testing/scripts/run_variations_smoke_tests.py index e60cbe4de126a..cc515e6b321c2 100755 --- a/testing/scripts/run_variations_smoke_tests.py +++ b/testing/scripts/run_variations_smoke_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright 2021 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -7,6 +7,7 @@ when parsing a newly given variations seed. """ import argparse +import http import json import logging import os @@ -14,24 +15,17 @@ import shutil import sys import tempfile import time -import six.moves.urllib.error +from functools import partial +from http.server import SimpleHTTPRequestHandler from threading import Thread import common -import six import variations_seed_access_helper as seed_helper -from variations_http_test_server import HTTPServer -from variations_http_test_server import HTTPHandler - -if six.PY3: - import http _THIS_DIR = os.path.dirname(os.path.abspath(__file__)) _SRC_DIR = os.path.join(_THIS_DIR, os.path.pardir, os.path.pardir) -_WEBDRIVER_PATH = os.path.join(_SRC_DIR, 'third_party', 'webdriver', 'pylib') _VARIATIONS_TEST_DATA = 'variations_smoke_test_data' -sys.path.insert(0, _WEBDRIVER_PATH) from selenium import webdriver from selenium.webdriver import ChromeOptions from selenium.common.exceptions import NoSuchElementException @@ -63,14 +57,10 @@ def _get_httpd(): port = 8000 directory = os.path.join(_THIS_DIR, _VARIATIONS_TEST_DATA, "http_server") httpd = None - if six.PY3: - handler = partial(http.server.SimpleHTTPRequestHandler, directory=directory) - httpd = http.server.HTTPServer((hostname, port), handler) - httpd.timeout = 0.5 - httpd.allow_reuse_address = True - httpd.server_bind() - else: - httpd = HTTPServer(directory, (hostname, port)) + handler = partial(SimpleHTTPRequestHandler, directory=directory) + httpd = http.server.HTTPServer((hostname, port), handler) + httpd.timeout = 0.5 + httpd.allow_reuse_address = True return httpd @@ -246,11 +236,7 @@ def _run_tests(*args): shutil.rmtree(log_file, ignore_errors=True) if driver: - try: - driver.quit() - except six.moves.urllib.error.URLError: - # Ignore the error as ChromeDriver may have already exited. - pass + driver.quit() return 0 @@ -263,14 +249,10 @@ def _start_local_http_server(): """ httpd = _get_httpd() thread = None - if six.PY3: - address = "http://{}:{}".format(httpd.server_name, httpd.server_port) - logging.info("%s is used as local http server.", address) - thread = Thread(target=httpd.serve_forever) - thread.setDaemon(True) - else: - thread = Thread(target=httpd.serve_forever) - thread.daemon = True + address = "http://{}:{}".format(httpd.server_name, httpd.server_port) + logging.info("%s is used as local http server.", address) + thread = Thread(target=httpd.serve_forever) + thread.setDaemon(True) thread.start() return httpd diff --git a/testing/scripts/variations_http_test_server.py b/testing/scripts/variations_http_test_server.py deleted file mode 100644 index b910688335c31..0000000000000 --- a/testing/scripts/variations_http_test_server.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -"""A http server implementation based on SimpleHTTPServer or http.server and -serves content from a base_path. -""" - -import os -try: - # Python 2 - from SimpleHTTPServer import SimpleHTTPRequestHandler - from BaseHTTPServer import HTTPServer as BaseHTTPServer -except ImportError: - # Python 3 - from http.server import SimpleHTTPRequestHandler - from http.server import HTTPServer as BaseHTTPServer - -class HTTPHandler(SimpleHTTPRequestHandler): - """This handler allows to specify a bath_path. """ - def translate_path(self, path): - """Uses server.base_path to combine full path.""" - path = SimpleHTTPRequestHandler.translate_path(self, path) - real_path = os.path.relpath(path, os.getcwd()) - return os.path.join(self.server.base_path, real_path) - -class HTTPServer(BaseHTTPServer): - """The main server, which you couild override base_path.""" - def __init__(self, base_path, server_address, - RequestHandlerClass=HTTPHandler): - self.base_path = base_path - self.stop = False - BaseHTTPServer.__init__(self, server_address, RequestHandlerClass) - - #pylint: disable=unused-argument - def serve_forever(self, poll_interval=0.1): - self.stop = False - while not self.stop: - self.handle_request() - - def shutdown(self): - self.stop = True