-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/enhance-management-of-custom-docker-im…
…ages
- Loading branch information
Showing
8 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM golang:1.21 AS polycli-builder | ||
ARG POLYCLI_VERSION | ||
WORKDIR /opt/polygon-cli | ||
RUN git clone --branch ${POLYCLI_VERSION} https://github.com/maticnetwork/polygon-cli.git . \ | ||
&& CGO_ENABLED=0 go build -o polycli main.go | ||
|
||
|
||
FROM ubuntu:22.04 | ||
LABEL author="[email protected]" | ||
LABEL description="Helper image capable of executing diverse workloads" | ||
|
||
COPY --from=polycli-builder /opt/polygon-cli/polycli /usr/bin/polycli | ||
# WARNING (DL3008): Pin versions in apt get install. | ||
# WARNING (DL4006): Set the SHELL option -o pipefail before RUN with a pipe in it | ||
# WARNING (SC1091): (Sourced) file not included in mock. | ||
# hadolint ignore=DL3008,DL4006,SC1091 | ||
RUN apt-get update \ | ||
&& apt-get install --yes --no-install-recommends curl jq git python3-pip \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& pip3 install yq \ | ||
&& curl --silent --location --proto "=https" https://foundry.paradigm.xyz | bash \ | ||
&& /root/.foundry/bin/foundryup \ | ||
&& cp /root/.foundry/bin/* /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Applying workload..." | ||
while true; do | ||
# shellcheck disable=SC1054,SC1083 | ||
{{range .commands}} | ||
# shellcheck disable=SC1054,SC1083 | ||
{{.}} & | ||
# shellcheck disable=SC1056,SC1072,SC1073,SC1009 | ||
{{end}} | ||
sleep 120 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Check if the required arguments are provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <mode>" | ||
exit 1 | ||
fi | ||
|
||
mode="$1" | ||
requests=100 | ||
concurrency=1 | ||
rpc_url="{{.rpc_url}}" | ||
|
||
echo "Running polycli loadtest (rpc_url=$rpc_url mode=$mode requests=$requests concurrency=$concurrency)..." | ||
# shellcheck disable=SC1083,SC2086 | ||
polycli loadtest \ | ||
--rpc-url "$rpc_url" \ | ||
--chain-id {{.chain_id}} \ | ||
--private-key "{{.private_key}}" \ | ||
--verbosity 700 \ | ||
--mode "$mode" \ | ||
--requests "$requests" \ | ||
--concurrency "$concurrency" \ | ||
{{if .send_legacy_tx}}--legacy{{end}} \ | ||
2>$1 | awk -v mode="$mode" -v url="$rpc_url" '{print "loadtest-" mode "-" url " " $0}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Running polycli rpcfuzz (rpc_url={{.rpc_url}})..." | ||
polycli rpcfuzz \ | ||
--rpc-url "{{.rpc_url}}" \ | ||
--private-key "{{.private_key}}" \ | ||
2>&1 | awk '{print "[rpcfuzz] " $0}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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. | ||
), | ||
) |