Thread (2 messages) flat view 2 messages, 2 authors, 2020-10-13

Re: [PATCH] remote-curl: add testing for intelligent retry for HTTP

From: Johannes Schindelin <hidden>
Date: 2020-10-13 14:25:32

Hi Junio,

On Mon, 12 Oct 2020, Junio C Hamano wrote:
Sean McAllister [off-list ref] writes:
quoted
quoted
Sean McAllister [off-list ref] writes:
quoted
+# generate a random 12 digit string
+gen_nonce() {
+    test_copy_bytes 12 < /dev/urandom | tr -dc A-Za-z0-9
+}
What is the randomness requirement of this application?  IOW, what
breaks if we just change this to "echo 0123456789ab"?

Or "date | git hash-object --stdin" for that matter?

We'd want to make our tests more predictiable, not less.
The randomness requirement is just that I need nonces to be unique
during a single run of the HTTP server
as they uniquefy the files I put on disk to make the HTTP hack-ily
stateful.  I'd be fine with your date/hash-object
solution, but I don't know that it will help make the tests more predictable.
If so, would something like this be

    global_counter_for_nonce=0
    gen_nonce () {
	global_counter_for_nonce=$(( global_counter_for_nonce + 1 )) &&
	echo "$global_counter_for_nonce"
    }

more appropriate?  It is utterly predictable and yields the same
answer only once during a single run.
We should also consider using `test-tool genrandom <seed>` instead (where
`<seed>` would have to be predictable, but probably would have to change
between `gen_nonce()` calls).

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help