Skip to content

Commit 656731a

Browse files
authored
Merge 2e3dc3b into 2b5f88d
2 parents 2b5f88d + 2e3dc3b commit 656731a

File tree

3 files changed

+81
-7
lines changed

3 files changed

+81
-7
lines changed

.github/actions/test_ya/action.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ runs:
101101
shell: bash
102102
run: |
103103
set -x
104-
104+
105+
echo "$(pwd)/ydb/ci/scripts" >> $GITHUB_PATH
106+
105107
export TMP_DIR=$(pwd)/tmp
106108
rm -rf $TMP_DIR
107109
mkdir -p $TMP_DIR
@@ -345,7 +347,7 @@ runs:
345347
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-link --name build --url "$TESTMO_RUN_URL" --resources $CURRENT_PUBLIC_DIR/testmo.json
346348
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:resources:add-field --name git-sha --type string --value "${GITHUB_SHA:0:7}" --resources $CURRENT_PUBLIC_DIR/testmo.json
347349
TESTMO_RUN_ID=$(
348-
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
350+
TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:create --instance "https://$TESTMO_PROXY_ADDR" --project-id ${{ inputs.testman_project_id }} \
349351
--name "$TESTMO_RUN_NAME" --source "$TESTMO_SOURCE" --resources $CURRENT_PUBLIC_DIR/testmo.json \
350352
--tags "$TESTMO_BRANCH_TAG" --tags "$TESTMO_EXTRA_TAG"
351353
)
@@ -459,11 +461,11 @@ runs:
459461
# archive unitest reports (transformed)
460462
tar -C $TESTMO_JUNIT_REPORT_PARTS/.. -czf $PUBLIC_DIR/junit_parts.xml.tar.gz $(basename $TESTMO_JUNIT_REPORT_PARTS)
461463

462-
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:submit-thread \
464+
TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:submit-thread \
463465
--instance "https://$TESTMO_PROXY_ADDR" --run-id "$TESTMO_RUN_ID" \
464466
--results "$TESTMO_JUNIT_REPORT_PARTS/*.xml"
465467

466-
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
468+
TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id $TESTMO_RUN_ID || true
467469
echo "runid=" >> $GITHUB_OUTPUT
468470
fi
469471

@@ -500,7 +502,7 @@ runs:
500502
shell: bash
501503
run: |
502504
if [ ${{ steps.build.outputs.runid }} ]; then
503-
TESTMO_TOKEN=${{ inputs.testman_token }} testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
505+
TESTMO_TOKEN=${{ inputs.testman_token }} retry.sh -- testmo automation:run:complete --instance "https://$TESTMO_PROXY_ADDR" --run-id ${{ steps.build.outputs.runid }} || true
504506
fi
505507
if [ ${{ inputs.testman_token }} ]; then
506508
kill $TESTMO_PROXY_PID

ydb/ci/scripts/retry.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "$0 -r [max_attempts] -t [timeout] -s [sleep] -- cmd"
5+
}
6+
7+
if [ $# -lt 2 ]; then
8+
usage
9+
exit 1
10+
fi
11+
12+
max_attempts=0
13+
timeout=1800
14+
sleep_time=30
15+
16+
while getopts 'r:t:s:' opt; do
17+
case "$opt" in
18+
r)
19+
max_attempts=$OPTARG
20+
;;
21+
t)
22+
timeout=$OPTARG
23+
;;
24+
s)
25+
sleep_time=$OPTARG
26+
;;
27+
:)
28+
usage
29+
exit 1
30+
;;
31+
esac
32+
done
33+
34+
35+
shift $((OPTIND - 2))
36+
37+
if [[ "$1" == "--" ]]; then
38+
shift # Shift past the double dash
39+
else
40+
echo "Error: Missing -- before command"
41+
exit 1
42+
fi
43+
44+
cmd=$@
45+
46+
attempt_num=1
47+
start_time=$(date +%s)
48+
49+
while true; do
50+
elapsed=$(($(date +%s) - $start_time))
51+
52+
if [ "$max_attempts" -ne 0 ] && [ "$attempt_num" -ge "$max_attempts" ]; then
53+
echo "maximum attempts reached, exit" >&2
54+
exit 10
55+
fi
56+
57+
if [ "$timeout" -ne 0 ] && [ $elapsed -ge "$timeout" ]; then
58+
echo "timeout reached, exit" >&2
59+
exit 11
60+
fi
61+
62+
$cmd
63+
64+
if [ $? -eq 0 ]; then
65+
exit
66+
else
67+
attempt_num=$(( attempt_num + 1 ))
68+
if [ $sleep_time != "0" ]; then
69+
sleep $sleep_time
70+
fi
71+
fi
72+
done

ydb/ci/testmo-proxy/testmo-proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class Handler(http.server.BaseHTTPRequestHandler):
1515
error_message_format = '{"status":"error", "code":"%(code)d", "message": "%(message)s"}\n'
1616

1717
# noinspection PyMissingConstructor
18-
def __init__(self, target_url: str, timeout: Tuple[int, int], max_reqest_time: int):
18+
def __init__(self, target_url: str, timeout: Tuple[int, int], max_request_time: int):
1919
self._target_url = target_url
2020
self._timeout = timeout
21-
self._max_request_time = max_reqest_time
21+
self._max_request_time = max_request_time
2222

2323
def __call__(self, *args, **kwargs):
2424
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)