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
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
Gabriel Monnerat
slapos.core
Commits
32833df9
Commit
32833df9
authored
May 17, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
assertTrue -> assertIn
parent
aec034d4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
42 deletions
+32
-42
slapos/tests/entry.py
slapos/tests/entry.py
+3
-3
slapos/tests/slap.py
slapos/tests/slap.py
+2
-4
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+17
-17
slapos/tests/slapobject.py
slapos/tests/slapobject.py
+10
-18
No files found.
slapos/tests/entry.py
View file @
32833df9
...
...
@@ -107,7 +107,7 @@ class TestcheckOption (BasicMixin, unittest.TestCase):
option
=
"--logfile /opt/slapgrid/slapformat.log"
entry
.
checkOption
(
option
)
self
.
assertNotEqual
(
original_sysargv
,
sys
.
argv
)
self
.
assert
True
(
option
in
" "
.
join
(
sys
.
argv
))
self
.
assert
In
(
option
,
' '
.
join
(
sys
.
argv
))
class
TestCall
(
BasicMixin
,
unittest
.
TestCase
):
...
...
@@ -133,7 +133,7 @@ class TestCall (BasicMixin, unittest.TestCase):
self
.
assertEqual
(
e
[
0
],
0
)
self
.
assertNotEqual
(
original_sysargv
,
sys
.
argv
)
for
x
in
options
:
self
.
assert
True
(
x
in
" "
.
join
(
sys
.
argv
))
self
.
assert
In
(
x
,
' '
.
join
(
sys
.
argv
))
self
.
assertEqual
(
config_path
,
sys
.
argv
[
1
])
def
test_config_and_missing_option_are_added
(
self
):
...
...
@@ -158,7 +158,7 @@ class TestCall (BasicMixin, unittest.TestCase):
self
.
assertEqual
(
e
[
0
],
0
)
self
.
assertNotEqual
(
original_sysargv
,
sys
.
argv
)
for
x
in
(
missing_option
,
present_option
):
self
.
assert
True
(
x
in
" "
.
join
(
sys
.
argv
))
self
.
assert
In
(
x
,
' '
.
join
(
sys
.
argv
))
self
.
assertFalse
(
default_present_option
in
" "
.
join
(
sys
.
argv
))
self
.
assertEqual
(
config_path
,
sys
.
argv
[
1
])
...
...
slapos/tests/slap.py
View file @
32833df9
...
...
@@ -91,10 +91,8 @@ class TestSlap(SlapMixin):
"""
slap_instance
=
slapos
.
slap
.
slap
()
slap_instance
.
initializeConnection
(
self
.
server_url
)
self
.
assertTrue
(
slap_instance
.
_connection_helper
.
host
in
self
.
server_url
)
self
.
assertTrue
(
slap_instance
.
_connection_helper
.
path
in
self
.
server_url
)
self
.
assertIn
(
slap_instance
.
_connection_helper
.
host
,
self
.
server_url
)
self
.
assertIn
(
slap_instance
.
_connection_helper
.
path
,
self
.
server_url
)
def
test_slap_initialisation_wrong_url
(
self
):
"""
...
...
slapos/tests/slapgrid.py
View file @
32833df9
...
...
@@ -541,7 +541,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
partition
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
...
...
@@ -584,7 +584,7 @@ chmod 755 etc/run/wrapper
break
time
.
sleep
(
0.1
)
os
.
path
.
getsize
(
wrapper_log
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
...
...
@@ -651,7 +651,7 @@ chmod 755 etc/run/wrapper
break
time
.
sleep
(
0.1
)
os
.
path
.
getsize
(
wrapper_log
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
...
...
@@ -718,7 +718,7 @@ exit 1
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'startedComputerPartition'
])
...
...
@@ -794,7 +794,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Failing'
in
open
(
daemon_log
).
read
())
self
.
assert
In
(
'Failing'
,
open
(
daemon_log
).
read
())
tries
=
200
while
tries
>
0
:
tries
-=
1
...
...
@@ -802,7 +802,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
break
time
.
sleep
(
0.1
)
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
watchdog_banged
))
self
.
assert
True
(
'daemon'
in
open
(
self
.
watchdog_banged
).
read
())
self
.
assert
In
(
'daemon'
,
open
(
self
.
watchdog_banged
).
read
())
def
test_one_failing_daemon_in_run_will_not_bang_with_watchdog
(
self
):
"""
...
...
@@ -846,7 +846,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Failing'
in
open
(
daemon_log
).
read
())
self
.
assert
In
(
'Failing'
,
open
(
daemon_log
).
read
())
tries
=
200
while
tries
>
0
:
tries
-=
1
...
...
@@ -947,7 +947,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest2.TestCase):
timestamp_path
=
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)
self
.
setSlapgrid
()
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assert
True
(
timestamp
in
open
(
timestamp_path
).
read
())
self
.
assert
In
(
timestamp
,
open
(
timestamp_path
).
read
())
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
...
...
@@ -1301,9 +1301,9 @@ echo %s; echo %s; exit 42""" % (line1, line2))
self
.
launchSlapgrid
()
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceError'
])
# We don't care of actual formatting, we just want to have full log
self
.
assert
True
(
line1
in
instance
.
error_log
)
self
.
assert
True
(
line2
in
instance
.
error_log
)
self
.
assert
True
(
"Failed to run buildout"
in
instance
.
error_log
)
self
.
assert
In
(
line1
,
instance
.
error_log
)
self
.
assert
In
(
line2
,
instance
.
error_log
)
self
.
assert
In
(
'Failed to run buildout'
,
instance
.
error_log
)
class
TestSlapgridUsageReport
(
MasterMixin
,
unittest2
.
TestCase
):
...
...
@@ -1330,7 +1330,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
...
...
@@ -1421,7 +1421,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
...
...
@@ -1442,7 +1442,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.1
)
self
.
assert
True
(
'Working'
in
open
(
wrapper_log
).
read
())
self
.
assert
In
(
'Working'
,
open
(
wrapper_log
).
read
())
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
...
...
@@ -1513,9 +1513,9 @@ echo %s; echo %s; exit 42""" % (line1, line2))
self
.
assertEqual
(
software
.
sequence
,
[
'buildingSoftwareRelease'
,
'softwareReleaseError'
])
# We don't care of actual formatting, we just want to have full log
self
.
assert
True
(
line1
in
software
.
error_log
)
self
.
assert
True
(
line2
in
software
.
error_log
)
self
.
assert
True
(
"Failed to run buildout"
in
software
.
error_log
)
self
.
assert
In
(
line1
,
software
.
error_log
)
self
.
assert
In
(
line2
,
software
.
error_log
)
self
.
assert
In
(
'Failed to run buildout'
,
software
.
error_log
)
class
SlapgridInitialization
(
unittest2
.
TestCase
):
"""
...
...
slapos/tests/slapobject.py
View file @
32833df9
...
...
@@ -27,7 +27,7 @@
import
logging
import
os
import
unittest
import
unittest
2
from
slapos.grid
import
SlapObject
from
slapos.grid
import
utils
...
...
@@ -53,7 +53,7 @@ originalBootstrapBuildout = utils.bootstrapBuildout
originalLaunchBuildout
=
utils
.
launchBuildout
originalUploadSoftwareRelease
=
SlapObject
.
Software
.
uploadSoftwareRelease
class
TestSoftwareSlapObject
(
BasicMixin
,
unittest
.
TestCase
):
class
TestSoftwareSlapObject
(
BasicMixin
,
unittest
2
.
TestCase
):
"""
Test for Software class.
"""
...
...
@@ -107,22 +107,14 @@ class TestSoftwareSlapObject(BasicMixin, unittest.TestCase):
software
.
install
()
command_list
=
FakeCallAndRead
.
external_command_list
self
.
assertTrue
(
'buildout:networkcache-section=networkcache'
in
command_list
)
self
.
assertTrue
(
'networkcache:signature-private-key-file=%s'
%
self
.
signature_private_key_file
in
command_list
)
self
.
assertTrue
(
'networkcache:upload-cache-url=%s'
%
self
.
upload_cache_url
in
command_list
)
self
.
assertTrue
(
'networkcache:upload-dir-url=%s'
%
self
.
upload_dir_url
in
command_list
)
self
.
assertTrue
(
'networkcache:shacache-cert-file=%s'
%
self
.
shacache_cert_file
in
command_list
)
self
.
assertTrue
(
'networkcache:shacache-key-file=%s'
%
self
.
shacache_key_file
in
command_list
)
self
.
assertTrue
(
'networkcache:shadir-cert-file=%s'
%
self
.
shadir_cert_file
in
command_list
)
self
.
assertTrue
(
'networkcache:shadir-key-file=%s'
%
self
.
shadir_key_file
in
command_list
)
self
.
assertIn
(
'buildout:networkcache-section=networkcache'
,
command_list
)
self
.
assertIn
(
'networkcache:signature-private-key-file=%s'
%
self
.
signature_private_key_file
,
command_list
)
self
.
assertIn
(
'networkcache:upload-cache-url=%s'
%
self
.
upload_cache_url
,
command_list
)
self
.
assertIn
(
'networkcache:upload-dir-url=%s'
%
self
.
upload_dir_url
,
command_list
)
self
.
assertIn
(
'networkcache:shacache-cert-file=%s'
%
self
.
shacache_cert_file
,
command_list
)
self
.
assertIn
(
'networkcache:shacache-key-file=%s'
%
self
.
shacache_key_file
,
command_list
)
self
.
assertIn
(
'networkcache:shadir-cert-file=%s'
%
self
.
shadir_cert_file
,
command_list
)
self
.
assertIn
(
'networkcache:shadir-key-file=%s'
%
self
.
shadir_key_file
,
command_list
)
def
test_software_install_without_networkcache
(
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