diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-05-29 11:39:31 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-05-29 15:02:31 +0300 |
commit | e839c5f1c93e1fe024a2656d319721a7b23c6461 (patch) | |
tree | 3828b84f7e46d8f9976d1a828e8625e22f79c84a /subplot | |
parent | 03a8b0f9cba08ad09cb8494579f6e318aee762f4 (diff) | |
download | obnam2-e839c5f1c93e1fe024a2656d319721a7b23c6461.tar.gz |
refactor: count chunks via file system, not via chunk server API
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/server.py | 18 | ||||
-rw-r--r-- | subplot/server.yaml | 4 |
2 files changed, 15 insertions, 7 deletions
diff --git a/subplot/server.py b/subplot/server.py index df594f7..cfe91ab 100644 --- a/subplot/server.py +++ b/subplot/server.py @@ -134,13 +134,21 @@ 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): +def server_has_n_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) + files = find_files(ctx["config"]["chunks"]) + files = [json.load(open(x)) for x in files if x.endswith(".meta")] + logging.debug(f"server_has_n_file_chunks: n={n}") + logging.debug(f"server_has_n_file_chunks: len(files)={len(files)}") + logging.debug(f"server_has_n_file_chunks: files={files}") + assert_eq(n, len(files)) + + +def find_files(root): + for dirname, _, names in os.walk(root): + for name in names: + yield os.path.join(dirname, name) # Make an HTTP request. diff --git a/subplot/server.yaml b/subplot/server.yaml index 60f8a44..5b8a242 100644 --- a/subplot/server.yaml +++ b/subplot/server.yaml @@ -44,5 +44,5 @@ - then: "the body matches file {filename}" function: body_matches_file -- then: "server has {n:int} file chunks" - function: server_has_n_file_chunks +- then: "server has {n:int} chunks" + function: server_has_n_chunks |