mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-10-30 14:17:40 +00:00
Fix paths
This commit is contained in:
@@ -23,20 +23,9 @@ sleep 5
|
||||
## 2nd test actually choose the preferred proxy from proxies.json
|
||||
# This will force a request via "proxy-two"
|
||||
docker run --network changedet-network \
|
||||
-v `pwd`/tests/proxy_list/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json \
|
||||
-v `pwd`/tests/proxy_list/proxies.json-example:/tmp/proxies.json \
|
||||
test-changedetectionio \
|
||||
bash -c 'echo here is the proxy list; cat /app/changedetectionio/test-datastore/proxies.json; cd changedetectionio && pytest -s tests/proxy_list/test_multiple_proxy.py'
|
||||
|
||||
echo "----------------- SQUID PROXY ONE LOGS -------------"
|
||||
docker logs squid-one
|
||||
echo "----------------- SQUID PROXY TWO LOGS -------------"
|
||||
docker logs squid-two
|
||||
echo "----- DNS debug output --------"
|
||||
docker run --network changedet-network test-changedetectionio getent hosts squid-one squid-two
|
||||
echo "------------------------------------------------------"
|
||||
|
||||
echo "docker ps output"
|
||||
docker ps
|
||||
bash -c 'cd changedetectionio && pytest -s tests/proxy_list/test_multiple_proxy.py -d /tmp'
|
||||
|
||||
set +e
|
||||
echo "- Looking for chosen.changedetection.io request in squid-one - it should NOT be here"
|
||||
|
||||
@@ -97,16 +97,39 @@ def cleanup(datastore_path):
|
||||
if os.path.isfile(f):
|
||||
os.unlink(f)
|
||||
|
||||
def pytest_addoption(parser):
|
||||
"""Add custom command-line options for pytest.
|
||||
|
||||
Mirrors main app's -d flag with --datastore-path for consistency.
|
||||
"""
|
||||
parser.addoption(
|
||||
"-d", "--datastore-path",
|
||||
action="store",
|
||||
default=None,
|
||||
help="Custom datastore path for tests (mirrors main app's -d flag)"
|
||||
)
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def datastore_path(tmp_path_factory, request):
|
||||
"""Provide datastore path unique to this worker.
|
||||
|
||||
Supports custom path via --datastore-path/-d flag (mirrors main app).
|
||||
|
||||
CRITICAL for xdist isolation:
|
||||
- Each WORKER gets its own directory
|
||||
- Tests on same worker run SEQUENTIALLY and cleanup between tests
|
||||
- No subdirectories needed since tests don't overlap on same worker
|
||||
- Example: /tmp/test-datastore-gw0/ for worker gw0
|
||||
"""
|
||||
# Check for custom path first (mirrors main app's -d flag)
|
||||
custom_path = request.config.getoption("--datastore-path")
|
||||
if custom_path:
|
||||
# Ensure the directory exists
|
||||
os.makedirs(custom_path, exist_ok=True)
|
||||
logger.info(f"Using custom datastore path: {custom_path}")
|
||||
return custom_path
|
||||
|
||||
# Otherwise use default tmp_path_factory logic
|
||||
worker_id = getattr(request.config, 'workerinput', {}).get('workerid', 'master')
|
||||
if worker_id == 'master':
|
||||
path = tmp_path_factory.mktemp("test-datastore")
|
||||
|
||||
Reference in New Issue
Block a user