Skip to content

Commit

Permalink
ci: Fixes to benchmarks in cloud (#10626)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi authored Aug 30, 2024
1 parent a20c915 commit 15f311c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-destroy-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Destroy Benchmark Env

on:
schedule:
- cron: '0 1 * * *'
- cron: '0 4 * * *'
workflow_dispatch:

permissions:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/benchmark-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
tenant-id: ${{ env.ARM_TENANT_ID }}
subscription-id: ${{ env.ARM_SUBSCRIPTION_ID }}

- name: Destroy any existing environment
run: pnpm destroy-cloud-env
working-directory: packages/@n8n/benchmark

- name: Run the benchmark with debug logging
if: github.event.inputs.debug == 'true'
run: pnpm benchmark-in-cloud --n8nTag ${{ inputs.n8n_tag || 'nightly' }} --benchmarkTag ${{ inputs.benchmark_tag || 'latest' }} --debug
Expand Down
2 changes: 0 additions & 2 deletions packages/@n8n/benchmark/infra/modules/benchmark-vm/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ variable "ssh_public_key" {

variable "vm_size" {
description = "VM Size"
# 8 vCPUs, 32 GiB memory
default = "Standard_DC8_v2"
}

variable "tags" {
Expand Down
4 changes: 2 additions & 2 deletions packages/@n8n/benchmark/infra/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ variable "host_size_family" {

variable "vm_size" {
description = "VM Size"
# 2 vCPUs, 8 GiB memory
default = "Standard_DC2s_v2"
# 8 vCPUs, 32 GiB memory
default = "Standard_DC8_v2"
}

variable "number_of_vms" {
Expand Down
20 changes: 18 additions & 2 deletions packages/@n8n/benchmark/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ set -euo pipefail;
CURRENT_USER=$(whoami)

# Mount the data disk
# First wait for the disk to become available
WAIT_TIME=0
MAX_WAIT_TIME=60

while [ ! -e /dev/sdc ]; do
if [ $WAIT_TIME -ge $MAX_WAIT_TIME ]; then
echo "Error: /dev/sdc did not become available within $MAX_WAIT_TIME seconds."
exit 1
fi

echo "Waiting for /dev/sdc to be available... ($WAIT_TIME/$MAX_WAIT_TIME)"
sleep 1
WAIT_TIME=$((WAIT_TIME + 1))
done

# Then mount it
if [ -d "/n8n" ]; then
echo "Data disk already mounted. Clearing it..."
sudo rm -rf /n8n/*
Expand All @@ -28,8 +44,8 @@ curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh

# Install docker, docker compose and nodejs
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose nodejs
sudo DEBIAN_FRONTEND=noninteractive apt-get update -yq
sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq docker.io docker-compose nodejs

# Add the current user to the docker group
sudo usermod -aG docker "$CURRENT_USER"
Expand Down
2 changes: 2 additions & 0 deletions packages/@n8n/benchmark/scripts/runForN8nSetup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ async function main() {

const runDir = path.join(baseRunDir, n8nSetupToUse);
fs.emptyDirSync(runDir);
// Make sure the n8n container user (node) has write permissions to the run directory
await $`chmod 777 ${runDir}`;

const dockerComposeClient = new DockerComposeClient({
$: $({
Expand Down
4 changes: 1 addition & 3 deletions packages/@n8n/benchmark/scripts/runInCloud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ async function ensureVmIsReachable(sshClient) {
* @returns Path where the scripts are located on the VM
*/
async function transferScriptsToVm(sshClient) {
await sshClient.ssh('rm -rf ~/n8n');

await sshClient.ssh('git clone --depth=1 https://github.com/n8n-io/n8n.git');
await sshClient.ssh('rm -rf ~/n8n && git clone --depth=1 https://github.com/n8n-io/n8n.git');

return '~/n8n/packages/@n8n/benchmark/scripts';
}

0 comments on commit 15f311c

Please sign in to comment.