57 lines
1.4 KiB
Bash
57 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# Mock script to run tests
|
|
# Usage: ./run_tests.sh <branch> <scenarios_json> <env> <mode> <job_id>
|
|
|
|
BRANCH=$1
|
|
SCENARIOS=$2
|
|
ENV=$3
|
|
MODE=$4
|
|
JOB_ID=$5
|
|
|
|
echo "Starting job $JOB_ID on branch $BRANCH with env $ENV and mode $MODE"
|
|
|
|
# Simulate work
|
|
sleep 5
|
|
|
|
# Create results directory if not exists (mapped volume)
|
|
# If running locally without docker mapping, this might fail if /results doesn't exist.
|
|
# We should use a relative path for safety if not in docker, but the requirement says Docker.
|
|
# We'll assume /results is mounted.
|
|
RESULTS_DIR="/results/$JOB_ID"
|
|
|
|
# Fallback for local testing if /results is not writable
|
|
if [ ! -d "/results" ]; then
|
|
RESULTS_DIR="./results/$JOB_ID"
|
|
fi
|
|
|
|
mkdir -p $RESULTS_DIR
|
|
|
|
# Generate HTML report
|
|
cat <<EOF > $RESULTS_DIR/index.html
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Test Results - Job $JOB_ID</title>
|
|
<style>body { font-family: sans-serif; padding: 20px; } .pass { color: green; } .fail { color: red; }</style>
|
|
</head>
|
|
<body>
|
|
<h1>Test Results for Job $JOB_ID</h1>
|
|
<p>Branch: $BRANCH</p>
|
|
<p>Environment: $ENV</p>
|
|
<p>Mode: $MODE</p>
|
|
<hr>
|
|
<h2>Scenarios</h2>
|
|
<ul>
|
|
<li class="pass">scenario_login: PASSED</li>
|
|
<li class="pass">scenario_payment: PASSED</li>
|
|
<li class="pass">scenario_profile: PASSED</li>
|
|
<li class="pass">scenario_logout: PASSED</li>
|
|
</ul>
|
|
<p><strong>Overall Status: PASSED</strong></p>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
|
|
echo "Job $JOB_ID completed."
|
|
exit 0
|