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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
75b02b2a
Commit
75b02b2a
authored
Feb 15, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testnode was still sometimes logging at several files at a time
parent
3f126710
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
58 deletions
+52
-58
erp5/tests/testERP5TestNode.py
erp5/tests/testERP5TestNode.py
+26
-29
erp5/util/testnode/testnode.py
erp5/util/testnode/testnode.py
+26
-29
No files found.
erp5/tests/testERP5TestNode.py
View file @
75b02b2a
...
@@ -454,16 +454,13 @@ branch = foo
...
@@ -454,16 +454,13 @@ branch = foo
original_runTestSuite
=
test_node
.
runTestSuite
original_runTestSuite
=
test_node
.
runTestSuite
test_node
.
runTestSuite
=
doNothing
test_node
.
runTestSuite
=
doNothing
SlapOSControler
.
initializeSlapOSControler
=
doNothing
SlapOSControler
.
initializeSlapOSControler
=
doNothing
try
:
test_node
.
run
()
test_node
.
run
()
self
.
assertEquals
(
5
,
counter
)
except
Exception
as
e
:
time
.
sleep
=
original_sleep
self
.
assertEqual
(
type
(
e
),
StopIteration
)
TaskDistributor
.
startTestSuite
=
original_startTestSuite
finally
:
TaskDistributionTool
.
createTestResult
=
original_createTestResult
time
.
sleep
=
original_sleep
test_node
.
_prepareSlapOS
=
original_prepareSlapOS
TaskDistributor
.
startTestSuite
=
original_startTestSuite
test_node
.
runTestSuite
=
original_runTestSuite
TaskDistributionTool
.
createTestResult
=
original_createTestResult
test_node
.
_prepareSlapOS
=
original_prepareSlapOS
test_node
.
runTestSuite
=
original_runTestSuite
def
test_12_spawn
(
self
):
def
test_12_spawn
(
self
):
def
_checkCorrectStatus
(
expected_status
,
*
args
):
def
_checkCorrectStatus
(
expected_status
,
*
args
):
...
@@ -512,12 +509,11 @@ branch = foo
...
@@ -512,12 +509,11 @@ branch = foo
counter
=
0
counter
=
0
def
patch_startTestSuite
(
self
,
test_node_title
):
def
patch_startTestSuite
(
self
,
test_node_title
):
global
counter
global
counter
config_list
=
[]
config_list
=
[
test_self
.
getTestSuiteData
(
reference
=
'aa'
)[
0
],
if
counter
==
0
:
test_self
.
getTestSuiteData
(
reference
=
'bb'
)[
0
]]
config_list
.
append
(
test_self
.
getTestSuiteData
(
reference
=
'aa'
)[
0
])
if
counter
in
(
1
,
2
):
if
counter
==
1
:
config_list
.
reverse
()
config_list
.
append
(
test_self
.
getTestSuiteData
(
reference
=
'bb'
)[
0
])
elif
counter
==
3
:
elif
counter
==
2
:
raise
StopIteration
raise
StopIteration
counter
+=
1
counter
+=
1
return
json
.
dumps
(
config_list
)
return
json
.
dumps
(
config_list
)
...
@@ -530,9 +526,10 @@ branch = foo
...
@@ -530,9 +526,10 @@ branch = foo
def
checkTestSuite
(
test_node
):
def
checkTestSuite
(
test_node
):
test_node
.
node_test_suite_dict
test_node
.
node_test_suite_dict
rand_part_set
=
set
()
rand_part_set
=
set
()
self
.
assertEquals
(
2
,
len
(
test_node
.
node_test_suite_dict
))
assert
(
test_node
.
suite_log
is
not
None
)
assert
(
isinstance
(
test_node
.
suite_log
,
types
.
MethodType
))
for
ref
,
suite
in
test_node
.
node_test_suite_dict
.
items
():
for
ref
,
suite
in
test_node
.
node_test_suite_dict
.
items
():
assert
(
suite
.
suite_log
is
not
None
)
assert
(
isinstance
(
suite
.
suite_log
,
types
.
MethodType
))
self
.
assertTrue
(
'var/log/testnode/%s'
%
suite
.
reference
in
\
self
.
assertTrue
(
'var/log/testnode/%s'
%
suite
.
reference
in
\
suite
.
suite_log_path
,
suite
.
suite_log_path
,
"Incorrect suite log path : %r"
%
suite
.
suite_log_path
)
"Incorrect suite log path : %r"
%
suite
.
suite_log_path
)
...
@@ -542,6 +539,9 @@ branch = foo
...
@@ -542,6 +539,9 @@ branch = foo
assert
(
len
(
rand_part
)
==
32
)
assert
(
len
(
rand_part
)
==
32
)
assert
(
rand_part
not
in
rand_part_set
)
assert
(
rand_part
not
in
rand_part_set
)
rand_part_set
.
add
(
rand_part
)
rand_part_set
.
add
(
rand_part
)
suite_log
=
open
(
suite
.
suite_log_path
,
'r'
)
self
.
assertEquals
(
1
,
len
([
x
for
x
in
suite_log
.
readlines
()
\
if
x
.
find
(
"Activated logfile"
)
>=
0
]))
original_sleep
=
time
.
sleep
original_sleep
=
time
.
sleep
time
.
sleep
=
doNothing
time
.
sleep
=
doNothing
...
@@ -556,17 +556,14 @@ branch = foo
...
@@ -556,17 +556,14 @@ branch = foo
original_runTestSuite
=
test_node
.
runTestSuite
original_runTestSuite
=
test_node
.
runTestSuite
test_node
.
runTestSuite
=
doNothing
test_node
.
runTestSuite
=
doNothing
SlapOSControler
.
initializeSlapOSControler
=
doNothing
SlapOSControler
.
initializeSlapOSControler
=
doNothing
try
:
test_node
.
run
()
test_node
.
run
()
self
.
assertEquals
(
counter
,
3
)
except
Exception
as
e
:
checkTestSuite
(
test_node
)
checkTestSuite
(
test_node
)
time
.
sleep
=
original_sleep
self
.
assertEqual
(
type
(
e
),
StopIteration
)
TaskDistributor
.
startTestSuite
=
original_startTestSuite
finally
:
TaskDistributionTool
.
createTestResult
=
original_createTestResult
time
.
sleep
=
original_sleep
test_node
.
_prepareSlapOS
=
original_prepareSlapOS
TaskDistributor
.
startTestSuite
=
original_startTestSuite
test_node
.
runTestSuite
=
original_runTestSuite
TaskDistributionTool
.
createTestResult
=
original_createTestResult
test_node
.
_prepareSlapOS
=
original_prepareSlapOS
test_node
.
runTestSuite
=
original_runTestSuite
def
test_16_cleanupLogDirectory
(
self
):
def
test_16_cleanupLogDirectory
(
self
):
# Make sure that we are able to cleanup old log folders
# Make sure that we are able to cleanup old log folders
...
...
erp5/util/testnode/testnode.py
View file @
75b02b2a
...
@@ -89,7 +89,6 @@ class NodeTestSuite(SlapOSInstance):
...
@@ -89,7 +89,6 @@ class NodeTestSuite(SlapOSInstance):
def
__init__
(
self
,
reference
):
def
__init__
(
self
,
reference
):
super
(
NodeTestSuite
,
self
).
__init__
()
super
(
NodeTestSuite
,
self
).
__init__
()
self
.
reference
=
reference
self
.
reference
=
reference
self
.
file_handler
=
None
def
edit
(
self
,
**
kw
):
def
edit
(
self
,
**
kw
):
super
(
NodeTestSuite
,
self
).
edit
(
**
kw
)
super
(
NodeTestSuite
,
self
).
edit
(
**
kw
)
...
@@ -123,30 +122,11 @@ class NodeTestSuite(SlapOSInstance):
...
@@ -123,30 +122,11 @@ class NodeTestSuite(SlapOSInstance):
SlapOSControler
.
createFolders
(
suite_log_directory
)
SlapOSControler
.
createFolders
(
suite_log_directory
)
self
.
suite_log_path
=
os
.
path
.
join
(
suite_log_directory
,
self
.
suite_log_path
=
os
.
path
.
join
(
suite_log_directory
,
'suite.log'
)
'suite.log'
)
self
.
_initializeSuiteLog
()
return
self
.
getSuiteLogPath
(),
random_suite_folder_id
return
self
.
getSuiteLogPath
(),
random_suite_folder_id
def
getSuiteLogPath
(
self
):
def
getSuiteLogPath
(
self
):
return
getattr
(
self
,
"suite_log_path"
,
None
)
return
getattr
(
self
,
"suite_log_path"
,
None
)
def
getSuiteLog
(
self
):
return
getattr
(
self
,
"suite_log"
,
None
)
def
_initializeSuiteLog
(
self
):
# remove previous handlers
logger
=
logging
.
getLogger
(
'testsuite'
)
if
self
.
file_handler
is
not
None
:
logger
.
removeHandler
(
self
.
file_handler
)
# and replace it with new handler
logger_format
=
'%(asctime)s %(name)-13s: %(levelname)-8s %(message)s'
formatter
=
logging
.
Formatter
(
logger_format
)
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
logger_format
)
self
.
file_handler
=
logging
.
FileHandler
(
filename
=
self
.
suite_log_path
)
self
.
file_handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
self
.
file_handler
)
logger
.
info
(
'Activated logfile %r output'
%
self
.
suite_log_path
)
self
.
suite_log
=
logger
.
info
class
TestNode
(
object
):
class
TestNode
(
object
):
def
__init__
(
self
,
log
,
config
,
max_log_time
=
MAX_LOG_TIME
,
def
__init__
(
self
,
log
,
config
,
max_log_time
=
MAX_LOG_TIME
,
...
@@ -158,6 +138,7 @@ class TestNode(object):
...
@@ -158,6 +138,7 @@ class TestNode(object):
self
.
node_test_suite_dict
=
{}
self
.
node_test_suite_dict
=
{}
self
.
max_log_time
=
max_log_time
self
.
max_log_time
=
max_log_time
self
.
max_temp_time
=
max_temp_time
self
.
max_temp_time
=
max_temp_time
self
.
file_handler
=
None
def
checkOldTestSuite
(
self
,
test_suite_data
):
def
checkOldTestSuite
(
self
,
test_suite_data
):
config
=
self
.
config
config
=
self
.
config
...
@@ -252,20 +233,36 @@ branch = %(branch)s
...
@@ -252,20 +233,36 @@ branch = %(branch)s
Create a log dedicated for the test suite,
Create a log dedicated for the test suite,
and register the url to master node.
and register the url to master node.
"""
"""
log_file_name
,
folder_id
=
node_test_suite
.
createSuiteLog
()
suite_log_path
,
folder_id
=
node_test_suite
.
createSuiteLog
()
if
log_file_name
is
None
and
config
.
get
(
'log_file'
):
self
.
_initializeSuiteLog
(
suite_log_path
)
log_file_name
=
config
[
'log_file'
]
# TODO make the path into url
# TODO make the path into url
test_result
.
reportStatus
(
'LOG url'
,
"%s/%s"
%
(
self
.
config
.
get
(
'httpd_url'
),
test_result
.
reportStatus
(
'LOG url'
,
"%s/%s"
%
(
self
.
config
.
get
(
'httpd_url'
),
folder_id
),
''
)
folder_id
),
''
)
self
.
log
(
"going to switch to log %r"
%
log_file_name
)
self
.
log
(
"going to switch to log %r"
%
suite_log_path
)
log
=
node_test_suite
.
getSuiteLog
()
self
.
process_manager
.
log
=
self
.
log
=
self
.
getSuiteLog
()
self
.
process_manager
.
log
=
self
.
log
=
log
return
suite_log_path
return
log_file_name
def
getSuiteLog
(
self
):
return
self
.
suite_log
def
_initializeSuiteLog
(
self
,
suite_log_path
):
# remove previous handlers
logger
=
logging
.
getLogger
(
'testsuite'
)
if
self
.
file_handler
is
not
None
:
logger
.
removeHandler
(
self
.
file_handler
)
# and replace it with new handler
logger_format
=
'%(asctime)s %(name)-13s: %(levelname)-8s %(message)s'
formatter
=
logging
.
Formatter
(
logger_format
)
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
logger_format
)
self
.
file_handler
=
logging
.
FileHandler
(
filename
=
suite_log_path
)
self
.
file_handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
self
.
file_handler
)
logger
.
info
(
'Activated logfile %r output'
%
suite_log_path
)
self
.
suite_log
=
logger
.
info
def
checkRevision
(
self
,
test_result
,
node_test_suite
):
def
checkRevision
(
self
,
test_result
,
node_test_suite
):
config
=
self
.
config
config
=
self
.
config
log
=
node_test_suite
.
getSuiteLog
()
log
=
self
.
log
if
log
is
None
:
if
log
is
None
:
log
=
self
.
log
log
=
self
.
log
if
node_test_suite
.
revision
!=
test_result
.
revision
:
if
node_test_suite
.
revision
!=
test_result
.
revision
:
...
@@ -328,7 +325,7 @@ branch = %(branch)s
...
@@ -328,7 +325,7 @@ branch = %(branch)s
software_path_list
=
self
.
config
.
get
(
"software_list"
))
software_path_list
=
self
.
config
.
get
(
"software_list"
))
def
prepareSlapOSForTestSuite
(
self
,
node_test_suite
):
def
prepareSlapOSForTestSuite
(
self
,
node_test_suite
):
log
=
node_test_suite
.
getSuiteLog
()
log
=
self
.
log
if
log
is
None
:
if
log
is
None
:
log
=
self
.
log
log
=
self
.
log
return
self
.
_prepareSlapOS
(
node_test_suite
.
working_directory
,
return
self
.
_prepareSlapOS
(
node_test_suite
.
working_directory
,
...
...
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