forked from thTNT/LAIR3-BDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkload.star
51 lines (50 loc) · 1.96 KB
/
workload.star
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def run(plan, args):
# Create scripts artifacts.
apply_workload_template = read_file(src="./templates/workload/apply_workload.sh")
polycli_loadtest_template = read_file(
src="./templates/workload/polycli_loadtest.sh"
)
polycli_rpcfuzz_template = read_file(src="./templates/workload/polycli_rpcfuzz.sh")
zkevm_rpc_service = plan.get_service("zkevm-node-rpc" + args["deployment_suffix"])
zkevm_rpc_url = "http://{}:{}".format(
zkevm_rpc_service.ip_address, zkevm_rpc_service.ports["http-rpc"].number
)
workload_script_artifact = plan.render_templates(
name="workload-script-artifact",
config={
"apply_workload.sh": struct(
template=apply_workload_template,
data={
"commands": args["workload_commands"],
},
),
"polycli_loadtest_on_l2.sh": struct(
template=polycli_loadtest_template,
data={
"rpc_url": zkevm_rpc_url,
"chain_id": args["zkevm_rollup_chain_id"],
"private_key": args["zkevm_l2_admin_private_key"],
"send_legacy_tx": True,
},
),
"polycli_rpcfuzz_on_l2.sh": struct(
template=polycli_rpcfuzz_template,
data={
"rpc_url": zkevm_rpc_url,
"private_key": args["zkevm_l2_admin_private_key"],
},
),
},
)
plan.add_service(
name="workload" + args["deployment_suffix"],
config=ServiceConfig(
image=args["workload_image"],
files={
"/usr/local/bin": Directory(artifact_names=[workload_script_artifact]),
},
entrypoint=["bash", "-c"],
cmd=["chmod +x /usr/local/bin/*.sh && apply_workload.sh"],
user=User(uid=0, gid=0), # Run the container as root user.
),
)