Fix prepare script

This commit is contained in:
Quentin 2022-09-16 16:19:09 +02:00
parent b95db09b96
commit 12764a020a
Signed by: quentin
GPG key ID: E9602264D639FF68
6 changed files with 61 additions and 60 deletions

View file

@ -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

View file

@ -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")

View file

@ -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
from . import shared, flavor
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
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"

View file

@ -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}")

View file

@ -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)

View file

@ -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: