mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 00:20:45 +00:00
c93a53ead2
* ci: init e2e test for browser env stash changes * test: update fsentry definition, add tests stash changes * test: pass puter-js mkdir test * test: add test for puter-js move * tidy code * tidy code * doc: add docs for playwright test * recover memoryfs * test: puter-js readdir/stat * test: puter-js write * test: puter-js read * test: puter-js move_cart * test: fix failed tests on move * tests: rename files * test: puter-js copy_cart * tests: puter-js batch/delete, read config from file * ci: add vitest * ci: update names and timeout * ci: simplify playwright-test * ci: simplify api-test * move "api-tester" from tools to tests * test: update example config * test: remove folder tests/api-tester/ci * test: unify config location * test: remove unused files * ci: fix wrong config * ci: fix wrong path * test: add docs * ci: update timeout, print artifact url
110 lines
2.2 KiB
JavaScript
110 lines
2.2 KiB
JavaScript
const axios = require('axios');
|
|
const YAML = require('yaml');
|
|
|
|
const https = require('node:https');
|
|
const { parseArgs } = require('node:util');
|
|
const url = require('node:url');
|
|
|
|
const path_ = require('path');
|
|
const fs = require('fs');
|
|
|
|
let config;
|
|
|
|
try {
|
|
({ values: {
|
|
config,
|
|
}, positionals: [id] } = parseArgs({
|
|
options: {
|
|
config: {
|
|
type: 'string',
|
|
},
|
|
},
|
|
allowPositionals: true,
|
|
}));
|
|
} catch (e) {
|
|
if ( args.length < 1 ) {
|
|
console.error(
|
|
'Usage: readdir_profile [OPTIONS]\n' +
|
|
'\n' +
|
|
'Options:\n' +
|
|
' --config=<path> (required) Path to configuration file\n' +
|
|
''
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
const conf = YAML.parse(fs.readFileSync(config).toString());
|
|
|
|
const dir = `/${conf.username}/readdir_test`
|
|
|
|
// process.on('SIGINT', async () => {
|
|
// process.exit(0);
|
|
// });
|
|
|
|
const httpsAgent = new https.Agent({
|
|
rejectUnauthorized: false
|
|
})
|
|
const getURL = (...path) => {
|
|
const apiURL = new url.URL(conf.url);
|
|
apiURL.pathname = path_.posix.join(
|
|
apiURL.pathname,
|
|
...path
|
|
);
|
|
return apiURL.href;
|
|
};
|
|
|
|
const epoch = Date.now();
|
|
const TIME_BEFORE_TEST = 20 * 1000; // 10 seconds
|
|
|
|
const NOOP = () => {};
|
|
let check = () => {
|
|
if ( Date.now() - epoch >= TIME_BEFORE_TEST ) {
|
|
console.log(
|
|
`\x1B[36;1m !!! START THE TEST !!! \x1B[0m`
|
|
);
|
|
check = NOOP;
|
|
}
|
|
};
|
|
|
|
const measure_readdir = async () => {
|
|
const ts_start = Date.now();
|
|
|
|
await axios.request({
|
|
httpsAgent,
|
|
method: 'post',
|
|
url: getURL('readdir'),
|
|
data: {
|
|
path: dir,
|
|
},
|
|
headers: {
|
|
'Authorization': `Bearer ${conf.token}`,
|
|
'Content-Type': 'application/json'
|
|
}
|
|
})
|
|
|
|
const ts_end = Date.now();
|
|
|
|
const diff = ts_end - ts_start;
|
|
|
|
await fs.promises.appendFile(
|
|
`readdir_profile.txt`,
|
|
`${Date.now()},${diff}\n`
|
|
)
|
|
|
|
check();
|
|
|
|
await new Promise(rslv => {
|
|
setTimeout(rslv, 5);
|
|
});
|
|
}
|
|
|
|
|
|
const main = async () => {
|
|
while (true) {
|
|
await measure_readdir();
|
|
}
|
|
}
|
|
|
|
main();
|