|
@@ -1,39 +1,40 @@
|
|
|
-const minimist = require('minimist')
|
|
|
|
|
-const settings = require('@overleaf/settings')
|
|
|
|
|
-const ProjectDetailsHandler = require('../app/src/Features/Project/ProjectDetailsHandler')
|
|
|
|
|
-const mongodb = require('../app/src/infrastructure/mongodb')
|
|
|
|
|
-const mongoose = require('../app/src/infrastructure/Mongoose')
|
|
|
|
|
-const fs = require('fs')
|
|
|
|
|
-const path = require('path')
|
|
|
|
|
-const crypto = require('crypto')
|
|
|
|
|
-const fetch = require('node-fetch')
|
|
|
|
|
-const http = require('http')
|
|
|
|
|
|
|
+import minimist from 'minimist'
|
|
|
|
|
+import settings from '@overleaf/settings'
|
|
|
|
|
+import ProjectDetailsHandler from '../app/src/Features/Project/ProjectDetailsHandler.js'
|
|
|
|
|
+import mongodb from '../app/src/infrastructure/mongodb.js'
|
|
|
|
|
+import mongoose from '../app/src/infrastructure/Mongoose.js'
|
|
|
|
|
+import fs from 'fs'
|
|
|
|
|
+import path from 'path'
|
|
|
|
|
+import crypto from 'crypto'
|
|
|
|
|
+import fetch from 'node-fetch'
|
|
|
|
|
+import http from 'http'
|
|
|
|
|
+import _ from 'lodash'
|
|
|
|
|
+
|
|
|
const { ObjectId } = mongodb
|
|
const { ObjectId } = mongodb
|
|
|
-const _ = require('lodash')
|
|
|
|
|
|
|
|
|
|
// Examples:
|
|
// Examples:
|
|
|
//
|
|
//
|
|
|
// Simple usage:
|
|
// Simple usage:
|
|
|
-// node stress_test.js --project-id=ID -n 100 --download-zip # download 100 zips from history-v1
|
|
|
|
|
-// node stress_test.js --project-id=ID -n 100 --create-blob # create 100 blobs in history-v1
|
|
|
|
|
-// node stress_test.js --project-id=ID -n 100 --fetch-blob # create blob and fetch it 100 times from history-v1
|
|
|
|
|
-// node stress_test.js --project-id=ID -n 100 --upload-file # upload 100 files to filestore
|
|
|
|
|
-// node stress_test.js --project-id=ID -n 100 --download-file # create file in filestore and download it 100 times
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --download-zip # download 100 zips from history-v1
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --create-blob # create 100 blobs in history-v1
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --fetch-blob # create blob and fetch it 100 times from history-v1
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --upload-file # upload 100 files to filestore
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --download-file # create file in filestore and download it 100 times
|
|
|
//
|
|
//
|
|
|
// Delay between requests:
|
|
// Delay between requests:
|
|
|
-// node stress_test.js --project-id=ID -n 100 --download-zip --sleep=0.1 # download 100 zips from history-v1 with 0.1s sleep
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --download-zip --sleep=0.1 # download 100 zips from history-v1 with 0.1s sleep
|
|
|
//
|
|
//
|
|
|
// Abort requests at random times:
|
|
// Abort requests at random times:
|
|
|
-// node stress_test.js --project-id=ID -n 100 --download-zip --abort # download 100 zips from history-v1 with aborts
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 100 --download-zip --abort # download 100 zips from history-v1 with aborts
|
|
|
//
|
|
//
|
|
|
// Parallel workers:
|
|
// Parallel workers:
|
|
|
-// node stress_test.js --project-id=ID -n 1000 -j 10 --upload-file # upload 1000 files in 10 parallel workers
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 1000 -j 10 --upload-file # upload 1000 files in 10 parallel workers
|
|
|
//
|
|
//
|
|
|
// Fixed file size:
|
|
// Fixed file size:
|
|
|
-// node stress_test.js --project-id=ID -n 1000 --size 1000000 --upload-file # upload 1000 files of 1MB in 10 parallel workers
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 1000 --size 1000000 --upload-file # upload 1000 files of 1MB in 10 parallel workers
|
|
|
//
|
|
//
|
|
|
// Random file size:
|
|
// Random file size:
|
|
|
-// node stress_test.js --project-id=ID -n 1000 --size-min 1024 --size-max 10000000 --upload-file # upload 1000 files of 1KB to 10MB in 10 parallel workers
|
|
|
|
|
|
|
+// node stress_test.mjs --project-id=ID -n 1000 --size-min 1024 --size-max 10000000 --upload-file # upload 1000 files of 1KB to 10MB in 10 parallel workers
|
|
|
|
|
|
|
|
const argv = minimist(process.argv.slice(2), {
|
|
const argv = minimist(process.argv.slice(2), {
|
|
|
string: ['n', 'j', 'project-id', 'sleep', 'size', 'size-min', 'size-max'],
|
|
string: ['n', 'j', 'project-id', 'sleep', 'size', 'size-min', 'size-max'],
|
|
@@ -58,7 +59,7 @@ const argv = minimist(process.argv.slice(2), {
|
|
|
const projectId = argv['project-id']
|
|
const projectId = argv['project-id']
|
|
|
if (!projectId) {
|
|
if (!projectId) {
|
|
|
console.error(
|
|
console.error(
|
|
|
- 'Usage: node stress_test.js --project-id ID -n COUNT -j CONCURRENCY --sleep T --size BYTES --use-file --[create-blob|fetch-blob|download-zip|upload-file|download-file]'
|
|
|
|
|
|
|
+ 'Usage: node stress_test.mjs --project-id ID -n COUNT -j CONCURRENCY --sleep T --size BYTES --use-file --[create-blob|fetch-blob|download-zip|upload-file|download-file]'
|
|
|
)
|
|
)
|
|
|
process.exit(1)
|
|
process.exit(1)
|
|
|
}
|
|
}
|
|
@@ -430,13 +431,12 @@ async function run() {
|
|
|
log('Stress test done')
|
|
log('Stress test done')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Promise.all([mongodb.waitForDb(), mongoose.connectionPromise])
|
|
|
|
|
- .then(() => run())
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- log('Completed')
|
|
|
|
|
- process.exit(0)
|
|
|
|
|
- })
|
|
|
|
|
- .catch(error => {
|
|
|
|
|
- console.error(error)
|
|
|
|
|
- process.exit(1)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+try {
|
|
|
|
|
+ await Promise.all([mongodb.waitForDb(), mongoose.connectionPromise])
|
|
|
|
|
+ await run()
|
|
|
|
|
+ log('Completed')
|
|
|
|
|
+ process.exit(0)
|
|
|
|
|
+} catch (error) {
|
|
|
|
|
+ console.error(error)
|
|
|
|
|
+ process.exit(1)
|
|
|
|
|
+}
|