Testing - Adding simple memory usage test (#2483)

pull/2152/merge
dgtlmoon 4 months ago committed by GitHub
parent 732ae1d935
commit 8f3a6a42bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,7 @@
#!/usr/bin/python3
import resource
import time
from threading import Thread
import pytest
from changedetectionio import changedetection_app
@ -23,6 +26,36 @@ def reportlog(pytestconfig):
yield
logger.remove(handler_id)
def track_memory(memory_usage, ):
while not memory_usage["stop"]:
max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
memory_usage["peak"] = max(memory_usage["peak"], max_rss)
time.sleep(0.01) # Adjust the sleep time as needed
@pytest.fixture(scope='function')
def measure_memory_usage(request):
memory_usage = {"peak": 0, "stop": False}
tracker_thread = Thread(target=track_memory, args=(memory_usage,))
tracker_thread.start()
yield
memory_usage["stop"] = True
tracker_thread.join()
# Note: ru_maxrss is in kilobytes on Unix-based systems
max_memory_used = memory_usage["peak"] / 1024 # Convert to MB
s = f"Peak memory used by the test {request.node.fspath} - '{request.node.name}': {max_memory_used:.2f} MB"
logger.debug(s)
with open("test-memory.log", 'a') as f:
f.write(f"{s}\n")
# Assert that the memory usage is less than 200MB
assert max_memory_used < 150, f"Memory usage exceeded 200MB: {max_memory_used:.2f} MB"
def cleanup(datastore_path):
import glob
# Unlink test output files

@ -77,13 +77,13 @@ def do_test(client, live_server, make_test_use_extra_browser=False):
# Requires playwright to be installed
def test_request_via_custom_browser_url(client, live_server):
def test_request_via_custom_browser_url(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# We do this so we can grep the logs of the custom container and see if the request actually went through that container
do_test(client, live_server, make_test_use_extra_browser=True)
def test_request_not_via_custom_browser_url(client, live_server):
def test_request_not_via_custom_browser_url(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# We do this so we can grep the logs of the custom container and see if the request actually went through that container
do_test(client, live_server, make_test_use_extra_browser=False)

@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks
import logging
# Requires playwright to be installed
def test_fetch_webdriver_content(client, live_server):
def test_fetch_webdriver_content(client, live_server, measure_memory_usage):
live_server_setup(live_server)
#####################

@ -3,7 +3,7 @@ from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
def test_execute_custom_js(client, live_server):
def test_execute_custom_js(client, live_server, measure_memory_usage):
live_server_setup(live_server)
assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test"

@ -5,7 +5,7 @@ from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
def test_preferred_proxy(client, live_server):
def test_preferred_proxy(client, live_server, measure_memory_usage):
live_server_setup(live_server)
url = "http://chosen.changedetection.io"

@ -5,7 +5,7 @@ from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
def test_noproxy_option(client, live_server):
def test_noproxy_option(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# Run by run_proxy_tests.sh
# Call this URL then scan the containers that it never went through them

@ -5,7 +5,7 @@ from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
# just make a request, we will grep in the docker logs to see it actually got called
def test_check_basic_change_detection_functionality(client, live_server):
def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage):
live_server_setup(live_server)
res = client.post(
url_for("import_page"),

@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks
import os
# just make a request, we will grep in the docker logs to see it actually got called
def test_select_custom(client, live_server):
def test_select_custom(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# Goto settings, add our custom one

@ -5,7 +5,7 @@ from flask import url_for
from changedetectionio.tests.util import live_server_setup, wait_for_all_checks
def test_socks5(client, live_server):
def test_socks5(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# Setup a proxy

@ -7,7 +7,7 @@ from changedetectionio.tests.util import live_server_setup, wait_for_all_checks
# should be proxies.json mounted from run_proxy_tests.sh already
# -v `pwd`/tests/proxy_socks5/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json
def test_socks5_from_proxiesjson_file(client, live_server):
def test_socks5_from_proxiesjson_file(client, live_server, measure_memory_usage):
live_server_setup(live_server)
test_url = "https://changedetection.io/CHANGELOG.txt?socks-test-tag=" + os.getenv('SOCKSTEST', '')

@ -48,7 +48,7 @@ def set_back_in_stock_response():
return None
# Add a site in paused mode, add an invalid filter, we should still have visual selector data ready
def test_restock_detection(client, live_server):
def test_restock_detection(client, live_server, measure_memory_usage):
set_original_response()
#assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test"

@ -40,7 +40,7 @@ def get_last_message_from_smtp_server():
# Requires running the test SMTP server
def test_check_notification_email_formats_default_HTML(client, live_server):
def test_check_notification_email_formats_default_HTML(client, live_server, measure_memory_usage):
# live_server_setup(live_server)
set_original_response()
@ -92,7 +92,7 @@ def test_check_notification_email_formats_default_HTML(client, live_server):
assert b'Deleted' in res.data
def test_check_notification_email_formats_default_Text_override_HTML(client, live_server):
def test_check_notification_email_formats_default_Text_override_HTML(client, live_server, measure_memory_usage):
# live_server_setup(live_server)
# HTML problems? see this

@ -35,10 +35,10 @@ def set_original(excluding=None, add_line=None):
with open("test-datastore/endpoint-content.txt", "w") as f:
f.write(test_return_data)
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_check_removed_line_contains_trigger(client, live_server):
def test_check_removed_line_contains_trigger(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
time.sleep(1)
@ -103,7 +103,7 @@ def test_check_removed_line_contains_trigger(client, live_server):
assert b'Deleted' in res.data
def test_check_add_line_contains_trigger(client, live_server):
def test_check_add_line_contains_trigger(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# Give the endpoint time to spin up

@ -53,10 +53,10 @@ def is_valid_uuid(val):
return False
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_api_simple(client, live_server):
def test_api_simple(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
api_key = extract_api_key_from_UI(client)
@ -241,7 +241,7 @@ def test_api_simple(client, live_server):
)
assert len(res.json) == 0, "Watch list should be empty"
def test_access_denied(client, live_server):
def test_access_denied(client, live_server, measure_memory_usage):
# `config_api_token_enabled` Should be On by default
res = client.get(
url_for("createwatch")
@ -287,7 +287,7 @@ def test_access_denied(client, live_server):
)
assert b"Settings updated." in res.data
def test_api_watch_PUT_update(client, live_server):
def test_api_watch_PUT_update(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
api_key = extract_api_key_from_UI(client)
@ -369,7 +369,7 @@ def test_api_watch_PUT_update(client, live_server):
assert b'Deleted' in res.data
def test_api_import(client, live_server):
def test_api_import(client, live_server, measure_memory_usage):
api_key = extract_api_key_from_UI(client)
res = client.post(

@ -5,7 +5,7 @@ from flask import url_for
from .util import live_server_setup, wait_for_all_checks
def test_basic_auth(client, live_server):
def test_basic_auth(client, live_server, measure_memory_usage):
live_server_setup(live_server)

@ -76,11 +76,11 @@ def set_response_without_ldjson():
f.write(test_return_data)
return None
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# actually only really used by the distll.io importer, but could be handy too
def test_check_ldjson_price_autodetect(client, live_server):
def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage):
set_response_with_ldjson()
@ -167,7 +167,7 @@ def _test_runner_check_bad_format_ignored(live_server, client, has_ldjson_price_
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_bad_ldjson_is_correctly_ignored(client, live_server):
def test_bad_ldjson_is_correctly_ignored(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
test_return_data = """
<html>

@ -17,7 +17,7 @@ def test_inscriptus():
assert stripped_text_from_html == 'test!\nok man'
def test_check_basic_change_detection_functionality(client, live_server):
def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage):
set_original_response()
live_server_setup(live_server)

@ -8,7 +8,7 @@ import re
import time
def test_backup(client, live_server):
def test_backup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
set_original_response()

@ -60,7 +60,7 @@ def set_modified_response_minus_block_text():
f.write(test_return_data)
def test_check_block_changedetection_text_NOT_present(client, live_server):
def test_check_block_changedetection_text_NOT_present(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# Use a mix of case in ZzZ to prove it works case-insensitive.

@ -6,7 +6,7 @@ from . util import live_server_setup
def test_trigger_functionality(client, live_server):
def test_trigger_functionality(client, live_server, measure_memory_usage):
live_server_setup(live_server)

@ -70,7 +70,7 @@ def test_include_filters_output():
# Tests the whole stack works with the CSS Filter
def test_check_markup_include_filters_restriction(client, live_server):
def test_check_markup_include_filters_restriction(client, live_server, measure_memory_usage):
sleep_time_for_fetch_thread = 3
include_filters = "#sametext"
@ -124,7 +124,7 @@ def test_check_markup_include_filters_restriction(client, live_server):
# Tests the whole stack works with the CSS Filter
def test_check_multiple_filters(client, live_server):
def test_check_multiple_filters(client, live_server, measure_memory_usage):
sleep_time_for_fetch_thread = 3
include_filters = "#blob-a\r\nxpath://*[contains(@id,'blob-b')]"
@ -180,7 +180,7 @@ def test_check_multiple_filters(client, live_server):
# The filter exists, but did not contain anything useful
# Mainly used when the filter contains just an IMG, this can happen when someone selects an image in the visual-selector
# Tests fetcher can throw a "ReplyWithContentButNoText" exception after applying filter and extracting text
def test_filter_is_empty_help_suggestion(client, live_server):
def test_filter_is_empty_help_suggestion(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
include_filters = "#blob-a"

@ -106,7 +106,7 @@ across multiple lines
)
def test_element_removal_full(client, live_server):
def test_element_removal_full(client, live_server, measure_memory_usage):
sleep_time_for_fetch_thread = 3
set_original_response()

@ -24,7 +24,7 @@ def set_html_response():
# In the case the server does not issue a charset= or doesnt have content_type header set
def test_check_encoding_detection(client, live_server):
def test_check_encoding_detection(client, live_server, measure_memory_usage):
set_html_response()
# Add our URL to the import page
@ -50,7 +50,7 @@ def test_check_encoding_detection(client, live_server):
# In the case the server does not issue a charset= or doesnt have content_type header set
def test_check_encoding_detection_missing_content_type_header(client, live_server):
def test_check_encoding_detection_missing_content_type_header(client, live_server, measure_memory_usage):
set_html_response()
# Add our URL to the import page

@ -54,7 +54,7 @@ def _runner_test_http_errors(client, live_server, http_code, expected_text):
assert b'Deleted' in res.data
def test_http_error_handler(client, live_server):
def test_http_error_handler(client, live_server, measure_memory_usage):
_runner_test_http_errors(client, live_server, 403, 'Access denied')
_runner_test_http_errors(client, live_server, 404, 'Page not found')
_runner_test_http_errors(client, live_server, 500, '(Internal server error) received')
@ -63,7 +63,7 @@ def test_http_error_handler(client, live_server):
assert b'Deleted' in res.data
# Just to be sure error text is properly handled
def test_DNS_errors(client, live_server):
def test_DNS_errors(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
time.sleep(1)
@ -87,7 +87,7 @@ def test_DNS_errors(client, live_server):
assert b'Deleted' in res.data
# Re 1513
def test_low_level_errors_clear_correctly(client, live_server):
def test_low_level_errors_clear_correctly(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# Give the endpoint time to spin up
time.sleep(1)

@ -9,7 +9,7 @@ sleep_time_for_fetch_thread = 3
def test_check_extract_text_from_diff(client, live_server):
def test_check_extract_text_from_diff(client, live_server, measure_memory_usage):
import time
with open("test-datastore/endpoint-content.txt", "w") as f:
f.write("Now it's {} seconds since epoch, time flies!".format(str(time.time())))

@ -67,10 +67,10 @@ def set_multiline_response():
return None
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_check_filter_multiline(client, live_server):
def test_check_filter_multiline(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_multiline_response()
@ -122,7 +122,7 @@ def test_check_filter_multiline(client, live_server):
# but the last one, which also says 'lines' shouldnt be here (non-greedy match checking)
assert b'aaand something lines' not in res.data
def test_check_filter_and_regex_extract(client, live_server):
def test_check_filter_and_regex_extract(client, live_server, measure_memory_usage):
include_filters = ".changetext"
@ -205,7 +205,7 @@ def test_check_filter_and_regex_extract(client, live_server):
def test_regex_error_handling(client, live_server):
def test_regex_error_handling(client, live_server, measure_memory_usage):
#live_server_setup(live_server)

@ -41,7 +41,7 @@ def set_response_with_filter():
f.write(test_return_data)
return None
def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_server):
def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_server, measure_memory_usage):
# Filter knowingly doesn't exist, like someone setting up a known filter to see if some cinema tickets are on sale again
# And the page has that filter available
# Then I should get a notification

@ -151,10 +151,10 @@ def run_filter_test(client, live_server, content_filter):
def test_setup(live_server):
live_server_setup(live_server)
def test_check_include_filters_failure_notification(client, live_server):
def test_check_include_filters_failure_notification(client, live_server, measure_memory_usage):
run_filter_test(client, live_server,'#nope-doesnt-exist')
def test_check_xpath_filter_failure_notification(client, live_server):
def test_check_xpath_filter_failure_notification(client, live_server, measure_memory_usage):
run_filter_test(client, live_server, '//*[@id="nope-doesnt-exist"]')
# Test that notification is never sent

@ -6,7 +6,7 @@ from .util import live_server_setup, wait_for_all_checks, extract_rss_token_from
import os
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def set_original_response():
@ -39,7 +39,7 @@ def set_modified_response():
f.write(test_return_data)
return None
def test_setup_group_tag(client, live_server):
def test_setup_group_tag(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_original_response()
@ -130,7 +130,7 @@ def test_setup_group_tag(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_tag_import_singular(client, live_server):
def test_tag_import_singular(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
test_url = url_for('test_endpoint', _external=True)
@ -150,7 +150,7 @@ def test_tag_import_singular(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_tag_add_in_ui(client, live_server):
def test_tag_add_in_ui(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
#
res = client.post(
@ -167,7 +167,7 @@ def test_tag_add_in_ui(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_group_tag_notification(client, live_server):
def test_group_tag_notification(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_original_response()
@ -235,7 +235,7 @@ def test_group_tag_notification(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_limit_tag_ui(client, live_server):
def test_limit_tag_ui(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
test_url = url_for('test_endpoint', _external=True)
@ -273,7 +273,7 @@ def test_limit_tag_ui(client, live_server):
assert b'Deleted' in res.data
res = client.get(url_for("tags.delete_all"), follow_redirects=True)
assert b'All tags deleted' in res.data
def test_clone_tag_on_import(client, live_server):
def test_clone_tag_on_import(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
test_url = url_for('test_endpoint', _external=True)
res = client.post(
@ -298,7 +298,7 @@ def test_clone_tag_on_import(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_clone_tag_on_quickwatchform_add(client, live_server):
def test_clone_tag_on_quickwatchform_add(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
test_url = url_for('test_endpoint', _external=True)
@ -328,7 +328,7 @@ def test_clone_tag_on_quickwatchform_add(client, live_server):
res = client.get(url_for("tags.delete_all"), follow_redirects=True)
assert b'All tags deleted' in res.data
def test_order_of_filters_tag_filter_and_watch_filter(client, live_server):
def test_order_of_filters_tag_filter_and_watch_filter(client, live_server, measure_memory_usage):
# Add a tag with some config, import a tag and it should roughly work
res = client.post(

@ -8,7 +8,7 @@ from flask import url_for
from .util import live_server_setup, wait_for_all_checks
from urllib.parse import urlparse, parse_qs
def test_consistent_history(client, live_server):
def test_consistent_history(client, live_server, measure_memory_usage):
live_server_setup(live_server)
r = range(1, 30)

@ -82,7 +82,7 @@ def set_modified_ignore_response():
f.write(test_return_data)
def test_check_ignore_text_functionality(client, live_server):
def test_check_ignore_text_functionality(client, live_server, measure_memory_usage):
# Use a mix of case in ZzZ to prove it works case-insensitive.
ignore_text = "XXXXX\r\nYYYYY\r\nzZzZZ\r\nnew ignore stuff"
@ -164,7 +164,7 @@ def test_check_ignore_text_functionality(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_check_global_ignore_text_functionality(client, live_server):
def test_check_global_ignore_text_functionality(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
time.sleep(1)

@ -23,7 +23,7 @@ def set_original_ignore_response():
f.write(test_return_data)
def test_highlight_ignore(client, live_server):
def test_highlight_ignore(client, live_server, measure_memory_usage):
live_server_setup(live_server)
set_original_ignore_response()
test_url = url_for('test_endpoint', _external=True)

@ -40,7 +40,7 @@ def set_modified_ignore_response():
with open("test-datastore/endpoint-content.txt", "w") as f:
f.write(test_return_data)
def test_render_anchor_tag_content_true(client, live_server):
def test_render_anchor_tag_content_true(client, live_server, measure_memory_usage):
"""Testing that the link changes are detected when
render_anchor_tag_content setting is set to true"""
sleep_time_for_fetch_thread = 3

@ -39,7 +39,7 @@ def set_some_changed_response():
f.write(test_return_data)
def test_normal_page_check_works_with_ignore_status_code(client, live_server):
def test_normal_page_check_works_with_ignore_status_code(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
@ -85,7 +85,7 @@ def test_normal_page_check_works_with_ignore_status_code(client, live_server):
# Tests the whole stack works with staus codes ignored
def test_403_page_check_works_with_ignore_status_code(client, live_server):
def test_403_page_check_works_with_ignore_status_code(client, live_server, measure_memory_usage):
sleep_time_for_fetch_thread = 3
set_original_response()

@ -49,7 +49,7 @@ def set_original_ignore_response():
# If there was only a change in the whitespacing, then we shouldnt have a change detected
def test_check_ignore_whitespace(client, live_server):
def test_check_ignore_whitespace(client, live_server, measure_memory_usage):
sleep_time_for_fetch_thread = 3
# Give the endpoint time to spin up

@ -8,10 +8,10 @@ from flask import url_for
from .util import live_server_setup, wait_for_all_checks
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_import(client, live_server):
def test_import(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
wait_for_all_checks(client)
@ -34,7 +34,7 @@ https://example.com tag1, other tag"""
res = client.get( url_for("index"))
res = client.get( url_for("index"))
def xtest_import_skip_url(client, live_server):
def xtest_import_skip_url(client, live_server, measure_memory_usage):
# Give the endpoint time to spin up
@ -57,7 +57,7 @@ def xtest_import_skip_url(client, live_server):
# Clear flask alerts
res = client.get( url_for("index"))
def test_import_distillio(client, live_server):
def test_import_distillio(client, live_server, measure_memory_usage):
distill_data='''
{
@ -123,7 +123,7 @@ def test_import_distillio(client, live_server):
# Clear flask alerts
res = client.get(url_for("index"))
def test_import_custom_xlsx(client, live_server):
def test_import_custom_xlsx(client, live_server, measure_memory_usage):
"""Test can upload a excel spreadsheet and the watches are created correctly"""
#live_server_setup(live_server)
@ -172,7 +172,7 @@ def test_import_custom_xlsx(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_import_watchete_xlsx(client, live_server):
def test_import_watchete_xlsx(client, live_server, measure_memory_usage):
"""Test can upload a excel spreadsheet and the watches are created correctly"""
#live_server_setup(live_server)

@ -5,11 +5,11 @@ from flask import url_for
from .util import live_server_setup, wait_for_all_checks
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# If there was only a change in the whitespacing, then we shouldnt have a change detected
def test_jinja2_in_url_query(client, live_server):
def test_jinja2_in_url_query(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# Add our URL to the import page
@ -34,7 +34,7 @@ def test_jinja2_in_url_query(client, live_server):
assert b'date=2' in res.data
# https://techtonics.medium.com/secure-templating-with-jinja2-understanding-ssti-and-jinja2-sandbox-environment-b956edd60456
def test_jinja2_security_url_query(client, live_server):
def test_jinja2_security_url_query(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# Add our URL to the import page

@ -201,7 +201,7 @@ def set_modified_response():
return None
def test_check_json_without_filter(client, live_server):
def test_check_json_without_filter(client, live_server, measure_memory_usage):
# Request a JSON document from a application/json source containing HTML
# and be sure it doesn't get chewed up by instriptis
set_json_response_with_html()
@ -294,14 +294,14 @@ def check_json_filter(json_filter, client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_check_jsonpath_filter(client, live_server):
def test_check_jsonpath_filter(client, live_server, measure_memory_usage):
check_json_filter('json:boss.name', client, live_server)
def test_check_jq_filter(client, live_server):
def test_check_jq_filter(client, live_server, measure_memory_usage):
if jq_support:
check_json_filter('jq:.boss.name', client, live_server)
def test_check_jqraw_filter(client, live_server):
def test_check_jqraw_filter(client, live_server, measure_memory_usage):
if jq_support:
check_json_filter('jqraw:.boss.name', client, live_server)
@ -352,14 +352,14 @@ def check_json_filter_bool_val(json_filter, client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_check_jsonpath_filter_bool_val(client, live_server):
def test_check_jsonpath_filter_bool_val(client, live_server, measure_memory_usage):
check_json_filter_bool_val("json:$['available']", client, live_server)
def test_check_jq_filter_bool_val(client, live_server):
def test_check_jq_filter_bool_val(client, live_server, measure_memory_usage):
if jq_support:
check_json_filter_bool_val("jq:.available", client, live_server)
def test_check_jqraw_filter_bool_val(client, live_server):
def test_check_jqraw_filter_bool_val(client, live_server, measure_memory_usage):
if jq_support:
check_json_filter_bool_val("jq:.available", client, live_server)
@ -430,7 +430,7 @@ def check_json_ext_filter(json_filter, client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_ignore_json_order(client, live_server):
def test_ignore_json_order(client, live_server, measure_memory_usage):
# A change in order shouldn't trigger a notification
with open("test-datastore/endpoint-content.txt", "w") as f:
@ -472,7 +472,7 @@ def test_ignore_json_order(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_correct_header_detect(client, live_server):
def test_correct_header_detect(client, live_server, measure_memory_usage):
# Like in https://github.com/dgtlmoon/changedetection.io/pull/1593
# Specify extra html that JSON is sometimes wrapped in - when using SockpuppetBrowser / Puppeteer / Playwrightetc
with open("test-datastore/endpoint-content.txt", "w") as f:
@ -504,13 +504,13 @@ def test_correct_header_detect(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_check_jsonpath_ext_filter(client, live_server):
def test_check_jsonpath_ext_filter(client, live_server, measure_memory_usage):
check_json_ext_filter('json:$[?(@.status==Sold)]', client, live_server)
def test_check_jq_ext_filter(client, live_server):
def test_check_jq_ext_filter(client, live_server, measure_memory_usage):
if jq_support:
check_json_ext_filter('jq:.[] | select(.status | contains("Sold"))', client, live_server)
def test_check_jqraw_ext_filter(client, live_server):
def test_check_jqraw_ext_filter(client, live_server, measure_memory_usage):
if jq_support:
check_json_ext_filter('jq:.[] | select(.status | contains("Sold"))', client, live_server)

@ -22,7 +22,7 @@ def set_nonrenderable_response():
return None
def test_check_basic_change_detection_functionality(client, live_server):
def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage):
set_original_response()
live_server_setup(live_server)

@ -21,7 +21,7 @@ def test_setup(live_server):
# Hard to just add more live server URLs when one test is already running (I think)
# So we add our test here (was in a different file)
def test_check_notification(client, live_server):
def test_check_notification(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_original_response()
@ -234,7 +234,7 @@ def test_check_notification(client, live_server):
follow_redirects=True
)
def test_notification_validation(client, live_server):
def test_notification_validation(client, live_server, measure_memory_usage):
time.sleep(1)
@ -273,7 +273,7 @@ def test_notification_validation(client, live_server):
def test_notification_custom_endpoint_and_jinja2(client, live_server):
def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# test_endpoint - that sends the contents of a file

@ -4,7 +4,7 @@ from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
import logging
def test_check_notification_error_handling(client, live_server):
def test_check_notification_error_handling(client, live_server, measure_memory_usage):
live_server_setup(live_server)
set_original_response()

@ -18,7 +18,7 @@ def set_original_ignore_response():
f.write(test_return_data)
def test_obfuscations(client, live_server):
def test_obfuscations(client, live_server, measure_memory_usage):
set_original_ignore_response()
live_server_setup(live_server)
time.sleep(1)

@ -6,7 +6,7 @@ from .util import set_original_response, set_modified_response, live_server_setu
# `subtractive_selectors` should still work in `source:` type requests
def test_fetch_pdf(client, live_server):
def test_fetch_pdf(client, live_server, measure_memory_usage):
import shutil
shutil.copy("tests/test.pdf", "test-datastore/endpoint-test.pdf")

@ -9,7 +9,7 @@ def test_setup(live_server):
# Hard to just add more live server URLs when one test is already running (I think)
# So we add our test here (was in a different file)
def test_headers_in_request(client, live_server):
def test_headers_in_request(client, live_server, measure_memory_usage):
#ve_server_setup(live_server)
# Add our URL to the import page
test_url = url_for('test_headers', _external=True)
@ -84,7 +84,7 @@ def test_headers_in_request(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_body_in_request(client, live_server):
def test_body_in_request(client, live_server, measure_memory_usage):
# Add our URL to the import page
test_url = url_for('test_body', _external=True)
@ -177,7 +177,7 @@ def test_body_in_request(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_method_in_request(client, live_server):
def test_method_in_request(client, live_server, measure_memory_usage):
# Add our URL to the import page
test_url = url_for('test_method', _external=True)
if os.getenv('PLAYWRIGHT_DRIVER_URL'):
@ -254,7 +254,7 @@ def test_method_in_request(client, live_server):
assert b'Deleted' in res.data
# Re #2408 - user-agent override test, also should handle case-insensitive header deduplication
def test_ua_global_override(client, live_server):
def test_ua_global_override(client, live_server, measure_memory_usage):
# live_server_setup(live_server)
test_url = url_for('test_headers', _external=True)
@ -309,7 +309,7 @@ def test_ua_global_override(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_headers_textfile_in_request(client, live_server):
def test_headers_textfile_in_request(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
# Add our URL to the import page

@ -49,10 +49,10 @@ def set_original_cdata_xml():
f.write(test_return_data)
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_rss_and_token(client, live_server):
def test_rss_and_token(client, live_server, measure_memory_usage):
# live_server_setup(live_server)
set_original_response()
@ -90,7 +90,7 @@ def test_rss_and_token(client, live_server):
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_basic_cdata_rss_markup(client, live_server):
def test_basic_cdata_rss_markup(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_original_cdata_xml()
@ -118,7 +118,7 @@ def test_basic_cdata_rss_markup(client, live_server):
assert b'The days of Terminator' in res.data
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_rss_xpath_filtering(client, live_server):
def test_rss_xpath_filtering(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_original_cdata_xml()

@ -5,7 +5,7 @@ import time
def test_setup(live_server):
live_server_setup(live_server)
def test_basic_search(client, live_server):
def test_basic_search(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
urls = ['https://localhost:12300?first-result=1',
@ -38,7 +38,7 @@ def test_basic_search(client, live_server):
assert urls[1].encode('utf-8') not in res.data
def test_search_in_tag_limit(client, live_server):
def test_search_in_tag_limit(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
urls = ['https://localhost:12300?first-result=1 tag-one',

@ -2,10 +2,10 @@ from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
import time
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_bad_access(client, live_server):
def test_bad_access(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
res = client.post(
url_for("import_page"),
@ -67,7 +67,7 @@ def test_bad_access(client, live_server):
assert b'file:// type access is denied for security reasons.' in res.data
def test_xss(client, live_server):
def test_xss(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
from changedetectionio.notification import (
default_notification_format

@ -9,7 +9,7 @@ import re
sleep_time_for_fetch_thread = 3
def test_share_watch(client, live_server):
def test_share_watch(client, live_server, measure_memory_usage):
set_original_response()
live_server_setup(live_server)

@ -10,7 +10,7 @@ sleep_time_for_fetch_thread = 3
def test_setup(live_server):
live_server_setup(live_server)
def test_check_basic_change_detection_functionality_source(client, live_server):
def test_check_basic_change_detection_functionality_source(client, live_server, measure_memory_usage):
set_original_response()
test_url = 'source:'+url_for('test_endpoint', _external=True)
# Add our URL to the import page
@ -58,7 +58,7 @@ def test_check_basic_change_detection_functionality_source(client, live_server):
# `subtractive_selectors` should still work in `source:` type requests
def test_check_ignore_elements(client, live_server):
def test_check_ignore_elements(client, live_server, measure_memory_usage):
set_original_response()
time.sleep(1)
test_url = 'source:'+url_for('test_endpoint', _external=True)

@ -55,7 +55,7 @@ def set_modified_with_trigger_text_response():
f.write(test_return_data)
def test_trigger_functionality(client, live_server):
def test_trigger_functionality(client, live_server, measure_memory_usage):
live_server_setup(live_server)

@ -22,7 +22,7 @@ def set_original_ignore_response():
def test_trigger_regex_functionality(client, live_server):
def test_trigger_regex_functionality(client, live_server, measure_memory_usage):
live_server_setup(live_server)

@ -22,7 +22,7 @@ def set_original_ignore_response():
def test_trigger_regex_functionality_with_filter(client, live_server):
def test_trigger_regex_functionality_with_filter(client, live_server, measure_memory_usage):
live_server_setup(live_server)
sleep_time_for_fetch_thread = 3

@ -66,10 +66,10 @@ def set_modified_with_trigger_text_response():
with open("test-datastore/endpoint-content.txt", "w") as f:
f.write(test_return_data)
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
def test_unique_lines_functionality(client, live_server):
def test_unique_lines_functionality(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
@ -118,7 +118,7 @@ def test_unique_lines_functionality(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_sort_lines_functionality(client, live_server):
def test_sort_lines_functionality(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
set_modified_swapped_lines_with_extra_text_for_sorting()

@ -4,7 +4,7 @@ from urllib.request import urlopen
from . util import set_original_response, set_modified_response, live_server_setup
def test_check_watch_field_storage(client, live_server):
def test_check_watch_field_storage(client, live_server, measure_memory_usage):
set_original_response()
live_server_setup(live_server)

@ -49,7 +49,7 @@ def set_modified_response():
# Handle utf-8 charset replies https://github.com/dgtlmoon/changedetection.io/pull/613
def test_check_xpath_filter_utf8(client, live_server):
def test_check_xpath_filter_utf8(client, live_server, measure_memory_usage):
filter = '//item/*[self::description]'
d = '''<?xml version="1.0" encoding="UTF-8"?>
@ -105,7 +105,7 @@ def test_check_xpath_filter_utf8(client, live_server):
# Handle utf-8 charset replies https://github.com/dgtlmoon/changedetection.io/pull/613
def test_check_xpath_text_function_utf8(client, live_server):
def test_check_xpath_text_function_utf8(client, live_server, measure_memory_usage):
filter = '//item/title/text()'
d = '''<?xml version="1.0" encoding="UTF-8"?>
@ -168,7 +168,7 @@ def test_check_xpath_text_function_utf8(client, live_server):
assert b'Deleted' in res.data
def test_check_markup_xpath_filter_restriction(client, live_server):
def test_check_markup_xpath_filter_restriction(client, live_server, measure_memory_usage):
xpath_filter = "//*[contains(@class, 'sametext')]"
set_original_response()
@ -214,7 +214,7 @@ def test_check_markup_xpath_filter_restriction(client, live_server):
assert b'Deleted' in res.data
def test_xpath_validation(client, live_server):
def test_xpath_validation(client, live_server, measure_memory_usage):
# Add our URL to the import page
test_url = url_for('test_endpoint', _external=True)
res = client.post(
@ -235,7 +235,7 @@ def test_xpath_validation(client, live_server):
assert b'Deleted' in res.data
def test_xpath23_prefix_validation(client, live_server):
def test_xpath23_prefix_validation(client, live_server, measure_memory_usage):
# Add our URL to the import page
test_url = url_for('test_endpoint', _external=True)
res = client.post(
@ -255,7 +255,7 @@ def test_xpath23_prefix_validation(client, live_server):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_xpath1_lxml(client, live_server):
def test_xpath1_lxml(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
d = '''<?xml version="1.0" encoding="UTF-8"?>
@ -319,7 +319,7 @@ def test_xpath1_lxml(client, live_server):
#####
def test_xpath1_validation(client, live_server):
def test_xpath1_validation(client, live_server, measure_memory_usage):
# Add our URL to the import page
test_url = url_for('test_endpoint', _external=True)
res = client.post(
@ -341,7 +341,7 @@ def test_xpath1_validation(client, live_server):
# actually only really used by the distll.io importer, but could be handy too
def test_check_with_prefix_include_filters(client, live_server):
def test_check_with_prefix_include_filters(client, live_server, measure_memory_usage):
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
@ -378,7 +378,7 @@ def test_check_with_prefix_include_filters(client, live_server):
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_various_rules(client, live_server):
def test_various_rules(client, live_server, measure_memory_usage):
# Just check these don't error
# live_server_setup(live_server)
with open("test-datastore/endpoint-content.txt", "w") as f:
@ -426,7 +426,7 @@ def test_various_rules(client, live_server):
assert b'Deleted' in res.data
def test_xpath_20(client, live_server):
def test_xpath_20(client, live_server, measure_memory_usage):
test_url = url_for('test_endpoint', _external=True)
res = client.post(
url_for("import_page"),
@ -463,7 +463,7 @@ def test_xpath_20(client, live_server):
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_xpath_20_function_count(client, live_server):
def test_xpath_20_function_count(client, live_server, measure_memory_usage):
set_original_response()
# Add our URL to the import page
@ -499,7 +499,7 @@ def test_xpath_20_function_count(client, live_server):
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_xpath_20_function_count2(client, live_server):
def test_xpath_20_function_count2(client, live_server, measure_memory_usage):
set_original_response()
# Add our URL to the import page
@ -535,7 +535,7 @@ def test_xpath_20_function_count2(client, live_server):
client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
def test_xpath_20_function_string_join_matches(client, live_server):
def test_xpath_20_function_string_join_matches(client, live_server, measure_memory_usage):
set_original_response()
# Add our URL to the import page

@ -4,12 +4,12 @@ import os
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
def test_setup(client, live_server):
def test_setup(client, live_server, measure_memory_usage):
live_server_setup(live_server)
# Add a site in paused mode, add an invalid filter, we should still have visual selector data ready
def test_visual_selector_content_ready(client, live_server):
def test_visual_selector_content_ready(client, live_server, measure_memory_usage):
import os
import json
@ -79,7 +79,7 @@ def test_visual_selector_content_ready(client, live_server):
follow_redirects=True
)
def test_basic_browserstep(client, live_server):
def test_basic_browserstep(client, live_server, measure_memory_usage):
#live_server_setup(live_server)
assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test"

Loading…
Cancel
Save