Skip to content

Commit

Permalink
extract sitespeed timeout to own config
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3Rabbit committed Feb 28, 2024
1 parent bb84c46 commit 047bccd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
3 changes: 3 additions & 0 deletions SAMPLE-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
# Tells sitespeed if we should use it as a docker image or a npm package
sitespeed_use_docker = True

# Tells sitespeed max timeout for website calls
sitespeed_timeout = 300

# how many iterations of Sitespeed.io requests would you like? Has to be at least 2 not to fail
sitespeed_iterations = 2

Expand Down
7 changes: 6 additions & 1 deletion tests/css_validator_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
css_review_group_errors = config.css_review_group_errors
review_show_improvements_only = config.review_show_improvements_only
sitespeed_use_docker = config.sitespeed_use_docker
try:
sitespeed_timeout = config.sitespeed_timeout
except:
# If sitespeed timeout is not set in config.py this will be the default
sitespeed_timeout = 600
try:
use_cache = config.cache_when_possible
cache_time_delta = config.cache_time_delta
Expand Down Expand Up @@ -63,7 +68,7 @@ def run_test(_, langCode, url):
sitespeed_arg += ' --postScript chrome-cookies.cjs --postScript chrome-versions.cjs'

(result_folder_name, filename) = get_result(
url, sitespeed_use_docker, sitespeed_arg, request_timeout * 5)
url, sitespeed_use_docker, sitespeed_arg, sitespeed_timeout)

# 1. Visit page like a normal user
data = identify_files(filename)
Expand Down
7 changes: 6 additions & 1 deletion tests/html_validator_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
useragent = config.useragent
review_show_improvements_only = config.review_show_improvements_only
sitespeed_use_docker = config.sitespeed_use_docker
try:
sitespeed_timeout = config.sitespeed_timeout
except:
# If sitespeed timeout is not set in config.py this will be the default
sitespeed_timeout = 600
try:
use_cache = config.cache_when_possible
cache_time_delta = config.cache_time_delta
Expand Down Expand Up @@ -55,7 +60,7 @@ def run_test(_, langCode, url):
sitespeed_arg += ' --postScript chrome-cookies.cjs --postScript chrome-versions.cjs'

(result_folder_name, filename) = get_result(
url, sitespeed_use_docker, sitespeed_arg, request_timeout * 5)
url, sitespeed_use_docker, sitespeed_arg, sitespeed_timeout)

# 1. Visit page like a normal user
data = identify_files(filename)
Expand Down
1 change: 0 additions & 1 deletion tests/sitespeed_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def get_result(url, sitespeed_use_docker, sitespeed_arg, timeout):
versions_json = json.loads(versions)

if (os.path.exists(filename_old)):
print('A')
modify_browsertime_content(filename_old, cookies_json, versions_json)
cleanup_results_dir(filename_old, result_folder_name)
return (result_folder_name, filename)
Expand Down
7 changes: 6 additions & 1 deletion tests/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
except:
# If browser is not set in config.py this will be the default
software_browser = 'chrome'
try:
sitespeed_timeout = config.sitespeed_timeout
except:
# If sitespeed timeout is not set in config.py this will be the default
sitespeed_timeout = 600
try:
use_cache = config.cache_when_possible
cache_time_delta = config.cache_time_delta
Expand Down Expand Up @@ -104,7 +109,7 @@ def get_rating_from_sitespeed(url, _local, _):
sitespeed_arg += ' --postScript chrome-cookies.cjs --postScript chrome-versions.cjs'

(result_folder_name, filename) = get_result(
url, sitespeed_use_docker, sitespeed_arg, request_timeout * 5)
url, sitespeed_use_docker, sitespeed_arg, sitespeed_timeout)


o = urlparse(url)
Expand Down
7 changes: 6 additions & 1 deletion tests/tracking_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
useragent = config.useragent
review_show_improvements_only = config.review_show_improvements_only
sitespeed_use_docker = config.sitespeed_use_docker
try:
sitespeed_timeout = config.sitespeed_timeout
except:
# If sitespeed timeout is not set in config.py this will be the default
sitespeed_timeout = 600
try:
use_cache = config.cache_when_possible
cache_time_delta = config.cache_time_delta
Expand Down Expand Up @@ -785,7 +790,7 @@ def get_rating_from_sitespeed(url, _local, _):
sitespeed_arg += ' --postScript chrome-cookies.cjs --postScript chrome-versions.cjs'

(result_folder_name, filename) = get_result(
url, sitespeed_use_docker, sitespeed_arg, request_timeout * 5)
url, sitespeed_use_docker, sitespeed_arg, sitespeed_timeout)

http_archive_content = get_file_content(filename)

Expand Down

0 comments on commit 047bccd

Please sign in to comment.