Skip to content

Commit 7cb67cd

Browse files
authored
Merge branch 'dev' into 855-refactor-benchmark-yml
2 parents e8c154a + 6442184 commit 7cb67cd

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Benchmark machine
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
docker_tag:
7+
description: The tag of docker image to pull
8+
default: 'latest'
9+
required: true
10+
11+
env:
12+
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }} # remote AWS host to run benchmarking
13+
BENCHMARK_SSH_USER: ${{ secrets.BENCHMARK_SSH_USER }}
14+
BENCHMARK_SSH_KEYPATH: ${{ secrets.BENCHMARK_SSH_KEYPATH }}
15+
16+
jobs:
17+
## run the benchmarking remotely
18+
benchmark-machine:
19+
runs-on: self-hosted
20+
steps:
21+
- name: Checkout codes on ${{ github.ref }}
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
# TODO: maybe use GHA to start/stop remote instance
27+
- name: Start remote instance
28+
timeout-minutes: 10
29+
id: start_instance
30+
run: |
31+
aws ec2 start-instances --instance-ids ${{ env.INSTANCE_ID }}
32+
sleep 5
33+
instance_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].InstanceStatus.Status' --output text"
34+
system_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].SystemStatus.Status' --output text"
35+
SECONDS=0
36+
while : ; do
37+
if [ "$(eval $instance_status)" = "ok" ] && [ "$(eval $system_status)" = "ok" ]; then
38+
break
39+
else
40+
sleep 20
41+
fi
42+
done
43+
echo "Remote instance reachable now after $SECONDS seconds"
44+
remote_ip=`aws ec2 describe-instances --filters 'Name=instance-state-name,Values=running' 'Name=instance-id,Values=${{ env.INSTANCE_ID }}' --query 'Reservations[*].Instances[*].[PublicIpAddress]' --output text`
45+
echo "Running instances ip address: $remote_ip"
46+
echo "::set-output name=remote_ip::$remote_ip"
47+
48+
# exit status should propagate through ssh
49+
- name: Remotely benchmark machine
50+
timeout-minutes: 10
51+
run: |
52+
echo "Running instances ip address: ${{ steps.start_instance.outputs.remote_ip }}"
53+
ssh -x -o StrictHostKeychecking=no "${{ steps.start_instance.outputs.remote_ip }}" -l ${{ env.BENCHMARK_SSH_USER }} -i ${{ env.BENCHMARK_SSH_KEYPATH }} \
54+
docker pull litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} && \
55+
docker run --rm litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} benchmark machine --chain=litmus-dev
56+
57+
- name: Stop remote instance
58+
if: always()
59+
run: |
60+
aws ec2 stop-instances --instance-ids ${{ env.INSTANCE_ID }}
61+
sleep 5
62+
ret=`aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} | jq '.InstanceStatuses[0].InstanceState.Name'`
63+
echo "Remote instance running state: $ret"

node/src/command.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,15 @@ pub fn run() -> Result<()> {
375375
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
376376
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
377377
}),
378+
#[cfg(not(feature = "runtime-benchmarks"))]
379+
BenchmarkCmd::Storage(_) =>
380+
return Err(sc_cli::Error::Input(
381+
"Compile with --features=runtime-benchmarks \
382+
to enable storage benchmarks."
383+
.into(),
384+
)
385+
.into()),
386+
#[cfg(feature = "runtime-benchmarks")]
378387
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
379388
construct_benchmark_partials!(config, |partials| {
380389
let db = partials.backend.expose_db();

0 commit comments

Comments
 (0)