1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Added scripts to test server performances

This commit is contained in:
Laurent Cozic 2021-06-17 11:21:37 +01:00
parent 232e0c937a
commit a38958ab7b
5 changed files with 69 additions and 2 deletions

View File

@ -1,2 +1,3 @@
test data/ test data/
export/ export/
support/serverPerformances/testPerfCommands.txt

View File

@ -0,0 +1,55 @@
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIR="$SCRIPT_DIR/../../../../.."
COMMANDS=($(echo $1 | tr "," "\n"))
PROFILE_DIR=~/.config/joplindev-testperf
CMD_FILE="$SCRIPT_DIR/testPerfCommands.txt"
rm -f "$CMD_FILE"
touch "$CMD_FILE"
for CMD in "${COMMANDS[@]}"
do
if [[ $CMD == "createUsers" ]]; then
curl --data '{"action": "createTestUsers"}' -H 'Content-Type: application/json' http://api.joplincloud.local:22300/api/debug
# elif [[ $CMD == "createData" ]]; then
# echo 'mkbook "shared"' >> "$CMD_FILE"
# echo 'mkbook "other"' >> "$CMD_FILE"
# echo 'use "shared"' >> "$CMD_FILE"
# echo 'mknote "note 1"' >> "$CMD_FILE"
# echo 'mknote "note 2"' >> "$CMD_FILE"
elif [[ $CMD == "reset" ]]; then
USER_EMAIL="user1@example.com"
rm -rf "$PROFILE_DIR"
echo "config keychain.supported 0" >> "$CMD_FILE"
echo "config sync.target 9" >> "$CMD_FILE"
echo "config sync.9.path http://api.joplincloud.local:22300" >> "$CMD_FILE"
echo "config sync.9.username $USER_EMAIL" >> "$CMD_FILE"
echo "config sync.9.password 123456" >> "$CMD_FILE"
# elif [[ $CMD == "e2ee" ]]; then
# echo "e2ee enable --password 111111" >> "$CMD_FILE"
else
echo "Unknown command: $CMD"
exit 1
fi
done
cd "$ROOT_DIR/packages/app-cli"
npm start -- --profile "$PROFILE_DIR" batch "$CMD_FILE"
npm start -- --profile "$PROFILE_DIR" import ~/Desktop/Joplin_17_06_2021.jex
npm start -- --profile "$PROFILE_DIR" sync

View File

@ -169,7 +169,7 @@ export default class Synchronizer {
if (report.deleteRemote) lines.push(_('Deleted remote items: %d.', report.deleteRemote)); if (report.deleteRemote) lines.push(_('Deleted remote items: %d.', report.deleteRemote));
if (report.fetchingTotal && report.fetchingProcessed) lines.push(_('Fetched items: %d/%d.', report.fetchingProcessed, report.fetchingTotal)); if (report.fetchingTotal && report.fetchingProcessed) lines.push(_('Fetched items: %d/%d.', report.fetchingProcessed, report.fetchingTotal));
if (report.cancelling && !report.completedTime) lines.push(_('Cancelling...')); if (report.cancelling && !report.completedTime) lines.push(_('Cancelling...'));
if (report.completedTime) lines.push(_('Completed: %s', time.formatMsToLocal(report.completedTime))); if (report.completedTime) lines.push(_('Completed: %s (%s)', time.formatMsToLocal(report.completedTime), `${Math.round((report.completedTime - report.startTime) / 1000)}s`));
if (this.reportHasErrors(report)) lines.push(_('Last error: %s', report.errors[report.errors.length - 1].toString().substr(0, 500))); if (this.reportHasErrors(report)) lines.push(_('Last error: %s', report.errors[report.errors.length - 1].toString().substr(0, 500)));
return lines; return lines;
@ -225,6 +225,7 @@ export default class Synchronizer {
if (n == 'starting') continue; if (n == 'starting') continue;
if (n == 'finished') continue; if (n == 'finished') continue;
if (n == 'state') continue; if (n == 'state') continue;
if (n == 'startTime') continue;
if (n == 'completedTime') continue; if (n == 'completedTime') continue;
this.logger().info(`${n}: ${report[n] ? report[n] : '-'}`); this.logger().info(`${n}: ${report[n] ? report[n] : '-'}`);
} }
@ -356,6 +357,8 @@ export default class Synchronizer {
const outputContext = Object.assign({}, lastContext); const outputContext = Object.assign({}, lastContext);
this.progressReport_.startTime = time.unixMs();
this.dispatch({ type: 'SYNC_STARTED' }); this.dispatch({ type: 'SYNC_STARTED' });
eventManager.emit('syncStart'); eventManager.emit('syncStart');

View File

@ -4,6 +4,9 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start-dev": "nodemon --config nodemon.json --ext ts,js,mustache,css,tsx dist/app.js --env dev", "start-dev": "nodemon --config nodemon.json --ext ts,js,mustache,css,tsx dist/app.js --env dev",
"devCreateDb": "node dist/app.js --env dev --create-db",
"devDropTables": "node dist/app.js --env dev --drop-tables",
"devDropDb": "node dist/app.js --env dev --drop-db",
"start": "node dist/app.js", "start": "node dist/app.js",
"generateTypes": "rm -f db-buildTypes.sqlite && npm run start -- --migrate-db --env buildTypes && node dist/tools/generateTypes.js && mv db-buildTypes.sqlite schema.sqlite", "generateTypes": "rm -f db-buildTypes.sqlite && npm run start -- --migrate-db --env buildTypes && node dist/tools/generateTypes.js && mv db-buildTypes.sqlite schema.sqlite",
"tsc": "tsc --project tsconfig.json", "tsc": "tsc --project tsconfig.json",

View File

@ -27,6 +27,11 @@ const env: Env = argv.env as Env || Env.Prod;
const defaultEnvVariables: Record<Env, EnvVariables> = { const defaultEnvVariables: Record<Env, EnvVariables> = {
dev: { dev: {
// To test with the Postgres database, uncomment DB_CLIENT below and
// comment out SQLITE_DATABASE. Then start the Postgres server using
// `docker-compose --file docker-compose.db-dev.yml up`
// DB_CLIENT: 'pg',
SQLITE_DATABASE: `${sqliteDefaultDir}/db-dev.sqlite`, SQLITE_DATABASE: `${sqliteDefaultDir}/db-dev.sqlite`,
}, },
buildTypes: { buildTypes: {