You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2022/12/12 07:14:24 UTC

[cloudstack] branch main updated: api: fixed flaky test (#6967)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 8aaa5edaa14 api: fixed flaky test (#6967)
8aaa5edaa14 is described below

commit 8aaa5edaa14da960943eaacd31acfd32782dd755
Author: tt0suzy <tt...@gmail.com>
AuthorDate: Mon Dec 12 01:14:14 2022 -0600

    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.
---
 .../org/apache/cloudstack/api/command/test/ResetVMUserDataCmdTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/src/test/java/org/apache/cloudstack/api/command/test/ResetVMUserDataCmdTest.java b/api/src/test/java/org/apache/cloudstack/api/command/test/ResetVMUserDataCmdTest.java
index e975138420a..afd5bd79827 100644
--- a/api/src/test/java/org/apache/cloudstack/api/command/test/ResetVMUserDataCmdTest.java
+++ b/api/src/test/java/org/apache/cloudstack/api/command/test/ResetVMUserDataCmdTest.java
@@ -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);
     }
 
 }