Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
36ecc00e
Commit
36ecc00e
authored
Nov 05, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_slapgrid: also cover promise plugins in promise summary
parent
a0fc52e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
slapos/tests/test_slapgrid.py
slapos/tests/test_slapgrid.py
+22
-11
No files found.
slapos/tests/test_slapgrid.py
View file @
36ecc00e
##############################################################################
##############################################################################
#
#
coding: utf-8
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
...
@@ -119,6 +119,7 @@ touch worked
...
@@ -119,6 +119,7 @@ touch worked
"""
"""
PROMISE_CONTENT_TEMPLATE
=
"""
PROMISE_CONTENT_TEMPLATE
=
"""
# coding: utf-8
import sys
import sys
sys.path[0:0] = %(paths)r
sys.path[0:0] = %(paths)r
...
@@ -1757,41 +1758,51 @@ echo %s; echo %s; exit 42""" % (line1, line2))
...
@@ -1757,41 +1758,51 @@ echo %s; echo %s; exit 42""" % (line1, line2))
def
test_processing_summary
(
self
):
def
test_processing_summary
(
self
):
"""At the end of instance processing, a summary of partition with errors is displayed.
"""At the end of instance processing, a summary of partition with errors is displayed.
"""
"""
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
3
,
3
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
4
,
4
)
_
,
instance1
,
instance2
=
computer
.
instance_list
_
,
instance1
,
instance2
,
instance3
=
computer
.
instance_list
# instance0 has no problem, it is not in summary
# instance0 has no problem, it is not in summary
# instance 1 fails software
# instance 1 fails software
instance1
=
computer
.
instance_list
[
1
]
instance1
.
software
=
computer
.
software_list
[
1
]
instance1
.
software
=
computer
.
software_list
[
1
]
instance1
.
software
.
setBuildout
(
"""#!/bin/sh
instance1
.
software
.
setBuildout
(
"""#!/bin/sh
echo fake buildout error
echo fake buildout error
exit 1"""
)
exit 1"""
)
# instance 2 fails promises
# instance 2 fails old style promises
instance2
=
computer
.
instance_list
[
2
]
instance2
.
requested_state
=
'started'
instance2
.
requested_state
=
'started'
instance2
.
setPromise
(
"failing_promise"
,
"""#!/bin/sh
instance2
.
setPromise
(
"failing_promise"
,
"""#!/bin/sh
echo fake promise error
echo
héhé
fake promise error
exit 1"""
)
exit 1"""
)
# instance 3 fails promise plugin
instance3
.
requested_state
=
'started'
instance3
.
setPluginPromise
(
"failing_promise_plugin.py"
,
promise_content
=
"""if 1:
return self.logger.error("héhé fake promise plugin error")
"""
,
)
with
httmock
.
HTTMock
(
computer
.
request_handler
),
\
with
httmock
.
HTTMock
(
computer
.
request_handler
),
\
patch
.
object
(
self
.
grid
.
logger
,
'info'
,)
as
dummyLogger
:
patch
.
object
(
self
.
grid
.
logger
,
'info'
,)
as
dummyLogger
:
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
# reconstruct the string like logger does
# reconstruct the string like logger does
self
.
assertEqual
(
self
.
assertEqual
(
dummyLogger
.
mock_calls
[
-
4
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
4
][
1
][
1
:],
dummyLogger
.
mock_calls
[
-
5
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
5
][
1
][
1
:],
'Error while processing the following partitions:'
)
'Error while processing the following partitions:'
)
self
.
assertRegexpMatches
(
self
.
assertRegexpMatches
(
dummyLogger
.
mock_calls
[
-
3
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
3
][
1
][
1
:],
dummyLogger
.
mock_calls
[
-
4
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
4
][
1
][
1
:],
r" 1\
[
\(not ready\
)
\]: Failed to run buildout profile in directory '.*/instance/1':\nfake buildout error\n\n"
)
r" 1\
[
\(not ready\
)
\]: Failed to run buildout profile in directory '.*/instance/1':\nfake buildout error\n\n"
)
self
.
assertEqual
(
self
.
assertEqual
(
dummyLogger
.
mock_calls
[
-
2
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
2
][
1
][
1
:],
dummyLogger
.
mock_calls
[
-
3
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
3
][
1
][
1
:],
'Error with promises for the following partitions:'
)
'Error with promises for the following partitions:'
)
self
.
assertEqual
(
dummyLogger
.
mock_calls
[
-
2
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
2
][
1
][
1
:],
" 2[(not ready)]: Promise 'failing_promise' failed with output: héhé fake promise error"
)
self
.
assertEqual
(
self
.
assertEqual
(
dummyLogger
.
mock_calls
[
-
1
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
1
][
1
][
1
:],
dummyLogger
.
mock_calls
[
-
1
][
1
][
0
]
%
dummyLogger
.
mock_calls
[
-
1
][
1
][
1
:],
"
2[(not ready)]: Promise 'failing_promise' failed with output: fake promise
error"
)
"
3[(not ready)]: Promise 'failing_promise_plugin.py' failed with output: héhé fake promise plugin
error"
)
def
test_partition_force_stop
(
self
):
def
test_partition_force_stop
(
self
):
"""
"""
...
...
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