Commit 0dbd2ed8 authored by Sebastien Robin's avatar Sebastien Robin Committed by Rafael Monnerat

test_result: make constraints working on test suites, cleanup of property settings

Most properties of test suite and test suite repository were by mistake set with type "lines" instead
of strings. Due to this, constraints where not working (for checking missing properties). Also, workflow
was not properly set to check constraints. So at the end, most constraints were ignored.

Change properties from type lines to type string. Add test for constraitns. Add compatiblity code
to do transparent migration of existing tests suites and test suite repositories.

Remove obsolete properties and constraints.
parent 0ad8ea27
......@@ -2,6 +2,7 @@ from Products.ERP5Type.XMLObject import XMLObject
from DateTime import DateTime
from zLOG import LOG,INFO,ERROR
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions
from Products.ERP5.mixin.periodicity import PeriodicityMixin
......@@ -30,4 +31,27 @@ class TestSuite(XMLObject, PeriodicityMixin):
return portal.portal_task_distribution.getMemcachedDict().get(
"%s_ping_date" % (self.getRelativeUrl()))
# Compatibility Code to be removed after 06/2018, since all instances using
# test suites should be migrated at that time. Purpose here was to fix the
# setting of some properties that were defined with type "lines" instead of "string".
# This was making the property existence constraint not working properly.
def _fixPropertyConsistency(self):
self = aq_base(self)
for property_name in ('additional_bt5_repository_id', 'test_suite'):
property_value = getattr(self, property_name, None)
if property_value is not None and isinstance(property_value, tuple):
if len(property_value) > 0:
property_value = property_value[0]
setattr(self, property_name, property_value)
else:
delattr(self, property_name)
def getAdditionalBt5RepositoryId(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetAdditionalBt5RepositoryId(*args, **kw)
def getTestSuite(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetTestSuite(*args, **kw)
# End of compatibility code
\ No newline at end of file
from Products.ERP5Type.XMLObject import XMLObject
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Acquisition import aq_base
class TestSuiteRepository(XMLObject):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Compatibility Code to be removed after 06/2018, since all instances using
# test suites should be migrated at that time. Purpose here was to fix the
# setting of some properties that were defined with type "lines" instead of "string".
# This was making the property existence constraint not working properly.
def _fixPropertyConsistency(self):
self = aq_base(self)
for property_name in ('branch', 'buildout_section_id', 'git_url', 'profile_path'):
property_value = getattr(self, property_name, None)
if property_value is not None and isinstance(property_value, tuple):
if len(property_value) > 0:
property_value = property_value[0]
setattr(self, property_name, property_value)
else:
delattr(self, property_name)
def getBranch(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetBranch(*args, **kw)
def getBuildoutSectionId(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetBuildoutSectionId(*args, **kw)
def getGitUrl(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetGitUrl(*args, **kw)
def getProfilePath(self, *args, **kw):
self._fixPropertyConsistency()
return self._baseGetProfilePath(*args, **kw)
# End of compatibility code
\ No newline at end of file
......@@ -2,62 +2,61 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Existence Constraint" module="erp5.portal_type"/>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<key> <string>default_reference</string> </key>
<value> <string>TestSuiteRepository</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<tuple>
<dictionary>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
<value> <string>document.erp5.TestSuiteRepository</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<key> <string>sid</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<none/>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple>
<string>test_suite_title</string>
</tuple>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Test Suite Title is mandatory</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_suite_title_constraint</string> </value>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Test Suite Title is mandatory</string> </value>
<key> <string>version</string> </key>
<value> <string>woelfel</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Existence Constraint</string> </value>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
......@@ -86,10 +85,39 @@
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -48,7 +48,7 @@
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>TextDocument</string> </value>
<value> <string>TestSuiteRepository</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
......
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>node_max_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>node_min_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>reference_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_suite_title_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>url_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import json
from time import sleep
......@@ -111,7 +112,6 @@ class TestTaskDistribution(ERP5TypeTestCase):
test_suite = self.test_suite_module.newContent(
portal_type = portal_type,
title = test_suite_title,
test_suite_title = test_suite_title,
test_suite = 'B%i' % i,
int_index = priority,
specialise_value = specialise_value,
......@@ -151,6 +151,19 @@ class TestTaskDistribution(ERP5TypeTestCase):
self.assertEquals(scalability_test_suite.getSpecialise(),
self.scalability_distributor.getRelativeUrl())
def test_02b_checkConsistencyOnTestSuite(self):
test_suite, = self._createTestSuite()
self.tic()
test_suite_repository, = test_suite.objectValues(portal_type="Test Suite Repository")
self.checkPropertyConstraint(test_suite, 'title', 'ERP5-MASTER')
self.checkPropertyConstraint(test_suite, 'test_suite', 'ERP5')
self.checkPropertyConstraint(test_suite_repository, 'git_url', 'https://lab.nexedi.com/nexedi/erp5.git')
self.checkPropertyConstraint(test_suite_repository, 'buildout_section_id', 'erp5')
self.checkPropertyConstraint(test_suite_repository, 'branch', 'master')
test_suite_repository.setGitUrl(None)
test_suite.invalidate()
self.assertRaises(ValidationFailed, self.portal.portal_workflow.doActionFor, test_suite, 'validate_action')
def _callOptimizeAlarm(self):
self.portal.portal_alarms.task_distributor_alarm_optimize.activeSense()
self.tic()
......
......@@ -45,17 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:607, 4: Possible unbalanced tuple unpacking with sequence defined at line 105: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:634, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 2 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:727, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:734, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:735, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:742, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:743, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:758, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 1 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
<string>W:778, 4: Possible unbalanced tuple unpacking with sequence defined at line 88: left side has 2 label(s), right side has 0 value(s) (unbalanced-tuple-unpacking)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
......@@ -26,3 +26,5 @@ def generateRandomString(size):
if test_suite.getPortalType() == "Scalability Test Suite":
random_path = test_suite.getReference() + "_" + generateRandomString(64)
test_suite.setRandomizedPath(random_path)
test_suite.TestDocument_optimize()
......@@ -10,6 +10,10 @@
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
......@@ -20,7 +24,7 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
<value> <string>TestSuite_optimize</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>TestSuite_optimize</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>TestSuite_optimize</string> </value>
<value> <string>checkConsistency</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
document.erp5.TestNode
document.erp5.TestSuite
document.erp5.TestSuiteRepository
document.erp5.ERP5ScalabilityDistributor
document.erp5.SlapOSAgentDistributor
\ No newline at end of file
......@@ -433,6 +433,20 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
type_list.sort(key=lambda x: x.getCreationDate())
return type_list
def checkPropertyConstraint(self, document, property_name, value,
decreased_quantity=1, commit=False):
"""
Convenient method to check required properties on documents. It check that
number of consistency errors decrease when property is set
"""
document.setProperty(property_name, None)
initial_consistency_len = len(document.checkConsistency())
document.setProperty(property_name, value)
if commit:
self.commit()
self.assertEqual(len(document.checkConsistency()),
initial_consistency_len-decreased_quantity)
def _addPropertySheet(self, portal_type_name,
property_sheet_name='TestPropertySheet',
deprecated=None):
......
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