summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-07-19 10:47:38 +0300
committerLars Wirzenius <liw@liw.fi>2020-07-19 10:50:12 +0300
commit50a778a59366b19ba1e94ca9d7f0ac9ff55f54a2 (patch)
tree5bccd3420b2bdf59c9c4df1424d9868cec25df0e
parentf03e530c0062ede2cd2a8bb915b6cedadd51a2a0 (diff)
downloadewww-50a778a59366b19ba1e94ca9d7f0ac9ff55f54a2.tar.gz
test: add logging to ewww.py
-rw-r--r--ewww.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/ewww.py b/ewww.py
index 76f27ac..ded5064 100644
--- a/ewww.py
+++ b/ewww.py
@@ -2,6 +2,7 @@
# Some helpers to make step functions simpler.
import json
+import logging
import os
import random
import re
@@ -62,6 +63,7 @@ def fixme(*args, **kwargs):
# Create a file.
def create_file(ctx, filename=None, content=None):
+ logging.debug(f"Creating file {filename} with {content}")
dirname = os.path.dirname(filename)
os.makedirs(dirname)
_write(filename, content)
@@ -70,15 +72,18 @@ def create_file(ctx, filename=None, content=None):
# Copy test certificate from source tree, where it's been created previously by
# ./check.
def copy_test_certificate(ctx, cert=None, key=None):
+ logging.debug(f"Copying test.pem, test.key from srcdir to {cert} and {key}")
shutil.copy(os.path.join(srcdir, "test.pem"), cert)
shutil.copy(os.path.join(srcdir, "test.key"), key)
# Start server using named configuration file.
def start_server(ctx, filename=None):
+ logging.debug(f"Starting ewww with config file {filename}")
config = get_file(filename).decode("UTF-8")
config = yaml.safe_load(config)
config["port"] = random.randint(2000, 30000)
+ logging.debug(f"Picked randomly port for ewww: {config['port']}")
ctx["config"] = config
config = yaml.safe_dump(config)
_write(filename, config)
@@ -88,10 +93,12 @@ def start_server(ctx, filename=None):
# Stop previously started server.
def stop_server(ctx):
+ logging.debug("Stopping ewww")
stop_daemon(ctx, "ewww")
# Make an HTTP request.
def request(ctx, method=None, url=None):
+ logging.debug(f"Making HTTP request to ewww: {method} {url}")
url, host = _url(ctx, url)
http_request(ctx, host=host, method=method, url=url)