From 1d89ffcc2d2b6cfd959e27d70ef5ebb500e6b959 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 24 Feb 2022 17:21:56 -0800 Subject: [PATCH] Update mock-server, upload ci logs on failure --- .github/workflows/benchmark.yml | 12 ++++++++++++ .github/workflows/ci.yml | 10 +++++++++- package.json | 2 +- ts/test-mock/benchmarks/convo_open_bench.ts | 12 +++++++++++- ts/test-mock/benchmarks/fixtures.ts | 19 ++++++++++++++++++- ts/test-mock/benchmarks/group_send_bench.ts | 4 ++++ ts/test-mock/benchmarks/send_bench.ts | 12 +++++++++++- ts/test-mock/benchmarks/startup_bench.ts | 5 ++++- ts/test-mock/bootstrap.ts | 9 +++++++++ yarn.lock | 8 ++++---- 10 files changed, 83 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 98974e22266e..3d18ba08b847 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -13,6 +13,7 @@ jobs: linux: runs-on: ubuntu-latest if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' }} + timeout-minutes: 30 steps: - name: Get system specs @@ -62,6 +63,7 @@ jobs: NODE_ENV: production RUN_COUNT: 10 ELECTRON_ENABLE_STACK_DUMPING: on + ARTIFACTS_DIR: artifacts/startup - name: Run send benchmarks run: | @@ -74,6 +76,7 @@ jobs: NODE_ENV: production RUN_COUNT: 100 ELECTRON_ENABLE_STACK_DUMPING: on + ARTIFACTS_DIR: artifacts/send - name: Run group send benchmarks run: | @@ -87,6 +90,7 @@ jobs: NODE_ENV: production RUN_COUNT: 100 ELECTRON_ENABLE_STACK_DUMPING: on + ARTIFACTS_DIR: artifacts/group-send - name: Run conversation open benchmarks run: | @@ -100,6 +104,14 @@ jobs: NODE_ENV: production RUN_COUNT: 100 ELECTRON_ENABLE_STACK_DUMPING: on + ARTIFACTS_DIR: artifacts/convo-open + + - name: Upload benchmark logs on failure + if: failure() + uses: actions/upload-artifact@v2 + with: + name: logs + path: artifacts - name: Clone benchmark repo uses: actions/checkout@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89982b854dff..6e9a98baf596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ on: jobs: lint: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - run: lsb_release -a @@ -42,6 +43,7 @@ jobs: needs: lint runs-on: macos-11.0 if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' + timeout-minutes: 30 steps: - run: uname -a @@ -70,6 +72,7 @@ jobs: run: yarn electron:install-app-deps - run: yarn test-node - run: yarn test-electron + timeout-minutes: 5 - run: yarn test-release env: NODE_ENV: production @@ -77,6 +80,7 @@ jobs: linux: needs: lint runs-on: ubuntu-latest + timeout-minutes: 30 steps: - run: lsb_release -a @@ -105,6 +109,7 @@ jobs: DISABLE_INSPECT_FUSE: on - run: xvfb-run --auto-servernum yarn test-node - run: xvfb-run --auto-servernum yarn test-electron + timeout-minutes: 5 env: LANG: en_US LANGUAGE: en_US @@ -114,7 +119,8 @@ jobs: windows: needs: lint - runs-on: windows-latest + runs-on: windows-2019 + timeout-minutes: 30 steps: - run: systeminfo @@ -146,6 +152,7 @@ jobs: env: DISABLE_INSPECT_FUSE: on - run: yarn test-electron + timeout-minutes: 5 - run: yarn test-release env: SIGNAL_ENV: production @@ -154,6 +161,7 @@ jobs: needs: lint runs-on: ubuntu-latest if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' }} + timeout-minutes: 30 steps: - name: Get system specs diff --git a/package.json b/package.json index e99627ed3147..b45d446fd670 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,7 @@ "@babel/preset-typescript": "7.16.0", "@chanzuckerberg/axe-storybook-testing": "3.0.2", "@electron/fuses": "1.5.0", - "@signalapp/mock-server": "1.1.0", + "@signalapp/mock-server": "1.1.1", "@storybook/addon-actions": "5.1.11", "@storybook/addon-knobs": "5.1.11", "@storybook/addons": "5.1.11", diff --git a/ts/test-mock/benchmarks/convo_open_bench.ts b/ts/test-mock/benchmarks/convo_open_bench.ts index 1c4bf77767af..cf8f98071cc0 100644 --- a/ts/test-mock/benchmarks/convo_open_bench.ts +++ b/ts/test-mock/benchmarks/convo_open_bench.ts @@ -4,7 +4,14 @@ import type { PrimaryDevice } from '@signalapp/mock-server'; -import { Bootstrap, debug, stats, RUN_COUNT, DISCARD_COUNT } from './fixtures'; +import { + Bootstrap, + debug, + saveLogs, + stats, + RUN_COUNT, + DISCARD_COUNT, +} from './fixtures'; const CONVERSATION_SIZE = 1000; // messages const DELAY = 50; // milliseconds @@ -94,6 +101,9 @@ const DELAY = 50; // milliseconds }; await Promise.all([sendQueue(), measure()]); + } catch (error) { + await saveLogs(bootstrap); + throw error; } finally { await app.close(); await bootstrap.teardown(); diff --git a/ts/test-mock/benchmarks/fixtures.ts b/ts/test-mock/benchmarks/fixtures.ts index 48c1c038453a..33ceffb5f2d5 100644 --- a/ts/test-mock/benchmarks/fixtures.ts +++ b/ts/test-mock/benchmarks/fixtures.ts @@ -3,10 +3,14 @@ /* eslint-disable no-await-in-loop, no-console */ import createDebug from 'debug'; +import fs from 'fs/promises'; +import path from 'path'; + +import { Bootstrap } from '../bootstrap'; export const debug = createDebug('mock:benchmarks'); -export { Bootstrap } from '../bootstrap'; +export { Bootstrap }; export { App } from '../playwright'; export type StatsType = { @@ -59,6 +63,19 @@ export function stats( return result; } +export async function saveLogs(bootstrap: Bootstrap): Promise { + const { ARTIFACTS_DIR } = process.env; + if (!ARTIFACTS_DIR) { + console.error('Not saving logs. Please set ARTIFACTS_DIR env variable'); + return; + } + + await fs.mkdir(ARTIFACTS_DIR, { recursive: true }); + + const { logsDir } = bootstrap; + await fs.rename(logsDir, path.join(ARTIFACTS_DIR, 'logs')); +} + // Can happen if electron exits prematurely process.on('unhandledRejection', reason => { console.error('Unhandled rejection:'); diff --git a/ts/test-mock/benchmarks/group_send_bench.ts b/ts/test-mock/benchmarks/group_send_bench.ts index e9c765bd6768..0f2a640687fb 100644 --- a/ts/test-mock/benchmarks/group_send_bench.ts +++ b/ts/test-mock/benchmarks/group_send_bench.ts @@ -12,6 +12,7 @@ import { import { Bootstrap, debug, + saveLogs, stats, RUN_COUNT, GROUP_SIZE, @@ -177,6 +178,9 @@ const LAST_MESSAGE = 'start sending messages now'; } console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) }); + } catch (error) { + await saveLogs(bootstrap); + throw error; } finally { await app.close(); await bootstrap.teardown(); diff --git a/ts/test-mock/benchmarks/send_bench.ts b/ts/test-mock/benchmarks/send_bench.ts index 14c39ca14e92..a4c9992299f3 100644 --- a/ts/test-mock/benchmarks/send_bench.ts +++ b/ts/test-mock/benchmarks/send_bench.ts @@ -6,7 +6,14 @@ import assert from 'assert'; import { ReceiptType } from '@signalapp/mock-server'; -import { Bootstrap, debug, stats, RUN_COUNT, DISCARD_COUNT } from './fixtures'; +import { + Bootstrap, + debug, + saveLogs, + stats, + RUN_COUNT, + DISCARD_COUNT, +} from './fixtures'; const CONVERSATION_SIZE = 500; // messages @@ -128,6 +135,9 @@ const LAST_MESSAGE = 'start sending messages now'; } console.log('stats info=%j', { delta: stats(deltaList, [99, 99.8]) }); + } catch (error) { + await saveLogs(bootstrap); + throw error; } finally { await app.close(); await bootstrap.teardown(); diff --git a/ts/test-mock/benchmarks/startup_bench.ts b/ts/test-mock/benchmarks/startup_bench.ts index 2f0b4e1238a0..b164e5b23c2f 100644 --- a/ts/test-mock/benchmarks/startup_bench.ts +++ b/ts/test-mock/benchmarks/startup_bench.ts @@ -4,7 +4,7 @@ import { ReceiptType } from '@signalapp/mock-server'; -import { debug, Bootstrap, stats, RUN_COUNT } from './fixtures'; +import { debug, Bootstrap, saveLogs, stats, RUN_COUNT } from './fixtures'; const MESSAGE_BATCH_SIZE = 1000; // messages @@ -127,6 +127,9 @@ const ENABLE_RECEIPTS = Boolean(process.env.ENABLE_RECEIPTS); if (messagesPerSec.length !== 0) { console.log('stats info=%j', { messagesPerSec: stats(messagesPerSec) }); } + } catch (error) { + await saveLogs(bootstrap); + throw error; } finally { await bootstrap.teardown(); } diff --git a/ts/test-mock/bootstrap.ts b/ts/test-mock/bootstrap.ts index 07f28d0d2633..17a47f5c0855 100644 --- a/ts/test-mock/bootstrap.ts +++ b/ts/test-mock/bootstrap.ts @@ -148,6 +148,15 @@ export class Bootstrap { debug('setting storage path=%j', this.storagePath); } + public get logsDir(): string { + assert( + this.storagePath !== undefined, + 'Bootstrap has to be initialized first, see: bootstrap.init()' + ); + + return path.join(this.storagePath, 'logs'); + } + public async teardown(): Promise { debug('tearing down'); diff --git a/yarn.lock b/yarn.lock index 6909cdec143e..705cfe65a725 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1349,10 +1349,10 @@ "@react-spring/shared" "~9.4.0" "@react-spring/types" "~9.4.0" -"@signalapp/mock-server@1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-1.1.0.tgz#1b6ca0f4c89fb2f0b803af06bb6571780edebf10" - integrity sha512-dsrxPhvbNM5kdaGzQSwLc2jgDNkNi93DvccWwSl8P28Wfir/1IVt+8/9alaTen0xr0UBbscfreZ2sJ8junNLjA== +"@signalapp/mock-server@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-1.1.1.tgz#b290feeb107a3d644851708ff31bb4cd9733aa87" + integrity sha512-bk+fMFwRtwE4zbhryIhqPoumXX1L91kJQbHjfl2i4If47LDM9ik44vVGblIqO7l8Wf1nKDD/tTemZU5w69f5qA== dependencies: "@signalapp/signal-client" "0.12.1" debug "^4.3.2"