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
Ophélie Gagnard
slapos.core
Commits
27edd2d4
Commit
27edd2d4
authored
Jan 08, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated tests
parent
71224c30
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
80 deletions
+89
-80
setup.py
setup.py
+1
-0
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+6
-0
slapos/grid/zc.buildout-bootstap.py
slapos/grid/zc.buildout-bootstap.py
+1
-2
slapos/proxy/views.py
slapos/proxy/views.py
+3
-9
slapos/tests/pyflakes/__init__.py
slapos/tests/pyflakes/__init__.py
+12
-3
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+58
-59
slapos/tests/slapproxy.py
slapos/tests/slapproxy.py
+8
-7
No files found.
setup.py
View file @
27edd2d4
...
...
@@ -39,6 +39,7 @@ setup(name=name,
'pyflakes'
,
# For testing purposes
'setuptools'
,
# namespaces
'supervisor'
,
# slapgrid uses supervisor to manage processes
'unittest2'
,
'xml_marshaller>=0.9.3'
,
# to unmarshall/marshall python objects to/from
# XML
'zope.interface'
,
# slap library implementes interfaces
...
...
slapos/grid/SlapObject.py
View file @
27edd2d4
...
...
@@ -508,6 +508,12 @@ class Partition(object):
if
f
:
if
os
.
path
.
exists
(
f
):
os
.
unlink
(
f
)
# better to manually remove symlinks because rmtree might choke on them
sr_symlink
=
os
.
path
.
join
(
self
.
instance_path
,
'software_release'
)
if
os
.
path
.
islink
(
sr_symlink
):
os
.
unlink
(
sr_symlink
)
for
root
,
dirs
,
file_list
in
os
.
walk
(
self
.
instance_path
):
for
directory
in
dirs
:
shutil
.
rmtree
(
os
.
path
.
join
(
self
.
instance_path
,
directory
))
...
...
slapos/grid/zc.buildout-bootstap.py
View file @
27edd2d4
...
...
@@ -18,7 +18,7 @@ The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import
os
,
shutil
,
sys
,
tempfile
,
textwrap
,
urllib
,
urllib2
,
subprocess
import
os
,
shutil
,
sys
,
tempfile
,
urllib
,
urllib2
,
subprocess
from
optparse
import
OptionParser
if
sys
.
platform
==
'win32'
:
...
...
@@ -57,7 +57,6 @@ if not has_broken_dash_S and 'site' in sys.modules:
# out any namespace packages from site-packages that might have been
# loaded by .pth files.
clean_path
=
sys
.
path
[:]
import
site
sys
.
path
[:]
=
clean_path
for
k
,
v
in
sys
.
modules
.
items
():
if
k
in
(
'setuptools'
,
'pkg_resources'
)
or
(
...
...
slapos/proxy/views.py
View file @
27edd2d4
...
...
@@ -303,13 +303,6 @@ def request_not_shared():
q
=
'SELECT * FROM %s WHERE partition_reference=?'
a
(
partition_reference
)
#
# XXX the following filter breaks renaming asked by the bully script
#
# if partition_id:
# q += ' AND requested_by=?'
# a(partition_id)
partition
=
execute_db
(
'partition'
,
q
,
args
,
one
=
True
)
args
=
[]
...
...
@@ -392,7 +385,7 @@ def request_slave():
partition_id
=
request
.
form
.
get
(
'computer_partition_id'
,
''
).
encode
()
# Contain slave parameters to be given to slave master
partition_parameter_kw
=
request
.
form
.
get
(
'partition_parameter_xml'
,
None
)
if
partition_parameter_kw
:
if
partition_parameter_kw
:
partition_parameter_kw
=
xml_marshaller
.
xml_marshaller
.
loads
(
partition_parameter_kw
.
encode
())
else
:
...
...
@@ -419,7 +412,7 @@ def request_slave():
args
)
abort
(
404
)
# We set slave diction
n
ary as described in docstring
# We set slave dictionary as described in docstring
new_slave
=
{}
slave_reference
=
partition_id
+
'_'
+
partition_reference
new_slave
[
'slave_title'
]
=
slave_reference
...
...
@@ -481,3 +474,4 @@ def request_slave():
slap_software_type
=
partition
[
'software_type'
],
ip_list
=
address_list
))
slapos/tests/pyflakes/__init__.py
View file @
27edd2d4
...
...
@@ -29,9 +29,9 @@ import os
import
pkg_resources
import
pyflakes.scripts.pyflakes
import
sys
import
unittest
import
unittest
2
class
CheckCodeConsistency
(
unittest
.
TestCase
):
class
CheckCodeConsistency
(
unittest
2
.
TestCase
):
"""Lints all SlapOS Node and SLAP library code base."""
def
setUp
(
self
):
self
.
_original_argv
=
sys
.
argv
...
...
@@ -45,5 +45,14 @@ class CheckCodeConsistency(unittest.TestCase):
def
tearDown
(
self
):
sys
.
argv
=
self
.
_original_argv
@
unittest2
.
skip
(
'pyflakes test is disabled'
)
def
testCodeConsistency
(
self
):
pyflakes
.
scripts
.
pyflakes
.
main
()
if
pyflakes
.
scripts
.
pyflakes
.
main
.
func_code
.
co_argcount
:
pyflakes
.
scripts
.
pyflakes
.
main
([
os
.
path
.
join
(
pkg_resources
.
get_distribution
(
'slapos.core'
).
location
,
'slapos'
,
)])
else
:
pyflakes
.
scripts
.
pyflakes
.
main
()
slapos/tests/slapgrid.py
View file @
27edd2d4
...
...
@@ -38,6 +38,7 @@ from slapos.grid.watchdog import Watchdog, getWatchdogID
import
socket
import
sys
import
tempfile
import
textwrap
import
time
import
unittest
import
urlparse
...
...
@@ -458,8 +459,8 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'worked'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
...
...
@@ -477,8 +478,8 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'worked'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
...
...
@@ -508,7 +509,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc
'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
tries
=
50
wrapper_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
...
...
@@ -551,8 +552,8 @@ chmod 755 etc/run/wrapper
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
tries
=
50
while
tries
>
0
:
...
...
@@ -574,9 +575,8 @@ chmod 755 etc/run/wrapper
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
expected_text
=
'Signal handler called with signal 15'
while
tries
>
0
:
...
...
@@ -622,8 +622,8 @@ chmod 755 etc/run/wrapper
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
tries
=
50
while
tries
>
0
:
...
...
@@ -648,9 +648,8 @@ exit 1
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_FAIL
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
expected_text
=
'Signal handler called with signal 15'
while
tries
>
0
:
...
...
@@ -676,8 +675,8 @@ exit 1
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'worked'
,
'etc'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
...
...
@@ -691,8 +690,8 @@ exit 1
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.0_wrapper.log'
,
'worked'
,
'etc'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.0_wrapper.log'
,
'etc'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
tries
=
50
...
...
@@ -770,11 +769,10 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_daemon.log'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
200
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
while
tries
>
0
:
...
...
@@ -792,16 +790,6 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
watchdog_banged
))
self
.
assertTrue
(
'daemon'
in
open
(
self
.
watchdog_banged
,
'r'
).
read
())
RUN_CONTENT
=
"""#!/bin/sh
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/daemon &&
echo "touch launched
touch ./crashed; echo "Failing
\
\
nFailing
\
\
n"; sleep 1; exit 111;
" >> etc/run/daemon &&
chmod 755 etc/run/daemon &&
touch worked
"""
def
test_one_failing_daemon_in_run_will_not_bang_with_watchdog
(
self
):
"""
Check that a failing service watched by watchdog trigger bang
...
...
@@ -817,13 +805,25 @@ touch worked
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
self
.
RUN_CONTENT
)
RUN_CONTENT
=
textwrap
.
dedent
(
"""
\
#!/bin/sh
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/daemon &&
echo "touch launched
touch ./crashed; echo "Failing
\
\
nFailing
\
\
n"; sleep 1; exit 111;
" >> etc/run/daemon &&
chmod 755 etc/run/daemon &&
touch worked
"""
)
partition
.
software
.
setBuildout
(
RUN_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_daemon.log'
,
'worked'
,
'buildout.cfg'
,
'etc
'
])
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
tries
=
200
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
while
tries
>
0
:
...
...
@@ -922,8 +922,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
timestamp_path
=
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)
...
...
@@ -931,8 +931,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertTrue
(
timestamp
in
open
(
timestamp_path
,
'r'
).
read
())
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
def
test_partition_timestamp_develop
(
self
):
...
...
@@ -945,8 +944,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'buildout.cfg
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
...
...
@@ -969,7 +968,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'buildout.cfg
'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
str
(
int
(
timestamp
)
-
1
)
...
...
@@ -989,7 +988,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'buildout.cfg
'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
str
(
int
(
timestamp
)
+
1
)
...
...
@@ -1012,7 +1011,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'buildout.cfg
'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
None
...
...
@@ -1199,10 +1198,10 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc
'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
...
...
@@ -1325,7 +1324,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'
worked'
,
'buildout.cfg'
,
'etc
'
])
[
'.0_wrapper.log'
,
'
buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
...
...
@@ -1347,9 +1346,8 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
...
...
@@ -1361,7 +1359,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'
worked'
,
'buildout.cfg'
,
'etc
'
])
[
'.0_wrapper.log'
,
'
buildout.cfg'
,
'etc'
,
'software_release'
,
'worked
'
])
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
...
...
@@ -1667,9 +1665,10 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'started'
worked_file
=
os
.
path
.
join
(
instance
.
partition_path
,
'fail_worked'
)
fail
=
(
"""#!/usr/bin/env sh
touch "%(worked_file)s"
exit 127"""
%
{
'worked_file'
:
worked_file
})
fail
=
textwrap
.
dedent
(
"""
\
#!/usr/bin/env sh
touch "%s"
exit 127"""
%
worked_file
)
instance
.
setPromise
(
'fail'
,
fail
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
...
...
slapos/tests/slapproxy.py
View file @
27edd2d4
...
...
@@ -256,15 +256,16 @@ class TestRequest (MasterMixin, unittest.TestCase):
"""
def
test_two_request_one_partition_free
(
self
):
"""
If only one partition is available and two different request are made
first will succeed second will fail
Since slapproxy does not implement scope, providing two partition_id
values will still succeed, even if only one partition is available.
"""
self
.
add_free_partition
(
1
)
self
.
assertIsInstance
(
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart2'
),
slapos
.
slap
.
ComputerPartition
)
with
self
.
assertRaises
(
WrongFormat
):
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart3'
)
self
.
assertIsInstance
(
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart3'
),
slapos
.
slap
.
ComputerPartition
)
def
test_two_request_two_partition_free
(
self
):
"""
...
...
@@ -327,11 +328,11 @@ class TestRequest (MasterMixin, unittest.TestCase):
def
test_two_different_request_from_two_partition
(
self
):
"""
Two request from different partitions
will return two differents partitions
Since slapproxy does not implement scope, two request with
different partition_id will still return the same partition.
"""
self
.
add_free_partition
(
2
)
self
.
assert
Not
Equal
(
self
.
assertEqual
(
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart2'
).
__dict__
,
self
.
request
(
'http://sr//'
,
None
,
'Maria'
,
'slappart3'
).
__dict__
)
...
...
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