Adding user load testing script.
This commit is contained in:
parent
b55635c7ab
commit
513d901ab4
|
@ -0,0 +1,83 @@
|
|||
const fetch = require("node-fetch")
|
||||
const { getProdAppID } = require("@budibase/backend-core/db")
|
||||
|
||||
const USER_LOAD_NUMBER = 10000
|
||||
const BATCH_SIZE = 25
|
||||
const SERVER_URL = "http://localhost:4001"
|
||||
const PASSWORD = "test"
|
||||
|
||||
const APP_ID = process.argv[2]
|
||||
const API_KEY = process.argv[3]
|
||||
|
||||
const words = [
|
||||
"test",
|
||||
"testing",
|
||||
"budi",
|
||||
"mail",
|
||||
"age",
|
||||
"risk",
|
||||
"load",
|
||||
"uno",
|
||||
"arm",
|
||||
"leg",
|
||||
"pen",
|
||||
"glass",
|
||||
"box",
|
||||
"chicken",
|
||||
"bottle",
|
||||
]
|
||||
|
||||
if (!APP_ID) {
|
||||
console.error("Must supply app ID as first CLI option!")
|
||||
process.exit(-1)
|
||||
}
|
||||
if (!API_KEY) {
|
||||
console.error("Must supply API key as second CLI option!")
|
||||
process.exit(-1)
|
||||
}
|
||||
|
||||
const WORD_1 = words[Math.floor(Math.random() * words.length)]
|
||||
const WORD_2 = words[Math.floor(Math.random() * words.length)]
|
||||
|
||||
function generateUser(count) {
|
||||
return {
|
||||
password: PASSWORD,
|
||||
email: `${WORD_1}${count}@${WORD_2}.com`,
|
||||
roles: {
|
||||
[getProdAppID(APP_ID)]: "BASIC",
|
||||
},
|
||||
status: "active",
|
||||
forceResetPassword: false,
|
||||
firstName: "John",
|
||||
lastName: "Smith",
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
for (let i = 0; i < USER_LOAD_NUMBER; i += BATCH_SIZE) {
|
||||
let promises = []
|
||||
for (let j = 0; j < BATCH_SIZE; j++) {
|
||||
promises.push(
|
||||
fetch(`${SERVER_URL}/api/public/v1/users`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(generateUser(i + j)),
|
||||
headers: {
|
||||
"x-budibase-api-key": API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
)
|
||||
}
|
||||
await Promise.all(promises)
|
||||
console.log(`${i + BATCH_SIZE} users have been created.`)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
.then(() => {
|
||||
console.log(`Generated ${USER_LOAD_NUMBER} users!`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Failed for reason: ", err)
|
||||
process.exit(-1)
|
||||
})
|
|
@ -1014,10 +1014,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.164":
|
||||
version "1.0.164"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.164.tgz#08c111dcebf5c74159a3c18218c7b3a0716de4f6"
|
||||
integrity sha512-lpMudezndUD1hHBLfT9LDNKCunj8rQNlaJb30/xggdIUvp718u/jVP54hXF26NYxXOTMZ0EvMwCsIS4AucJ1Mg==
|
||||
"@budibase/backend-core@1.0.167":
|
||||
version "1.0.167"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.167.tgz#6ea4b90f8b8b8ec3cbbe05e39853d44d40938879"
|
||||
integrity sha512-IG9GZUdjFiqOKbgpZiwGotyT3BttFlChXs7mT8GaOkX7XvlyxxrG/nSI1duglBd6X2iafGESKQU8e6tKKQsxuw==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "^0.3.0"
|
||||
aws-sdk "^2.901.0"
|
||||
|
@ -1091,12 +1091,12 @@
|
|||
svelte-flatpickr "^3.2.3"
|
||||
svelte-portal "^1.0.0"
|
||||
|
||||
"@budibase/pro@1.0.164":
|
||||
version "1.0.164"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.164.tgz#780ae38893d0609c87bf51fe96cc2c35bbdb431a"
|
||||
integrity sha512-PgF7q2vADPPYzet4Wdma+THWuQPrEnN1+TfRly4l0oS9SUxutog3hYn0TlPmPS0AHgrqG/1v65TcEdC4ucX8TA==
|
||||
"@budibase/pro@1.0.167":
|
||||
version "1.0.167"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.167.tgz#62fe54b58206eb04151a786a5516351137bd2f84"
|
||||
integrity sha512-AdWWOub58LMxZoZzXm3jy1ZSVOR1teSH+lwLisdGWLnoVAUV8e46pD7iOyJDM1SKuSyNWeQ1lXj8tcLHVK1+OA==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.164"
|
||||
"@budibase/backend-core" "1.0.167"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/standard-components@^0.9.139":
|
||||
|
|
|
@ -293,10 +293,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.164":
|
||||
version "1.0.164"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.164.tgz#08c111dcebf5c74159a3c18218c7b3a0716de4f6"
|
||||
integrity sha512-lpMudezndUD1hHBLfT9LDNKCunj8rQNlaJb30/xggdIUvp718u/jVP54hXF26NYxXOTMZ0EvMwCsIS4AucJ1Mg==
|
||||
"@budibase/backend-core@1.0.167":
|
||||
version "1.0.167"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.167.tgz#6ea4b90f8b8b8ec3cbbe05e39853d44d40938879"
|
||||
integrity sha512-IG9GZUdjFiqOKbgpZiwGotyT3BttFlChXs7mT8GaOkX7XvlyxxrG/nSI1duglBd6X2iafGESKQU8e6tKKQsxuw==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "^0.3.0"
|
||||
aws-sdk "^2.901.0"
|
||||
|
@ -321,12 +321,12 @@
|
|||
uuid "^8.3.2"
|
||||
zlib "^1.0.5"
|
||||
|
||||
"@budibase/pro@1.0.164":
|
||||
version "1.0.164"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.164.tgz#780ae38893d0609c87bf51fe96cc2c35bbdb431a"
|
||||
integrity sha512-PgF7q2vADPPYzet4Wdma+THWuQPrEnN1+TfRly4l0oS9SUxutog3hYn0TlPmPS0AHgrqG/1v65TcEdC4ucX8TA==
|
||||
"@budibase/pro@1.0.167":
|
||||
version "1.0.167"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.167.tgz#62fe54b58206eb04151a786a5516351137bd2f84"
|
||||
integrity sha512-AdWWOub58LMxZoZzXm3jy1ZSVOR1teSH+lwLisdGWLnoVAUV8e46pD7iOyJDM1SKuSyNWeQ1lXj8tcLHVK1+OA==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.164"
|
||||
"@budibase/backend-core" "1.0.167"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@cspotcode/source-map-consumer@0.8.0":
|
||||
|
|
Loading…
Reference in New Issue