summaryrefslogtreecommitdiff
path: root/subplot/server.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-02-06 18:03:49 +0200
committerLars Wirzenius <liw@liw.fi>2021-02-06 18:16:45 +0200
commit61aca01941d3bdf324a207f2b53dbf7128169142 (patch)
tree861aa3b61e16e2a486c61eabf1bf2e27a223679e /subplot/server.py
parentad98db921aa3d710ad7c448c6a1b818f4359d73a (diff)
downloadobnam2-61aca01941d3bdf324a207f2b53dbf7128169142.tar.gz
test: add scenario for checking chunk-size
Diffstat (limited to 'subplot/server.py')
-rw-r--r--subplot/server.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/subplot/server.py b/subplot/server.py
index 289e181..df594f7 100644
--- a/subplot/server.py
+++ b/subplot/server.py
@@ -5,8 +5,6 @@ import random
import re
import requests
import shutil
-import socket
-import time
import urllib3
import yaml
@@ -35,7 +33,9 @@ def start_chunk_server(ctx):
"address": f"localhost:{port}",
}
- server_binary = os.path.abspath(os.path.join(srcdir, "target", "debug", "obnam-server"))
+ server_binary = os.path.abspath(
+ os.path.join(srcdir, "target", "debug", "obnam-server")
+ )
filename = "config.yaml"
yaml.safe_dump(config, stream=open(filename, "w"))
@@ -44,11 +44,7 @@ def start_chunk_server(ctx):
ctx["server_url"] = f"https://{config['address']}"
daemon_start_on_port(
- ctx,
- name="obnam-server",
- path=server_binary,
- args=filename,
- port=port,
+ ctx, name="obnam-server", path=server_binary, args=filename, port=port
)
@@ -138,6 +134,15 @@ def json_body_matches(ctx, wanted=None):
assert_eq(body.get(key, "not.there"), wanted[key])
+def server_has_n_file_chunks(ctx, n=None):
+ assert_eq = globals()["assert_eq"]
+ n = int(n)
+ url = f"{ctx['server_url']}/chunks?data=true"
+ _request(ctx, requests.get, url)
+ num_chunks = len(ctx["http.json"])
+ assert_eq(n, num_chunks)
+
+
# Make an HTTP request.
def _request(ctx, method, url, headers=None, data=None):
r = method(url, headers=headers, data=data, verify=False)