> We do not rely on the order. So our algorithms would be still correct. But
> they wouldn't produce identical results. E.g. it can easily happen that two
> routes have exactly the same distance (even in real world!) and with one
> hash ordering we return one path of those optimal solution, and another hash
> ordering produces a different path.
That's exactly what I'm saying -- if this is the case then you are
relying on map ordering and your algorithm's result
is predictably non-deterministic. If the two routes have an equivalent
score then returning any of them as a result should
be an acceptable output (and the tests should take this into
account!). If consistency is part of the returned output's contract
then all pareto-optimal solutions should be sorted to a secondary
criterion (say, the ordering of node IDs or something), so that the
output is always consistent, regardless of intermediate ordering of
associative data structures.
> To be honest: I still do not see this problem for us (and as we used trove4j
> which highly likely suffers from the same issue),
This isn't something that is very likely, but if it bites, it'll hang
your application at runtime.
> Again, I'll investigate this more - maybe we get some performance boosts
> with random seeds which would show that we already have/had a problem here
> :)
It'd be more likely that you get more uniform, but a bit slower runs.
>> So yes, a single test won't reproduce in the same way in isolation
>> compared to executing it from a global suite.
>
> But this makes no sense to me. A test should return the same stuff in
> isolation, as it does for a test suite. Otherwise it is highly confusing.
A test that is independent of any global state would return the same
result. A test that relies on some global state (as in mutable static
test fixtures, system properties, file system state, you name it) may
not be reproducible with the same seed. People are often locked
in to the notion of "identical" test runs, which is a bad assumption
in general. Think of test method ordering in Java 8 that all of a
sudden stopped being predictable -- many tests crashed just because
the global state wasn't accessed in the same order.
Yes, it is true that random hash map mixers make it very difficult to
create an immutable test fixture (or a repeatable test run detached
from its global state). But then again -- I'd embrace this
randomness rather than fight with it. If your tests run with changing
map/set iteration order, they'll be more rebust.
Look at Lucene tests -- they shuffle stuff (components, locales, time
zones) underneath all tests in all sorts of ways and occasionally
things break. But it's quite rare that something is not reproducible
at all (once it's narrowed down, you can typically write a repro for
it). If something non-reproducible happens, it's typically a VM
problem...
Dawid