Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package retry for openSUSE:Factory checked in at 2024-04-02 16:43:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/retry (Old) and /work/SRC/openSUSE:Factory/.retry.new.1905 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "retry" Tue Apr 2 16:43:12 2024 rev:6 rq:1163956 version:1711985904.b9b8f3b Changes: -------- --- /work/SRC/openSUSE:Factory/retry/retry.changes 2023-11-24 23:36:15.398677167 +0100 +++ /work/SRC/openSUSE:Factory/.retry.new.1905/retry.changes 2024-04-02 16:45:06.466926911 +0200 @@ -1,0 +2,11 @@ +Mon Apr 01 15:39:57 UTC 2024 - ok...@suse.com + +- Update to version 1711985904.b9b8f3b: + * Add count-fail-ratio to Makefile+spec + * Mention alternative github.com/minfrin/retry + * Explain count-fail-ratio in README as well + * count-fail-ratio: Enable timing by default + * Add count-fail-ratio with tests + * Makefile: Adapt path to checkbashisms + +------------------------------------------------------------------- Old: ---- retry-1700850441.829db9e.obscpio New: ---- retry-1711985904.b9b8f3b.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ retry.spec ++++++ --- /var/tmp/diff_new_pack.U4KWZb/_old 2024-04-02 16:45:07.810974887 +0200 +++ /var/tmp/diff_new_pack.U4KWZb/_new 2024-04-02 16:45:07.830975601 +0200 @@ -1,7 +1,7 @@ # # spec file for package retry # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: retry -Version: 1700850441.829db9e +Version: 1711985904.b9b8f3b Release: 0 Summary: A simple tool for retrying command executions in plain POSIX sh License: MIT @@ -43,4 +43,5 @@ %files %{_bindir}/retry +%{_bindir}/count-fail-ratio ++++++ retry-1700850441.829db9e.obscpio -> retry-1711985904.b9b8f3b.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/Makefile new/retry-1711985904.b9b8f3b/Makefile --- old/retry-1700850441.829db9e/Makefile 2023-11-24 19:27:21.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/Makefile 2024-04-01 17:38:24.000000000 +0200 @@ -15,7 +15,7 @@ checkbashisms: @command -v wget >/dev/null 2>&1 || echo "Command 'wget' not found, can not download checkbashisms" - wget -q https://salsa.debian.org/debian/devscripts/-/raw/master/scripts/checkbashisms.pl -O checkbashisms + wget -q https://salsa.debian.org/debian/devscripts/-/raw/main/scripts/checkbashisms.pl -O checkbashisms chmod +x checkbashisms command -v checkbashisms >/dev/null || echo "Downloaded checkbashisms. You can check the file and add to PATH, then call make again" @@ -35,3 +35,4 @@ .PHONY: install install: install -m 755 retry "$(DESTDIR)"/usr/bin/retry + install -m 755 count-fail-ratio "$(DESTDIR)"/usr/bin/count-fail-ratio diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/README.md new/retry-1711985904.b9b8f3b/README.md --- old/retry-1700850441.829db9e/README.md 2023-11-24 19:27:21.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/README.md 2024-04-01 17:38:24.000000000 +0200 @@ -43,6 +43,30 @@ retry -- timeout 10 $cmd ``` +### count-fail-ratio - simple statistics about retries + +Another tool provided is "count-fail-ratio" which can count fails, the fail +ratio, the failure probability and timing information from repeated command +calls. Simply call + +``` +count-fail-ratio $cmd +``` + +to execute `$cmd` automatically multiple times collecting the mentioned +statistics. + +Further options to count-fail-ratio can be specified by runtime variables. For +example to change the number of runs from the default of 20 set the variable +"runs" while disabling computing timing information: + +``` +runs=100 timing=0 count-fail-ratio $cmd +``` + +For the complete list of variables take a look into the script file +count-fail-ratio itself. + ## Contribute This project lives in https://github.com/okurz/retry @@ -79,6 +103,11 @@ make checkstyle ``` +## Alternatives + +* https://github.com/minfrin/retry - an older C implementation which is also + available in Debian and Ubuntu. + ## License This project is licensed under the MIT license, see LICENSE file for details. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/count-fail-ratio new/retry-1711985904.b9b8f3b/count-fail-ratio --- old/retry-1700850441.829db9e/count-fail-ratio 1970-01-01 01:00:00.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/count-fail-ratio 2024-04-01 17:38:24.000000000 +0200 @@ -0,0 +1,45 @@ +#!/bin/bash -e +# shellcheck disable=SC2048 +[ "$1" = "-h" ] || [ "$1" = "--help" ] && echo "Run an arbitrary command multiple times and count failures and fail ratio" && exit + +fails="${fails:-0}" +runs="${runs:-"20"}" +start="${start:-1}" +timing="${timing:-1}" +if [ "$timing" = 1 ]; then t_start=$(date +%s%N); fi +declare -a times=() +for ((i=start; i <= runs; i++)); do + echo "## Run $i" + if [ "$timing" = 1 ]; then t_run_start=$(date +%s%N); fi + $* || fails=$((fails+1)) + if [ "$timing" = 1 ]; then + t_run_end=$(date +%s%N) + runtime=$(( (t_run_end - t_run_start) / 1000000 )) + times+=("$runtime") + fi + p=$(bc <<< "scale=9;${fails}/${i}") + standard_error=$(bc <<< "scale=9;sqrt(${p}*(1 - ${p})/${i})") + # critical value (z_value) for a 95% confidence level. In this + # case, the critical value is approximately 1.96. + z_value=1.96 + me=$(bc <<< "scale=9;${z_value}*${standard_error}") + echo -n "## $(basename "$0"): Run: $i. Fails: $fails. Fail ratio $(bc <<< "r=${p} * 100;scale=2;r/1")±$(bc <<< "r=${me}*100;scale=2;r/1")%" + [[ $fails = 0 ]] && echo -n ". No fails, computed failure probability < $(bc <<< "scale=2;3 * 100/${i}")%" + echo "" + if [ "$timing" = 1 ]; then + t_end=$(date +%s%N) + # Compute standard deviation + sum=0 + for time in "${times[@]}"; do + sum=$((sum + time)) + done + mean=$((sum / i)) + variance=0 + for time in "${times[@]}"; do + diff=$((time - mean)) + variance=$((variance + diff*diff)) + done + stddev=$(bc <<< "scale=2;sqrt(${variance}/${i})") + echo "## mean runtime: $(( (t_end - t_start) / i / 1000000 ))±$stddev ms" + fi +done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/dist/rpm/retry.spec new/retry-1711985904.b9b8f3b/dist/rpm/retry.spec --- old/retry-1700850441.829db9e/dist/rpm/retry.spec 2023-11-24 19:27:21.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/dist/rpm/retry.spec 2024-04-01 17:38:24.000000000 +0200 @@ -42,5 +42,6 @@ %files %{_bindir}/retry +%{_bindir}/count-fail-ratio %changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/test/01-count-fail-ratio.t new/retry-1711985904.b9b8f3b/test/01-count-fail-ratio.t --- old/retry-1700850441.829db9e/test/01-count-fail-ratio.t 1970-01-01 01:00:00.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/test/01-count-fail-ratio.t 2024-04-01 17:38:24.000000000 +0200 @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e +dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd) + +TEST_MORE_PATH=$dir/../test-more-bash +BASHLIB="` + find $TEST_MORE_PATH -type d | + grep -E '/(bin|lib)$' | + xargs -n1 printf "%s:"`" +PATH=$BASHLIB$PATH + +source bash+ :std +use Test::More +plan tests 9 + +call_cmd() { + $dir/../count-fail-ratio $* +} + +rc=0 +output=$(runs=3 call_cmd true 2>&1) || rc=$? +is "$rc" 0 'successful run for no fails' +like "$output" 'Run: 3. Fails: 0. Fail ratio 0.*%. No fails, computed failure probability < 100.00%' 'counted all successes' + +rc=0 +output=$(runs=30 call_cmd true 2>&1) || rc=$? +is "$rc" 0 'successful run for many no fails' +like "$output" 'Run: 30. Fails: 0. Fail ratio 0.*%.*< 10.00%' 'computed failure probability lowers to < 10% for enough runs' + +rc=0 +output=$(runs=3 call_cmd false 2>&1) || rc=$? +is "$rc" 0 'successful run for all fails' +like "$output" 'count-fail-ratio: Run: 3. Fails: 3. Fail ratio 100.00.*%' 'counted all fails' + +rc=0 +tmp="${tmp:-"/tmp/tmp.fail-once-every-third-call"}" +echo 0 > $tmp +output=$(runs=10 call_cmd $dir/fail-once-every-third-call 2>&1) || rc=$? +is "$rc" 0 'successful run for sporadically failing script' +like "$output" 'count-fail-ratio: Run: 10. Fails: 3. Fail ratio 30.00±28.40%' 'counted sporadic failure' + +output=$(runs=1 timing=1 call_cmd false 2>&1) +like "$output" 'mean runtime' 'timing info shows up' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/retry-1700850441.829db9e/test/fail-once-every-third-call new/retry-1711985904.b9b8f3b/test/fail-once-every-third-call --- old/retry-1700850441.829db9e/test/fail-once-every-third-call 1970-01-01 01:00:00.000000000 +0100 +++ new/retry-1711985904.b9b8f3b/test/fail-once-every-third-call 2024-04-01 17:38:24.000000000 +0200 @@ -0,0 +1,12 @@ +#!/bin/bash +TMPDIR="${TMPDIR:-"/tmp"}" +tmp="${tmp:-"$TMPDIR/tmp.$(basename "$0")"}" +if [ -e "$tmp" ]; then + attempts="$(cat "$tmp")" +fi +if [[ -z "$attempts" ]]; then + attempts=0 +fi +((attempts++)) +echo "$attempts" > "$tmp" +((attempts%3)) ++++++ retry.obsinfo ++++++ --- /var/tmp/diff_new_pack.U4KWZb/_old 2024-04-02 16:45:08.346994021 +0200 +++ /var/tmp/diff_new_pack.U4KWZb/_new 2024-04-02 16:45:08.362994593 +0200 @@ -1,5 +1,5 @@ name: retry -version: 1700850441.829db9e -mtime: 1700850441 -commit: 829db9e3f5e511bf4fd4149654c1723b5d97f9ca +version: 1711985904.b9b8f3b +mtime: 1711985904 +commit: b9b8f3b914334e7dc1447a7185bac074ec29dc26