aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-09-16 16:19:09 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-09-16 16:19:09 +0200
commit12764a020a4171eee738b1e2a8a3d5340f4da7a1 (patch)
treef84833d8e1967db93e78e3dda7f1675178929ad1
parentb95db09b96d6a901004fdf3ccccc98e297c9102d (diff)
downloadmknet-12764a020a4171eee738b1e2a8a3d5340f4da7a1.tar.gz
mknet-12764a020a4171eee738b1e2a8a3d5340f4da7a1.zip
Fix prepare script
-rwxr-xr-xprepare.py6
-rw-r--r--scenarios/fragments/flavor.py35
-rw-r--r--scenarios/fragments/garage.py51
-rw-r--r--scenarios/fragments/warp.py9
-rwxr-xr-xscenarios/garage-s3lat8
-rwxr-xr-xscenarios/garage-warp14
6 files changed, 62 insertions, 61 deletions
diff --git a/prepare.py b/prepare.py
index d902c65..60d58c1 100755
--- a/prepare.py
+++ b/prepare.py
@@ -25,9 +25,9 @@ python3 -m pip install .
python3 -m pip install -r scenarios/requirements.txt
""")
-print("--- download garage artifacts ---")
-from scenarios.fragments import garage
-garage.download()
+print("--- download artifacts ---")
+from scenarios.fragments import flavor
+flavor.download()
print("""done! now, run:
> sudo -i
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}")
diff --git a/scenarios/garage-s3lat b/scenarios/garage-s3lat
index 0307cc7..b0a8d0d 100755
--- a/scenarios/garage-s3lat
+++ b/scenarios/garage-s3lat
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
-from fragments import garage, s3lat, shared
+from fragments import garage, s3lat, shared, flavor
import sys
-for flavor in sys.argv[1:]:
- if flavor in garage.version_flavor:
- garage.version = garage.version_flavor[flavor]
+for fl in sys.argv[1:]:
+ if fl in flavor.garage:
+ garage.version = flavor.garage[fl]
if shared.id() == 1:
garage.deploy_coord(version=garage.version)
diff --git a/scenarios/garage-warp b/scenarios/garage-warp
index 3d80c79..5d338c0 100755
--- a/scenarios/garage-warp
+++ b/scenarios/garage-warp
@@ -1,16 +1,16 @@
#!/usr/bin/env python3
-from fragments import garage, warp, shared
+from fragments import garage, warp, shared, flavor
import sys
-for flavor in sys.argv[1:]:
- if flavor in garage.version_flavor:
- garage.version = garage.version_flavor[flavor]
- if flavor in warp.bench_flavor:
- warp.bench = warp.bench_flavor[flavor]
+for fl in sys.argv[1:]:
+ if fl in flavor.garage:
+ garage.version = flavor.garage[fl]
+ if fl in flavor.warp:
+ warp.bench = flavor.warp[fl]
if shared.id() == 1:
garage.deploy_coord(version=garage.version)
- warp.on_garage(params=warp_bench)
+ warp.on_garage(params=warp.bench)
garage.delete_key()
garage.destroy()
else: