Closed jishnub closed 3 months ago
Hmmm this'll be a bit tricky to fix properly :/ UUID7 has a time dependency as well, and there's no easy way to substitute that at the moment. It uses the timestamp with millisecond precision, and I would have expected these two calls to be close enough together for that to work out it CI. Unfortunate that it isn't, due to the highly parallel load on CI..
time()
does a ccall
under the hood, which apparently introduces enough jitter to make this test fail. We could disable this particular test, but that would also mean not testing that the RNG state is important. Alternatively, the internal function could be split so that the time component is added afterwards, and the RNG specific parts are tested seperately?
Alternatively, the internal function could be split so that the time component is added afterwards, and the RNG specific parts are tested seperately?
Yeah, defining an internal function which takes the time as input looks the easiest option (unless adding a timestamp argument to uuid7 is an option?)
I would add the timestamp argument to uuid7. Seems like a reasonable API addition.
The same problem would also exist with uuid1
, since that also has a dependency on time()
and an RNG. It's just not exposed due to that particular behavior not being tested, it seems.
I'm in principle open to adding a method to uuid7
(the timestamp is just milliseconds since the unix epoch), but for uuid1
that's a bit more complicated:
UUIDv1 is a time-based UUID featuring a 60-bit timestamp represented by Coordinated Universal Time (UTC) as a count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).
So if we want this, IMO the best way would be just taking in a Float64
(as if generated by time()
, so UNIX time) and doing the required transforms internally ourselves.
Looking at the tests again - turns out we're not even using the dedicated test vectors from the RFC :melting_face: I'll rework that in the coming week so that we can make use of those too.
Seen in https://buildkite.com/julialang/julia-master/builds/38290#0190cfa0-2041-4c0a-811a-2dd9bea0a58e
The difference in the two appears to be in the
cab8
vscab9
segments.