Eli Mesika has uploaded a new change for review.

Change subject: core: fix search on fedora 21
......................................................................

core: fix search on fedora 21

The problem was JDK 8 that is installed by default on f21
The search mechanism relies on column order retrieved from a map, it
seems that there are differences that cause that return the columns in
different order in JDK 8.
Code was changed to use a alphabetic order of the column names to build
the condition and relevant test expectations were updated accordingly.

Change-Id: I4e6f2cb0832dc21be9fab9f24858e6f7c4c613ba
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1163400
Signed-off-by: emesika <[email protected]>
---
M 
backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/BaseConditionFieldAutoCompleter.java
M 
backend/manager/modules/searchbackend/src/test/java/org/ovirt/engine/core/searchbackend/SyntaxCheckerTest.java
2 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/36282/1

diff --git 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/BaseConditionFieldAutoCompleter.java
 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/BaseConditionFieldAutoCompleter.java
index 62bb486..cecf4be 100644
--- 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/BaseConditionFieldAutoCompleter.java
+++ 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/BaseConditionFieldAutoCompleter.java
@@ -3,12 +3,15 @@
 import java.math.BigDecimal;
 import java.text.DateFormat;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.ovirt.engine.core.common.businessentities.DateEnumForSearch;
 import org.ovirt.engine.core.common.businessentities.Tags;
@@ -164,7 +167,10 @@
         } else if ("!=".equals(relations)) {
             relations = "NOT " + getLikeSyntax(caseSensitive);
         }
-        for (Map.Entry<String, String> columnNameEntry : 
columnNameDict.entrySet()) {
+        // Sort according to the value (real column name) in order not to rely 
on random access from map
+        SortedSet<Map.Entry<String, String>> sortedEntrySet = new 
TreeSet<>(new ColNameMapEntryComparator());
+        sortedEntrySet.addAll(columnNameDict.entrySet());
+        for (Map.Entry<String, String> columnNameEntry : sortedEntrySet) {
             if (typeDict.get(columnNameEntry.getKey()) == String.class && 
!notFreeTextSearchableFieldsList.contains(columnNameEntry.getKey())) {
                 if (firstTime) {
                     firstTime = false;
@@ -392,4 +398,13 @@
     public String getWildcard(String fieldName) {
         return verbsWithMultipleValues.contains(fieldName) ? ".*" : "%";
     }
+
+    public static class ColNameMapEntryComparator implements 
Comparator<Map.Entry<String, String>> {
+
+        @Override
+        public int compare(Map.Entry<String, String> e1, Map.Entry<String, 
String> e2) {
+            return e1.getValue().compareTo(e2.getValue());
+        }
+    }
+
 }
diff --git 
a/backend/manager/modules/searchbackend/src/test/java/org/ovirt/engine/core/searchbackend/SyntaxCheckerTest.java
 
b/backend/manager/modules/searchbackend/src/test/java/org/ovirt/engine/core/searchbackend/SyntaxCheckerTest.java
index 55e7994..9d46354 100644
--- 
a/backend/manager/modules/searchbackend/src/test/java/org/ovirt/engine/core/searchbackend/SyntaxCheckerTest.java
+++ 
b/backend/manager/modules/searchbackend/src/test/java/org/ovirt/engine/core/searchbackend/SyntaxCheckerTest.java
@@ -184,7 +184,7 @@
 
         // Used to validate that searching values not in fields search all 
fields
         testValidSql("Vm: mac=00:1a:4a:d4:53:94",
-                "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT 
distinct vms_with_tags.vm_guid FROM  vms_with_tags   WHERE  (  
vms_with_tags.vm_pool_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.run_on_vds_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.vm_fqdn LIKE '%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.tag_name 
LIKE '%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.guest_cur_user_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.description LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.quota_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_host LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_ip LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.storage_pool_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vds_group_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.free_text_comment LIKE 
'%mac=00:1a:4a:d4:53:94%' ) ))  ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMI!
 T 0");
+                "SELECT * FROM (SELECT * FROM vms WHERE ( vm_guid IN (SELECT 
distinct vms_with_tags.vm_guid FROM  vms_with_tags   WHERE  (  
vms_with_tags.description LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.free_text_comment LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.guest_cur_user_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.quota_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.run_on_vds_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.storage_pool_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.tag_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.vds_group_name LIKE '%mac=00:1a:4a:d4:53:94%' OR  
vms_with_tags.vm_fqdn LIKE '%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_host 
LIKE '%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_ip LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_name LIKE 
'%mac=00:1a:4a:d4:53:94%' OR  vms_with_tags.vm_pool_name LIKE 
'%mac=00:1a:4a:d4:53:94%' ) ))  ORDER BY vm_name ASC ) as T1 OFFSET (1 -1) LIMI!
 T 0");
     }
 
     @Test


-- 
To view, visit http://gerrit.ovirt.org/36282
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e6f2cb0832dc21be9fab9f24858e6f7c4c613ba
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to