diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-09-16 16:19:09 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-09-16 16:19:09 +0200 |
commit | 12764a020a4171eee738b1e2a8a3d5340f4da7a1 (patch) | |
tree | f84833d8e1967db93e78e3dda7f1675178929ad1 /scenarios/fragments | |
parent | b95db09b96d6a901004fdf3ccccc98e297c9102d (diff) | |
download | mknet-12764a020a4171eee738b1e2a8a3d5340f4da7a1.tar.gz mknet-12764a020a4171eee738b1e2a8a3d5340f4da7a1.zip |
Fix prepare script
Diffstat (limited to 'scenarios/fragments')
-rw-r--r-- | scenarios/fragments/flavor.py | 35 | ||||
-rw-r--r-- | scenarios/fragments/garage.py | 51 | ||||
-rw-r--r-- | scenarios/fragments/warp.py | 9 |
3 files changed, 48 insertions, 47 deletions
diff --git a/scenarios/fragments/flavor.py b/scenarios/fragments/flavor.py new file mode 100644 index 0000000..68c1f55 --- /dev/null +++ b/scenarios/fragments/flavor.py @@ -0,0 +1,35 @@ +from pathlib import Path +from . import shared +from os.path import exists + +def add_path(d): + for flav, desc in d.items(): + if "path" in desc: continue + binary = f"garage-{desc['target']}-{desc['version']}" + desc['path'] = Path(shared.binary_path) / binary + return d + +garage = add_path({ + "garage-local": { "path": "./garage/target/release/garage" }, + "garage-v0.7": { + "version": "v0.7.3", + "target": "x86_64-unknown-linux-musl", + }, + "garage-v0.8": { "version": "89b8087ba81c508ba382aa6c9cb6bb3afa6a43c8", "target": "x86_64-unknown-linux-musl" }, +}) + +warp = { + "warp-fast": "mixed --obj.size 5M --objects 200 --duration=1m", + "warp-default": "mixed" +} + + +def download(): + for flav, desc in garage.items(): + if "version" not in desc: continue + if exists(desc['path']): continue + + shared.exec(f"mkdir -p {shared.binary_path}") + shared.exec(f"wget https://garagehq.deuxfleurs.fr/_releases/{version['version']}/{version['target']}/garage -O {p}") + shared.exec(f"chmod +x {p}") + shared.exec(f"{p} --version") diff --git a/scenarios/fragments/garage.py b/scenarios/fragments/garage.py index d0d5209..c1e09d0 100644 --- a/scenarios/fragments/garage.py +++ b/scenarios/fragments/garage.py @@ -2,18 +2,15 @@ import glob, json, time from os.path import exists from os import environ as env from pathlib import Path -from . import shared - -try: - import garage_admin_sdk - from garage_admin_sdk.api import nodes_api, layout_api, key_api - from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo - from garage_admin_sdk.model.layout_version import LayoutVersion - from garage_admin_sdk.model.add_key_request import AddKeyRequest - from garage_admin_sdk.model.update_key_request import UpdateKeyRequest - from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow -except: - pass +from . import shared, flavor + +import garage_admin_sdk +from garage_admin_sdk.api import nodes_api, layout_api, key_api +from garage_admin_sdk.model.node_cluster_info import NodeClusterInfo +from garage_admin_sdk.model.layout_version import LayoutVersion +from garage_admin_sdk.model.add_key_request import AddKeyRequest +from garage_admin_sdk.model.update_key_request import UpdateKeyRequest +from garage_admin_sdk.model.update_key_request_allow import UpdateKeyRequestAllow storage_path = "./i/am/not/defined" rpc_secret = "3e9abff5f9e480afbadb46a77b7a26fe0e404258f0dc3fd5386b0ba8e0ad2fba" @@ -21,12 +18,7 @@ metrics = "cacce0b2de4bc2d9f5b5fdff551e01ac1496055aed248202d415398987e35f81" admin = "ae8cb40ea7368bbdbb6430af11cca7da833d3458a5f52086f4e805a570fb5c2a" key = None -version_flavor = { - "garage-local": { "path": "./garage/target/release/garage" }, - "garage-v0.7": { "version": "v0.7.3", "target": "x86_64-unknown-linux-musl" }, - "garage-v0.8": { "version": "89b8087ba81c508ba382aa6c9cb6bb3afa6a43c8", "target": "x86_64-unknown-linux-musl" }, -} -version = version_flavor["garage-v0.7"] +version = flavor.garage["garage-v0.7"] configuration = garage_admin_sdk.Configuration( host = "http://localhost:3903/v0", @@ -66,27 +58,6 @@ def deploy_follow(version=None, target=None): sync_on_key_up() shared.log("ready") -def path(vers=None): - if vers is None: - vers = version - - if "path" in vers: return vers["path"] - else: - binary = f"garage-{vers['target']}-{vers['version']}" - return Path(shared.binary_path) / binary - -def download(): - for flav, version in version_flavor.items(): - if "path" in version: continue - - p = path(vers=version) - if exists(p): continue - - shared.exec(f"mkdir -p {shared.binary_path}") - shared.exec(f"wget https://garagehq.deuxfleurs.fr/_releases/{version['version']}/{version['target']}/garage -O {p}") - shared.exec(f"chmod +x {p}") - shared.exec(f"{p} --version") - def daemon(): shared.exec(f"mkdir -p {storage_path}") with open(config, 'w+') as f: @@ -118,7 +89,7 @@ metrics_token = "{metrics}" admin_token = "{admin}" """) - shared.exec(f"{path()} server 2>> {storage_path}/logs.stderr 1>> {storage_path}/logs.stdout & echo $! > {storage_path}/daemon.pid") + shared.exec(f"{version['path']} server 2>> {storage_path}/logs.stderr 1>> {storage_path}/logs.stdout & echo $! > {storage_path}/daemon.pid") time.sleep(1) node_info = storage_path / "node_info" diff --git a/scenarios/fragments/warp.py b/scenarios/fragments/warp.py index 721c604..0c5acc8 100644 --- a/scenarios/fragments/warp.py +++ b/scenarios/fragments/warp.py @@ -1,15 +1,10 @@ import os from os.path import exists from pathlib import Path -from fragments import shared, garage +from fragments import shared, garage, flavor warp_bin = Path(os.path.dirname(__file__)) / "../../benchmarks/warp/warp" - -bench_flavor = { - "warp-fast": "mixed --obj.size 5M --objects 200 --duration=1m", - "warp-default": "mixed" -} -bench = warp_bench_flavor["warp-fast"] +bench = flavor.warp["warp-fast"] def on_garage(params="mixed"): shared.log(f"launching warp {warp_bin}") |