Working for non-deletes
This commit is contained in:
parent
ec54d0fdb3
commit
054d109ef8
12 changed files with 546 additions and 575 deletions
|
|
@ -1,21 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# Check if the argument is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <number_of_processes>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the number of processes from the first argument
|
||||
process_count=$1
|
||||
|
||||
npm run build
|
||||
|
||||
pids=()
|
||||
for i in {1..10}; do
|
||||
for i in $(seq 1 $process_count); do
|
||||
node dist/cli.js 2>&1 | tee "log_${i}.log" &
|
||||
pids+=($!)
|
||||
done
|
||||
|
||||
trap 'kill ${pids[@]} 2>/dev/null' SIGINT SIGTERM
|
||||
print_failed_log() {
|
||||
for i in $(seq 1 $process_count); do
|
||||
if [ -n "${pids[$i-1]}" ] && ! kill -0 ${pids[$i-1]} 2>/dev/null; then
|
||||
# Get the exit code of the process
|
||||
wait ${pids[$i-1]}
|
||||
exit_code=$?
|
||||
|
||||
# Only consider non-zero exit codes as failures
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo "Process ${pids[$i-1]} failed with exit code $exit_code. Log file: $(pwd)/log_${i}.log"
|
||||
return 0
|
||||
else
|
||||
echo "Process ${pids[$i-1]} completed successfully with exit code 0"
|
||||
# Mark this PID as processed by setting it to empty
|
||||
pids[$i-1]=""
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
for pid in ${pids[@]}; do
|
||||
if ! wait $pid; then
|
||||
kill ${pids[@]} 2>/dev/null
|
||||
echo "Process $pid failed, see log_$(echo ${pids[@]} | tr ' ' '\n' | grep -n "^$pid$" | cut -d: -f1).log"
|
||||
# Monitor processes
|
||||
while true; do
|
||||
if print_failed_log; then
|
||||
# Kill remaining processes
|
||||
for pid in "${pids[@]}"; do
|
||||
if [ -n "$pid" ]; then
|
||||
kill $pid 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if all processes have completed
|
||||
all_done=true
|
||||
for pid in "${pids[@]}"; do
|
||||
if [ -n "$pid" ] && kill -0 $pid 2>/dev/null; then
|
||||
all_done=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if $all_done; then
|
||||
echo "All processes completed successfully"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sleep 0.2
|
||||
done
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export class MockAgent extends MockClient {
|
|||
|
||||
// Let's not ignore errors
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
sleep(1000).then(() => process.exit(1));
|
||||
sleep(100).then(() => process.exit(1));
|
||||
|
||||
break;
|
||||
case LogLevel.WARNING:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ async function runTest({
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
// for debugging
|
||||
// eslint-disable-next-line
|
||||
(globalThis as any).clients = clients;
|
||||
|
||||
try {
|
||||
|
|
@ -88,11 +90,11 @@ async function runTest({
|
|||
}
|
||||
|
||||
async function runTests(): Promise<void> {
|
||||
const agentCounts = [2, 10];
|
||||
const jitterScaleInSeconds = [0, 0.5, 3];
|
||||
const concurrencies = [1, 16];
|
||||
const iterations = [50, 300];
|
||||
const doDeletes = [false];
|
||||
const agentCounts = [2, 8];
|
||||
const jitterScaleInSeconds = [0.5, 0, 2];
|
||||
const concurrencies = [1];
|
||||
const iterations = [50, 200];
|
||||
const doDeletes = [true, false];
|
||||
|
||||
for (const agentCount of agentCounts) {
|
||||
for (const concurrency of concurrencies) {
|
||||
|
|
@ -106,6 +108,7 @@ async function runTests(): Promise<void> {
|
|||
doDeletes: deleteFiles,
|
||||
jitterScaleInSeconds: jitter
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,15 +116,13 @@ async function runTests(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
process.on("uncaughtException", async (error) => {
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error("Uncaught Exception:", error);
|
||||
await sleep(1000);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", async (reason, promise) => {
|
||||
process.on("unhandledRejection", (reason, _promise) => {
|
||||
console.error("Unhandled Rejection:", reason);
|
||||
await sleep(1000);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
|
@ -131,6 +132,5 @@ runTests()
|
|||
})
|
||||
.catch(async (err: unknown) => {
|
||||
console.error(err);
|
||||
await sleep(1000);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue