Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to run benchmark on remote server #248

Merged
merged 5 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 8 additions & 29 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,14 @@ jobs:
- name: checkout
uses: actions/checkout@v2

- name: get tag
run: |
git fetch --tags
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "TAG_NAME=$latest_tag" >> $GITHUB_ENV
- name: decode secret key
run: echo ${{ secrets.RUNNER_SECRET_KEY }} | base64 -d > secret && chmod 600 secret

- name: Set up terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
terraform_wrapper: false
- name: mkdir ${{ github.run_number }}
run: ssh ubuntu@${{ secrets.RUNNER_IP }} -i secret "mkdir ${{ github.run_number }}"

- name: setup
run: ./setup.sh ${{ env.TAG_NAME }} ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} ${{ secrets.GCP_PROJECT_ID }}
working-directory: ./benchmark_src/
- name: clone QuickMPC
run: ssh ubuntu@${{ secrets.RUNNER_IP }} -i secret "cd ${{ github.run_number }} && git clone https://github.com/acompany-develop/QuickMPC"

- name: create gcp instance
run: terraform init && terraform plan && terraform apply --auto-approve && terraform output -json > ../application/output.json
working-directory: ./demo/terraform/gcp

- name: deploy quickmpc
run: terraform init && terraform plan && terraform apply --auto-approve && terraform output -json > ../../../benchmark_src/terraform/output.json
working-directory: ./demo/terraform/application

- name: benchmark test
run: terraform init && terraform plan && terraform apply --auto-approve
working-directory: ./benchmark_src/terraform

- if: always()
name: post-processing
run: terraform destroy --auto-approve
working-directory: ./demo/terraform/gcp
- name: run benchmark
run: ssh ubuntu@${{ secrets.RUNNER_IP }} -i secret "nohup bash -c \"cd ${{ github.run_number }}/QuickMPC/benchmark_src; chmod +x benchamrk_runner.sh; ./benchmark_runner.sh ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} ${{ secrets.GCP_PROJECT_ID }} ${{ github.run_number }} ${{ secrets.SLACK_CHANNEL_ID }} ${{ secrets.SLACK_API_TOKEN }}; sudo rm -r ~/${{ github.run_number }}\" &> /home/ubuntu/log/runner-${{ github.run_number }}.log; &"
38 changes: 38 additions & 0 deletions benchmark_src/benchmark_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e
trap finally EXIT

gcp_service_account_key=$1
gcp_project_id=$2
runner_id=$3
channel_id=$4
slack_token=$5
SCRIPT_DIR=$(cd $(dirname $0); pwd)

git fetch --tags
latest_tag=$(git tag --list | grep -E '[0-9]+\.[0-9]+\.[0-9]+' | tail -1)

function finally() {
# logをslackに送信
# 更新日 2023/06/30
curl -F initial_comment="QuickMPC version: $latest_tag \`\`\`$( sed -n '/test_print_result/,$p' /home/ubuntu/log/result-$runner_id.log | sed 's/\[[0-9][0-9]*m//g')\`\`\`" -F file=@/home/ubuntu/log/result-$runner_id.log -F channels=$channel_id -H "Authorization: Bearer $slack_token" https://slack.com/api/files.upload
KotaTakahashi9320 marked this conversation as resolved.
Show resolved Hide resolved
# post processing
# NOTE: `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`の回避のためknown_hostsを毎回削除する
rm ~/.ssh/known_hosts
KotaTakahashi9320 marked this conversation as resolved.
Show resolved Hide resolved
cd $SCRIPT_DIR/../demo/terraform/gcp
terraform destroy --auto-approve
}

./setup.sh $latest_tag $gcp_service_account_key $gcp_project_id

# Create GCP instance
cd ../demo/terraform/gcp
terraform init && terraform plan && terraform apply --auto-approve && terraform output -json > ../application/output.json

# Deploy quickmpc
cd ../application
terraform init && terraform plan && terraform apply --auto-approve && terraform output -json > ../../../benchmark_src/terraform/output.json

#Run benchmark test
cd ../../../benchmark_src/terraform
terraform init && terraform plan && terraform apply --auto-approve > /home/ubuntu/log/result-$runner_id.log