Commit 8cc256c8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use '=' comparison operator explicitly in title search.

otherwise full text index is used where keywords that appear in more than 50% of rows are ignored.
parent 55985c7d
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
############################################################################## ##############################################################################
from Products.ERP5.Document.ERP5ProjectUnitTestDistributor import ERP5ProjectUnitTestDistributor from Products.ERP5.Document.ERP5ProjectUnitTestDistributor import ERP5ProjectUnitTestDistributor
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from zLOG import LOG,ERROR from zLOG import LOG,ERROR
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -110,7 +111,10 @@ class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor): ...@@ -110,7 +111,10 @@ class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor):
tag = "%s_%s" % (self.getRelativeUrl(), title) tag = "%s_%s" % (self.getRelativeUrl(), title)
if portal.portal_activities.countMessageWithTag(tag) == 0: if portal.portal_activities.countMessageWithTag(tag) == 0:
test_node_list = test_node_module.searchFolder(portal_type="Test Node",title=title) test_node_list = test_node_module.searchFolder(
portal_type="Test Node",
title=SimpleQuery(comparison_operator='=', title=title),
)
assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title
test_node = None test_node = None
if len(test_node_list) == 1: if len(test_node_list) == 1:
...@@ -129,7 +133,8 @@ class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor): ...@@ -129,7 +133,8 @@ class ERP5ScalabilityDistributor(ERP5ProjectUnitTestDistributor):
isMasterTestnode : return True if the node given in parameter exists and is a validated master isMasterTestnode : return True if the node given in parameter exists and is a validated master
""" """
test_node_module = self._getTestNodeModule() test_node_module = self._getTestNodeModule()
test_node_master = [ node for node in test_node_module.searchFolder(portal_type="Test Node", title=title, test_node_master = [ node for node in test_node_module.searchFolder(portal_type="Test Node",
title=SimpleQuery(comparison_operator='=', title=title),
specialise_uid=self.getUid(), specialise_uid=self.getUid(),
validation_state="validated") if node.getMaster() == 1 ] validation_state="validated") if node.getMaster() == 1 ]
if len(test_node_master) == 1: if len(test_node_master) == 1:
......
...@@ -37,7 +37,7 @@ import string ...@@ -37,7 +37,7 @@ import string
from zLOG import LOG,INFO,ERROR from zLOG import LOG,INFO,ERROR
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ZSQLCatalog.SQLCatalog import Query from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
TEST_SUITE_MAX = 4 TEST_SUITE_MAX = 4
# Depending on the test suite priority, we will affect # Depending on the test suite priority, we will affect
# more or less cores # more or less cores
...@@ -210,7 +210,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -210,7 +210,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
tag = "%s_%s" % (self.getRelativeUrl(), title) tag = "%s_%s" % (self.getRelativeUrl(), title)
if portal.portal_activities.countMessageWithTag(tag) == 0: if portal.portal_activities.countMessageWithTag(tag) == 0:
test_node_list = test_node_module.searchFolder(portal_type="Test Node",title=title) test_node_list = test_node_module.searchFolder(
portal_type="Test Node",
title=SimpleQuery(comparison_operator='=', title=title),
)
assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title
test_node = None test_node = None
if len(test_node_list) == 1: if len(test_node_list) == 1:
...@@ -244,9 +247,11 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -244,9 +247,11 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
from_date = now - 30 from_date = now - 30
def getTestSuiteSortKey(test_suite): def getTestSuiteSortKey(test_suite):
test_result = portal.portal_catalog(portal_type="Test Result", test_result = portal.portal_catalog(portal_type="Test Result",
title='="%s"' % test_suite.getTitle(), title=SimpleQuery(title=test_suite.getTitle()),
modification_date=Query(**{"creation_date": from_date, creation_date=SimpleQuery(
"range": "min"}), creation_date=from_date,
comparison_operator='>=',
),
sort_on=[("modification_date", "descending")], sort_on=[("modification_date", "descending")],
limit=1) limit=1)
if len(test_result): if len(test_result):
...@@ -268,7 +273,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -268,7 +273,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
config_list = [] config_list = []
tag = "%s_%s" % (self.getRelativeUrl(), title) tag = "%s_%s" % (self.getRelativeUrl(), title)
if portal.portal_activities.countMessageWithTag(tag) == 0: if portal.portal_activities.countMessageWithTag(tag) == 0:
test_node_list = test_node_module.searchFolder(portal_type="Test Node",title=title) test_node_list = test_node_module.searchFolder(
portal_type="Test Node",
title=SimpleQuery(comparison_operator='=', title=title),
)
assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title assert len(test_node_list) in (0, 1), "Unable to find testnode : %s" % title
test_node = None test_node = None
if len(test_node_list) == 1: if len(test_node_list) == 1:
...@@ -329,7 +337,9 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -329,7 +337,9 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
def _getTestNodeFromTitle(self, node_title): def _getTestNodeFromTitle(self, node_title):
test_node_list = self._getTestNodeModule().searchFolder( test_node_list = self._getTestNodeModule().searchFolder(
portal_type='Test Node', title="='%s'" % node_title) portal_type="Test Node",
title=SimpleQuery(comparison_operator='=', title=node_title),
)
assert len(test_node_list) == 1, "We found %i test nodes for %s" % ( assert len(test_node_list) == 1, "We found %i test nodes for %s" % (
len(test_node_list), node_title) len(test_node_list), node_title)
test_node = test_node_list[0].getObject() test_node = test_node_list[0].getObject()
...@@ -337,7 +347,9 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -337,7 +347,9 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
def _getTestSuiteFromTitle(self, suite_title): def _getTestSuiteFromTitle(self, suite_title):
test_suite_list = self._getTestSuiteModule().searchFolder( test_suite_list = self._getTestSuiteModule().searchFolder(
portal_type='Test Suite', title="='%s'" % suit_tile, validation_state="validated") portal_type='Test Suite',
title=SimpleQuery(comparison_operator='=', title=suite_title),
validation_state='validated')
assert len(test_suite_list) == 1, "We found %i test suite for %s" % ( assert len(test_suite_list) == 1, "We found %i test suite for %s" % (
len(test_suite_list), name) len(test_suite_list), name)
test_suite = test_suite_list[0].getObject() test_suite = test_suite_list[0].getObject()
......
...@@ -30,6 +30,7 @@ import random ...@@ -30,6 +30,7 @@ import random
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
from zLOG import LOG from zLOG import LOG
from xmlrpclib import Binary from xmlrpclib import Binary
...@@ -91,7 +92,7 @@ class TaskDistributionTool(BaseTool): ...@@ -91,7 +92,7 @@ class TaskDistributionTool(BaseTool):
def createTestResultLineList(test_result, test_name_list): def createTestResultLineList(test_result, test_name_list):
duration_list = [] duration_list = []
previous_test_result_list = portal.test_result_module.searchFolder( previous_test_result_list = portal.test_result_module.searchFolder(
title='="%s"' % test_result.getTitle(), title=SimpleQuery(comparison_operator='=', title=test_result.getTitle()),
sort_on=[('creation_date','descending')], sort_on=[('creation_date','descending')],
simulation_state=('stopped', 'public_stopped'), simulation_state=('stopped', 'public_stopped'),
limit=1) limit=1)
...@@ -126,7 +127,7 @@ class TaskDistributionTool(BaseTool): ...@@ -126,7 +127,7 @@ class TaskDistributionTool(BaseTool):
int_index, reference = revision int_index, reference = revision
result_list = portal.test_result_module.searchFolder( result_list = portal.test_result_module.searchFolder(
portal_type="Test Result", portal_type="Test Result",
title='="%s"' % test_title, title=SimpleQuery(comparison_operator='=', title=test_title),
sort_on=(("creation_date","descending"),), sort_on=(("creation_date","descending"),),
limit=1) limit=1)
if result_list: if result_list:
...@@ -162,7 +163,7 @@ class TaskDistributionTool(BaseTool): ...@@ -162,7 +163,7 @@ class TaskDistributionTool(BaseTool):
test_result._setIntIndex(int_index) test_result._setIntIndex(int_index)
if project_title is not None: if project_title is not None:
project_list = portal.portal_catalog(portal_type='Project', project_list = portal.portal_catalog(portal_type='Project',
title='="%s"' % project_title) title=SimpleQuery(comparison_operator='=', title=project_title))
if len(project_list) != 1: if len(project_list) != 1:
raise ValueError('found this list of project : %r for title %r' % \ raise ValueError('found this list of project : %r for title %r' % \
([x.path for x in project_list], project_title)) ([x.path for x in project_list], project_title))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment