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

ci: fix benchmark workflow #25

Merged
merged 1 commit into from
Jul 22, 2024
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
26 changes: 18 additions & 8 deletions .github/workflows/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Mask AWS Credentials
uses: actions/github-script@v7
with:
script: |
core.setSecret(context.payload.inputs.aws_access_key)
core.setSecret(context.payload.inputs.aws_secret_access_key)
- name: Configure AWS Credentials
run: |
mkdir -p ~/.aws
Expand All @@ -32,43 +38,47 @@ jobs:
aws_access_key_id = ${{ github.event.inputs.aws_access_key }}
aws_secret_access_key = ${{ github.event.inputs.aws_secret_access_key }}
EOF

cat <<EOF > ~/.aws/config
[default]
region = us-west-2
EOF
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.inputs.ref }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: 1.6.4
terraform_wrapper: false
- name: Create infrastructure
id: create_infra
timeout-minutes: 30
run: |
terraform init
terraform apply -var spec_file=tests/${{ github.event.inputs.scenario }}.yaml -auto-approve
terraform output -json | scripts/output2md.sh >> $GITHUB_STEP_SUMMARY
terraform output -raw bench_id >> $GITHUB_OUTPUT
terraform apply -var spec_file=tests/${{ github.event.inputs.scenario }}.yaml -auto-approve -lock=false
echo "ssh_key_path=$(terraform output -raw ssh_key_path)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: success()
with:
name: ssh_private_key
path: |
"~/.ssh/${{ steps.create_infra.outputs.bench_id }}.pem"
${{ steps.create_infra.outputs.ssh_key_path }}
- name: Run benchmark
timeout-minutes: 60
run: |
ansible loadgen -m command -a 'systemctl start loadgen' --become
sleep ${{ github.event.inputs.duration }}
sleep $((${{ github.event.inputs.duration }} * 60))
ansible loadgen -m command -a 'systemctl stop loadgen' --become
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Metrics" >> $GITHUB_STEP_SUMMARY
echo "## Benchmark metrics" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
scripts/fetch-metrics.sh >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: terraform destroy
if: always()
run: |
terraform destroy -var spec_file=tests/${{ github.event.inputs.scenario }}.yaml -auto-approve
terraform destroy -var spec_file=tests/${{ github.event.inputs.scenario }}.yaml -auto-approve
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: failure()
with:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ ansible-playbook ansible/emqtt-bench.yml
ansible-playbook ansible/emqx.yml -e '{"cache_enabled": true, "topics": ["t/a"]}'
```

To ssh directly into instances, use terraform output to get IP addresses, and generated ssh private key in `.ssh` directory, for example:
To ssh directly into instances, use terraform output to get IP addresses, and generated ssh private key, for example:

```bash
ssh -l ubuntu -i ~/.ssh/foobar.pem 52.53.191.91
ssh -l ubuntu -i ./foobar.pem 52.53.191.91
# generic ssh one-liner to connect to the first emqx node
ssh -l ubuntu -i $(terraform output -raw ssh_key_path) $(terraform output -json emqx_nodes | jq -r '.[0].ip')
# open dashboard in the browser (macos only)
Expand Down Expand Up @@ -227,7 +227,7 @@ function bm-ssh() {

```
function bm-urls() {
echo "dashboard: http://$(terraform output -raw emqx_dashboard_url)"
echo "grafana: http://$(terraform output -raw grafana_url)"
echo "dashboard: $(terraform output -raw emqx_dashboard_url)"
echo "grafana: $(terraform output -raw grafana_url)"
}
```
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ locals {
prefix = local.bench_id
route53_zone_name = replace("${local.prefix}.emqx.io", "/", "-")
ssh_key_name = local.prefix
ssh_key_path = pathexpand(format("~/.ssh/%s.pem", replace(local.ssh_key_name, "/", "-")))
ssh_key_path = pathexpand(format("./%s.pem", replace(local.ssh_key_name, "/", "-")))

region = try(local.spec.region, "eu-north-1")
instance_type = try(local.spec.instance_type, "t3.large")
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ output "bench_id" {

output "emqx_dashboard_url" {
description = "EMQX Dashboard URL"
value = "${module.public_nlb.dns_name}:18083"
value = "http://${module.public_nlb.dns_name}:18083"
}

output "grafana_url" {
description = "Grafana URL"
value = local.monitoring_enabled ? "${module.public_nlb.dns_name}:3000" : null
value = local.monitoring_enabled ? "http://${module.public_nlb.dns_name}:3000" : null
}

output "prometheus_url" {
description = "Prometheus URL"
value = local.monitoring_enabled ? "${module.public_nlb.dns_name}:9090" : null
value = local.monitoring_enabled ? "http://${module.public_nlb.dns_name}:9090" : null
}

output "locust_url" {
Expand Down
44 changes: 0 additions & 44 deletions scripts/output2md.sh

This file was deleted.