Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hamza
erp5
Commits
df85ed15
Commit
df85ed15
authored
Jan 10, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TaskDistributionTool: do not use countMessage, which could lead to race conditions in this context
parent
b6307fe2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
30 deletions
+19
-30
product/ERP5/Tool/TaskDistributionTool.py
product/ERP5/Tool/TaskDistributionTool.py
+19
-30
No files found.
product/ERP5/Tool/TaskDistributionTool.py
View file @
df85ed15
...
@@ -46,9 +46,6 @@ class TaskDistributionTool(BaseTool):
...
@@ -46,9 +46,6 @@ class TaskDistributionTool(BaseTool):
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
def
__init__
(
self
,
*
args
,
**
kw
):
BaseTool
.
__init__
(
self
,
*
args
,
**
kw
)
security
.
declarePublic
(
'getProtocolRevision'
)
security
.
declarePublic
(
'getProtocolRevision'
)
def
getProtocolRevision
(
self
):
def
getProtocolRevision
(
self
):
"""
"""
...
@@ -84,19 +81,6 @@ class TaskDistributionTool(BaseTool):
...
@@ -84,19 +81,6 @@ class TaskDistributionTool(BaseTool):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
if
test_title
is
None
:
if
test_title
is
None
:
test_title
=
name
test_title
=
name
tag
=
"test_result_creation_%s"
%
test_title
# If there is already pending creation, we raise error, the testnode
# will automatically retry later
assert
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
==
0
,
\
"There is already a test result under creation"
test_result_path
=
None
result_list
=
portal
.
test_result_module
.
searchFolder
(
portal_type
=
"Test Result"
,
simulation_state
=
"started"
,
title
=
test_title
,
sort_on
=
[(
"creation_date"
,
"descending"
)])
if
len
(
result_list
):
test_result_path
=
result_list
[
0
].
getRelativeUrl
()
def
createNode
(
test_result
,
node_title
):
def
createNode
(
test_result
,
node_title
):
if
node_title
is
not
None
:
if
node_title
is
not
None
:
node
=
self
.
_getTestResultNode
(
test_result
,
node_title
)
node
=
self
.
_getTestResultNode
(
test_result
,
node_title
)
...
@@ -138,9 +122,14 @@ class TaskDistributionTool(BaseTool):
...
@@ -138,9 +122,14 @@ class TaskDistributionTool(BaseTool):
else
:
else
:
# backward compatibility
# backward compatibility
int_index
,
reference
=
revision
int_index
,
reference
=
revision
test_result
=
None
result_list
=
portal
.
test_result_module
.
searchFolder
(
if
test_result_path
:
portal_type
=
"Test Result"
,
test_result
=
portal
.
unrestrictedTraverse
(
test_result_path
,
None
)
simulation_state
=
"started"
,
title
=
test_title
,
sort_on
=
((
"creation_date"
,
"descending"
),),
limit
=
1
)
if
result_list
:
test_result
=
result_list
[
0
].
getObject
()
if
test_result
is
None
or
test_result
.
getSimulationState
()
in
\
if
test_result
is
None
or
test_result
.
getSimulationState
()
in
\
(
'cancelled'
,
'failed'
):
(
'cancelled'
,
'failed'
):
pass
pass
...
@@ -156,9 +145,9 @@ class TaskDistributionTool(BaseTool):
...
@@ -156,9 +145,9 @@ class TaskDistributionTool(BaseTool):
last_revision
=
last_revision
,
reference
last_revision
=
last_revision
,
reference
if
len
(
test_result
.
objectValues
(
portal_type
=
"Test Result Line"
))
==
0
\
if
len
(
test_result
.
objectValues
(
portal_type
=
"Test Result Line"
))
==
0
\
and
len
(
test_name_list
):
and
len
(
test_name_list
):
self
.
_p_changed
=
1
# avoid two parallel creation
test_result
.
serialize
()
# prevent duplicate test result lines
createTestResultLineList
(
test_result
,
test_name_list
)
createTestResultLineList
(
test_result
,
test_name_list
)
return
test_result
_path
,
last_revision
return
test_result
.
getRelativeUrl
()
,
last_revision
if
last_state
==
'stopped'
:
if
last_state
==
'stopped'
:
if
reference_list_string
is
not
None
:
if
reference_list_string
is
not
None
:
if
reference_list_string
==
test_result
.
getReference
():
if
reference_list_string
==
test_result
.
getReference
():
...
@@ -169,25 +158,25 @@ class TaskDistributionTool(BaseTool):
...
@@ -169,25 +158,25 @@ class TaskDistributionTool(BaseTool):
portal_type
=
'Test Result'
,
portal_type
=
'Test Result'
,
title
=
test_title
,
title
=
test_title
,
reference
=
reference
,
reference
=
reference
,
predecessor
=
test_result_path
,
is_indexable
=
False
)
activate_kw
=
{
"tag"
:
tag
})
if
int_index
is
not
None
:
if
int_index
is
not
None
:
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
=
'="%s"'
%
project_title
)
if
len
(
project_list
)
==
1
:
if
len
(
project_list
)
!=
1
:
test_result
.
setSourceProjectValue
(
project_list
[
0
].
getObject
())
else
:
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
))
test_result
.
_setSourceProjectValue
(
project_list
[
0
].
getObject
())
test_result
.
updateLocalRolesOnSecurityGroups
()
# XXX
test_result
.
updateLocalRolesOnSecurityGroups
()
# XXX
test_result_path
=
test_result
.
getRelativeUrl
()
self
.
_p_changed
=
1
test_result
.
start
()
test_result
.
start
()
del
test_result
.
isIndexable
test_result
.
immediateReindexObject
()
self
.
serialize
()
# prevent duplicate test result
# following 2 functions only call 'newContent' on test_result
createTestResultLineList
(
test_result
,
test_name_list
)
createTestResultLineList
(
test_result
,
test_name_list
)
createNode
(
test_result
,
node_title
)
createNode
(
test_result
,
node_title
)
return
test_result
_path
,
revision
return
test_result
.
getRelativeUrl
()
,
revision
security
.
declarePublic
(
'startUnitTest'
)
security
.
declarePublic
(
'startUnitTest'
)
def
startUnitTest
(
self
,
test_result_path
,
exclude_list
=
()):
def
startUnitTest
(
self
,
test_result_path
,
exclude_list
=
()):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment