mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
api: fixed flaky test (#6967)
Similar as 6875. The test org.apache.cloudstack.api.command.test.ResetVMUserDataCmdTest.testUserdataDetails, is a flaky tests. It can pass mvn test but when run using the tool NonDex, it fails. NonDex is a tool that will introduce non-determinism in certain java collections. The cause of failure is because the test is comparing the string format of two hashmaps, however, as per Oracle's documentation: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time. So the result of toString() is non-deterministic. Use hashmap's own equal methods is more reasonable.
This commit is contained in:
parent
ed1ac1c161
commit
8aaa5edaa1
@ -132,7 +132,7 @@ public class ResetVMUserDataCmdTest {
|
||||
Map<String, String> result = cmd.getUserdataDetails();
|
||||
|
||||
values1.putAll(values2);
|
||||
Assert.assertEquals(values1.toString(), result.toString());
|
||||
Assert.assertEquals(values1, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user