Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jenkins: test jenkins in a loop #33762

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4abe6d9
test
maxime-desroches Oct 10, 2024
3a38ab3
fix
maxime-desroches Oct 10, 2024
9fcc21e
test
maxime-desroches Oct 10, 2024
dafa0c6
test
maxime-desroches Oct 10, 2024
69b905c
fix
maxime-desroches Oct 10, 2024
011b8cb
test
maxime-desroches Oct 10, 2024
18b44bb
test
maxime-desroches Oct 10, 2024
e4334d0
test
maxime-desroches Oct 10, 2024
86c890a
test
maxime-desroches Oct 10, 2024
816c08c
test
maxime-desroches Oct 10, 2024
7cc5ee9
test
maxime-desroches Oct 10, 2024
9d0a9af
test
maxime-desroches Oct 10, 2024
89e5a3c
test
maxime-desroches Oct 10, 2024
a194772
test
maxime-desroches Oct 10, 2024
8f50948
test this
maxime-desroches Oct 10, 2024
9ff576c
test
maxime-desroches Oct 10, 2024
869f3ed
fix
maxime-desroches Oct 10, 2024
35e16c9
better
maxime-desroches Oct 10, 2024
2a384f3
test
maxime-desroches Oct 11, 2024
b827835
better
maxime-desroches Oct 11, 2024
4ad1d7a
better
maxime-desroches Oct 17, 2024
fde1ff2
also this
maxime-desroches Oct 17, 2024
2093a1e
all
maxime-desroches Oct 17, 2024
6e3651b
fix
maxime-desroches Oct 17, 2024
18bf032
testing
maxime-desroches Oct 17, 2024
82d124c
fix?
maxime-desroches Oct 17, 2024
8e0148f
fix
maxime-desroches Oct 17, 2024
331669a
fix this also
maxime-desroches Oct 17, 2024
d37ff5e
test
maxime-desroches Oct 17, 2024
86a93a1
js
maxime-desroches Oct 17, 2024
c21f92a
better
maxime-desroches Oct 17, 2024
9862c37
better
maxime-desroches Oct 17, 2024
0b4aae7
git
maxime-desroches Oct 17, 2024
f333122
fix sub
maxime-desroches Oct 17, 2024
76c6f20
sub
maxime-desroches Oct 17, 2024
b0eb821
fix
maxime-desroches Oct 17, 2024
5425d96
fix
maxime-desroches Oct 17, 2024
b7143ad
try
maxime-desroches Oct 17, 2024
5e100e8
env var
maxime-desroches Oct 17, 2024
ed95911
try full run
maxime-desroches Oct 17, 2024
ee76d20
fix this
maxime-desroches Oct 17, 2024
7368f40
Merge branch 'master' into jenkins_stress
maxime-desroches Oct 17, 2024
6206c01
cleanup
maxime-desroches Oct 17, 2024
9549de8
simpler
maxime-desroches Oct 18, 2024
ebc7319
better
maxime-desroches Oct 19, 2024
1ef5abb
fix
maxime-desroches Oct 19, 2024
3d8f808
get back
maxime-desroches Oct 19, 2024
00bee5b
concurent build
maxime-desroches Oct 19, 2024
c73f8fb
Merge branch 'master' into jenkins_stress
maxime-desroches Oct 19, 2024
3c74723
cleanup
maxime-desroches Oct 19, 2024
7c9d7ca
name
maxime-desroches Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ node {
'testing-closet*', 'hotfix-*']
def excludeRegex = excludeBranches.join('|').replaceAll('\\*', '.*')

if (env.BRANCH_NAME != 'master') {
if (env.BRANCH_NAME != 'master' && env.BRANCH_NAME != '__jenkins_loop_test') {
properties([
disableConcurrentBuilds(abortPrevious: true)
])
Expand Down
135 changes: 135 additions & 0 deletions scripts/jenkins_loop_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env bash
set -e

YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
BOLD='\033[1m'
NC='\033[0m'

COOKIE_JAR=/tmp/cookies
CRUMB=$(curl -s --cookie-jar $COOKIE_JAR 'https://jenkins.comma.life/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')

TESTING_BRANCH="__jenkins_loop_test"
API_ROUTE="https://jenkins.comma.life/job/openpilot/job/$TESTING_BRANCH"
N=20
TEST_BUILDS=()

# Try to find previous builds
ALL_BUILDS=( $(curl -s $API_ROUTE/api/json | jq .builds.[].number || :) )

# No builds. Create branch
if [[ ${#ALL_BUILDS[@]} -eq 0 ]]; then
TEMP_DIR=$(mktemp -d)
GIT_LFS_SKIP_SMUDGE=1 git clone -b master --depth=1 --no-tags [email protected]:commaai/openpilot $TEMP_DIR
git -C $TEMP_DIR checkout -b $TESTING_BRANCH
echo "TESTING" >> $TEMP_DIR/testing_jenkins
git -C $TEMP_DIR add testing_jenkins
git -C $TEMP_DIR commit -m "testing"
git -C $TEMP_DIR push -f origin $TESTING_BRANCH
rm -rf $TEMP_DIR
FIRST_RUN=1
sleep 90
else
# Found some builds. Check if they are still running
for i in ${ALL_BUILDS[@]}; do
running=$(curl -s $API_ROUTE/$i/api/json/ | jq .inProgress)
if [[ $running == "false" ]]; then
continue
fi
TEST_BUILDS=( ${ALL_BUILDS[@]} )
N=${#TEST_BUILDS[@]}
break
done
fi

# No running builds found
if [[ ${#TEST_BUILDS[@]} -eq 0 ]]; then
# Delete all previous builds
for i in ${ALL_BUILDS[@]}; do
curl -s --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/$i/doDelete
done

FIRST_RUN=$(curl -s $API_ROUTE/api/json | jq .nextBuildNumber)
LAST_RUN=$((FIRST_RUN+N-1))
TEST_BUILDS=( $(seq $FIRST_RUN $LAST_RUN) )

# Start N new builds
for i in ${TEST_BUILDS[@]};
do
echo "Starting build $i"
curl -s --output /dev/null --cookie $COOKIE_JAR -H "$CRUMB" -X POST $API_ROUTE/build?delay=0sec
sleep 5
done
fi

echo "Testing Jenkins with $N builds:"

while true; do
#sleep 60
sleep 5

count=0
for i in ${TEST_BUILDS[@]};
do
RES=$(curl -s -w "\n%{http_code}" --cookie $COOKIE_JAR -H "$CRUMB" $API_ROUTE/$i/api/json)
HTTP_CODE=$(tail -n1 <<< "$RES")
JSON=$(sed '$ d' <<< "$RES")

if [[ $HTTP_CODE == "200" ]]; then
STILL_RUNNING=$(echo $JSON | jq .inProgress)
if [[ $STILL_RUNNING == "true" ]]; then
echo -e "Build $i: ${YELLOW}still running${NC}"
continue
else
count=$((count+1))
echo -e "Build $i: ${GREEN}done${NC}"
fi
else
echo "No status for build $i"
fi
done
echo ""

if [[ $count -ge $N ]]; then
break
fi
done

STAGES_NAMES=()
while read stage; do
STAGES_NAMES[$index]=$stage
index=$((index+1))
done < <(curl -s -H "$CRUMB" $API_ROUTE/lastBuild/wfapi/ | jq .stages[].name)
STAGES_COUNT=${#STAGES_NAMES[@]}

STAGES_FAILURES=($(for i in $(seq 1 $STAGES_COUNT); do echo 0; done))

for i in ${TEST_BUILDS[@]}; do
index=0
while read result; do
if [[ $result != '"SUCCESS"' ]]; then
STAGES_FAILURES[$index]=$((STAGES_FAILURES[$index]+1))
fi
index=$((index+1))
done < <(curl -s $API_ROUTE/$i/wfapi/ | jq .stages[].status)
done

echo "=========================================="
echo "===================DONE==================="
echo "=========================================="

# print results of all builds
for i in $(seq 0 $(($STAGES_COUNT-1))); do
P=$((${STAGES_FAILURES[$i]}*100/$N))
if [[ $P -eq 0 ]]; then
P=${GREEN}${BOLD}${P}
else
P=${RED}${BOLD}${P}
fi
echo -e "${STAGES_NAMES[$i]} : $P% failure rate${NC}"
done

echo "=========================================="
echo "=========================================="
echo "=========================================="
Loading