Enable cpu profiling for ui tests (#9149)
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2025-06-02 17:56:17 +07:00 committed by GitHub
parent d5919f3de9
commit 51cc82b175
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 67 additions and 27 deletions

View File

@ -261,26 +261,26 @@ jobs:
run: |
cd ./tests/sanity
node ../../common/scripts/install-run-rushx.js ci
# - name: Start profiling
# run: |
# cd ./tests
# ./profile-start.sh
- name: Start profiling
run: |
cd ./tests
./profile-start.sh
- name: Run UI tests
run: |
cd ./tests/sanity
node ../../common/scripts/install-run-rushx.js uitest
# - name: Download profile
# run: |
# cd ./tests
# ./profile-download.sh
# npm install -g cpupro
# ./profile-generate.sh
# - name: Upload profiling results
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: profiling
# path: ./tests/profiles
- name: Download profile
run: |
cd ./tests
./profile-download.sh
npm install -g cpupro
./profile-generate.sh
- name: Upload profiling results
if: always()
uses: actions/upload-artifact@v4
with:
name: profiling
path: ./tests/profiles
- name: 'Store docker logs'
if: always()
run: |
@ -390,10 +390,26 @@ jobs:
run: |
cd ./tests/sanity
node ../../common/scripts/install-run-rushx.js ci
- name: Start profiling
run: |
cd ./tests
./profile-start.sh
- name: Run UI tests
run: |
cd ./tests/sanity
node ../../common/scripts/install-run-rushx.js uitest
- name: Download profile
run: |
cd ./tests
./profile-download.sh
npm install -g cpupro
./profile-generate.sh
- name: Upload profiling results
if: always()
uses: actions/upload-artifact@v4
with:
name: profiling-pg
path: ./tests/profiles
- name: 'Store docker logs'
if: always()
run: |
@ -589,7 +605,7 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Configure docker
uses: crazy-max/ghaction-setup-docker@v3
uses: docker/setup-docker-action@v4
with:
daemon-config: |
{

View File

@ -110,6 +110,9 @@ import { performGmailAccountMigrations } from './gmail'
import { getToolToken, getWorkspace, getWorkspaceTransactorEndpoint } from './utils'
import { createRestClient } from '@hcengineering/api-client'
import { mkdir, writeFile } from 'fs/promises'
import { basename, dirname } from 'path'
import { existsSync } from 'fs'
const colorConstants = {
colorRed: '\u001b[31m',
@ -1682,6 +1685,33 @@ export function devTool (
)
})
})
program
.command('profile <endpoint> <mode>')
.description('Enable or disable profiling')
.option('-o, --output <output>', 'Output file', 'profile.cpuprofile')
.action(async (endpoint: string, mode: string, opt: { output: string }) => {
const token = generateToken(systemAccountUuid, '' as WorkspaceUuid, { admin: 'true' })
if (mode === 'start') {
await fetch(`${endpoint}/api/v1/manage?token=${token}&operation=profile-start`, {
method: 'PUT'
})
} else {
const resp = await fetch(`${endpoint}/api/v1/manage?token=${token}&operation=profile-stop`, {
method: 'PUT'
})
if (resp.ok) {
const bdir = dirname(opt.output)
if (!existsSync(bdir)) {
await mkdir(bdir, { recursive: true })
}
const bytes = await resp.arrayBuffer()
console.log('writing to', opt.output)
await writeFile(opt.output, new Uint8Array(bytes))
} else {
console.error('failed to stop profile', resp.headers)
}
}
})
program
.command('generate-persons <workspace>')

View File

@ -1,5 +1,3 @@
echo "Downloading profile"
token=$(./tool.sh generate-token --admin anticrm@hc.engineering sanity-ws)
current=$(date +%Y%m%d%H%M%S)
mkdir -p ./profiles
curl -X PUT "http://localhost:3334/api/v1/manage?token=${token}&operation=profile-stop" -o "./profiles/profile-${current}".cpuprofile
./tool.sh profile http://localhost:3334 stop -o "./profiles/profile-${current}".cpuprofile

View File

@ -1,3 +1,2 @@
echo "Start profiling on server"
token=$(./tool.sh generate-token --admin anticrm@hc.engineering sanity-ws)
curl -X PUT "http://localhost:3334/api/v1/manage?token=${token}&operation=profile-start"
./tool.sh profile http://localhost:3334 start

View File

@ -1,5 +1,3 @@
echo "Downloading profile"
token=$(./tool.sh generate-token --admin anticrm@hc.engineering sanity-ws)
current=$(date +%Y%m%d%H%M%S)
mkdir -p ./profiles
curl -X PUT "http://huly.local:3334/api/v1/manage?token=${token}&operation=profile-stop" -o "./profiles/profile-${current}".cpuprofile
./tool.sh profile http://localhost:3335 stop -o "./profiles/profile-${current}".cpuprofile

View File

@ -1,3 +1,2 @@
echo "Start profiling on server"
token=$(./tool.sh generate-token --admin anticrm@hc.engineering sanity-ws)
curl -X PUT "http://huly.local:3334/api/v1/manage?token=${token}&operation=profile-start"
./tool-europe.sh profile http://localhost:3335 start