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
Eric Zheng
slapos.core
Commits
e9682562
Commit
e9682562
authored
May 17, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed custom self.assertSortedListEqual to self.assertItemsEqual from stdlib
parent
6795119f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
144 deletions
+101
-144
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+101
-144
No files found.
slapos/tests/slapgrid.py
View file @
e9682562
...
@@ -99,9 +99,6 @@ touch worked
...
@@ -99,9 +99,6 @@ touch worked
"""
"""
class
BasicMixin
:
class
BasicMixin
:
def
assertSortedListEqual
(
self
,
list1
,
list2
,
msg
=
None
):
self
.
assertListEqual
(
sorted
(
list1
),
sorted
(
list2
),
msg
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
_tempdir
=
tempfile
.
mkdtemp
()
self
.
_tempdir
=
tempfile
.
mkdtemp
()
self
.
software_root
=
os
.
path
.
join
(
self
.
_tempdir
,
'software'
)
self
.
software_root
=
os
.
path
.
join
(
self
.
_tempdir
,
'software'
)
...
@@ -482,20 +479,17 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
...
@@ -482,20 +479,17 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'etc'
,
'var'
])
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'etc'
,
'var'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[])
def
test_one_partition
(
self
):
def
test_one_partition
(
self
):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'stoppedComputerPartition'
])
'stoppedComputerPartition'
])
...
@@ -508,13 +502,10 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
...
@@ -508,13 +502,10 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'stoppedComputerPartition'
])
'stoppedComputerPartition'
])
...
@@ -528,9 +519,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
...
@@ -528,9 +519,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
partition
=
computer
.
instance_list
[
0
]
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'destroyed'
partition
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
partition
.
partition_path
),
[])
self
.
assert
Items
Equal
(
os
.
listdir
(
partition
.
partition_path
),
[])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertEqual
(
partition
.
sequence
,
[])
self
.
assertEqual
(
partition
.
sequence
,
[])
def
test_one_partition_started
(
self
):
def
test_one_partition_started
(
self
):
...
@@ -539,10 +530,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
...
@@ -539,10 +530,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -551,8 +541,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
...
@@ -551,8 +541,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest2.TestCase):
break
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
partition
.
software
.
software_hash
])
[
partition
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'startedComputerPartition'
])
'startedComputerPartition'
])
...
@@ -583,10 +572,9 @@ HEREDOC
...
@@ -583,10 +572,9 @@ HEREDOC
chmod 755 etc/run/wrapper
chmod 755 etc/run/wrapper
"""
%
dict
(
python
=
sys
.
executable
))
"""
%
dict
(
python
=
sys
.
executable
))
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
tries
=
50
tries
=
50
while
tries
>
0
:
while
tries
>
0
:
...
@@ -596,8 +584,7 @@ chmod 755 etc/run/wrapper
...
@@ -596,8 +584,7 @@ chmod 755 etc/run/wrapper
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
os
.
path
.
getsize
(
wrapper_log
)
os
.
path
.
getsize
(
wrapper_log
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'startedComputerPartition'
])
'startedComputerPartition'
])
...
@@ -606,10 +593,9 @@ chmod 755 etc/run/wrapper
...
@@ -606,10 +593,9 @@ chmod 755 etc/run/wrapper
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'stopped'
instance
.
requested_state
=
'stopped'
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
expected_text
=
'Signal handler called with signal 15'
expected_text
=
'Signal handler called with signal 15'
while
tries
>
0
:
while
tries
>
0
:
...
@@ -653,10 +639,9 @@ HEREDOC
...
@@ -653,10 +639,9 @@ HEREDOC
chmod 755 etc/run/wrapper
chmod 755 etc/run/wrapper
"""
%
dict
(
python
=
sys
.
executable
))
"""
%
dict
(
python
=
sys
.
executable
))
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
tries
=
50
tries
=
50
while
tries
>
0
:
while
tries
>
0
:
...
@@ -666,7 +651,7 @@ chmod 755 etc/run/wrapper
...
@@ -666,7 +651,7 @@ chmod 755 etc/run/wrapper
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
os
.
path
.
getsize
(
wrapper_log
)
os
.
path
.
getsize
(
wrapper_log
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
...
@@ -679,10 +664,10 @@ chmod 755 etc/run/wrapper
...
@@ -679,10 +664,10 @@ chmod 755 etc/run/wrapper
exit 1
exit 1
"""
)
"""
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_FAIL
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_FAIL
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
instance_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assert
Items
Equal
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
expected_text
=
'Signal handler called with signal 15'
expected_text
=
'Signal handler called with signal 15'
while
tries
>
0
:
while
tries
>
0
:
...
@@ -705,12 +690,11 @@ exit 1
...
@@ -705,12 +690,11 @@ exit 1
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
partition
),
self
.
assert
Items
Equal
(
os
.
listdir
(
partition
),
[
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
...
@@ -720,12 +704,11 @@ exit 1
...
@@ -720,12 +704,11 @@ exit 1
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
computer
.
sequence
=
[]
computer
.
sequence
=
[]
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
partition
),
self
.
assert
Items
Equal
(
os
.
listdir
(
partition
),
[
'.0_wrapper.log'
,
'etc'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'etc'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
...
@@ -757,12 +740,10 @@ exit 1
...
@@ -757,12 +740,10 @@ exit 1
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
dummy_file_name
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
dummy_file_name
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
[
'getFullComputerInformation'
,
'stoppedComputerPartition'
])
'stoppedComputerPartition'
])
...
@@ -802,10 +783,9 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
...
@@ -802,10 +783,9 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
200
tries
=
200
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -854,10 +834,10 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
...
@@ -854,10 +834,10 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
partition
.
software
.
setBuildout
(
RUN_CONTENT
)
partition
.
software
.
setBuildout
(
RUN_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
instance_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assert
Items
Equal
(
os
.
listdir
(
partition
.
partition_path
),
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
200
tries
=
200
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
daemon_log
=
os
.
path
.
join
(
partition
.
partition_path
,
'.0_daemon.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -944,7 +924,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
...
@@ -944,7 +924,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest2.TestCase):
self
.
assertEqual
(
computer
.
sequence
,[])
self
.
assertEqual
(
computer
.
sequence
,[])
class
TestSlapgridCPPartitionProcessing
(
MasterMixin
,
unittest2
.
TestCase
):
class
TestSlapgridCPPartitionProcessing
(
MasterMixin
,
unittest2
.
TestCase
):
def
test_partition_timestamp
(
self
):
def
test_partition_timestamp
(
self
):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
...
@@ -953,13 +933,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -953,13 +933,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertSortedListEqual
(
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
timestamp_path
=
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)
timestamp_path
=
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)
self
.
setSlapgrid
()
self
.
setSlapgrid
()
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
...
@@ -975,13 +953,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -975,13 +953,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertSortedListEqual
(
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
self
.
launchSlapgrid
(
develop
=
True
),
self
.
assertEqual
(
self
.
launchSlapgrid
(
develop
=
True
),
slapgrid
.
SLAPGRID_SUCCESS
)
slapgrid
.
SLAPGRID_SUCCESS
)
...
@@ -998,13 +974,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -998,13 +974,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
str
(
int
(
timestamp
)
-
1
)
instance
.
timestamp
=
str
(
int
(
timestamp
)
-
1
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
instance
.
sequence
,
self
.
assertEqual
(
instance
.
sequence
,
...
@@ -1018,13 +992,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -1018,13 +992,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
str
(
int
(
timestamp
)
+
1
)
instance
.
timestamp
=
str
(
int
(
timestamp
)
+
1
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
...
@@ -1041,12 +1013,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -1041,12 +1013,11 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assert
SortedList
Equal
(
os
.
listdir
(
partition
),
self
.
assert
Items
Equal
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
self
.
assert
SortedList
Equal
(
os
.
listdir
(
self
.
software_root
),
self
.
assert
Items
Equal
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
instance
.
timestamp
=
None
instance
.
timestamp
=
None
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
...
@@ -1072,9 +1043,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -1072,9 +1043,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
time
.
sleep
(
2
)
time
.
sleep
(
2
)
# dummify install() so that it doesn't actually do anything so that it
# dummify install() so that it doesn't actually do anything so that it
...
@@ -1082,9 +1052,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
...
@@ -1082,9 +1052,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest2.TestCase):
instance
.
install
=
lambda
:
None
instance
.
install
=
lambda
:
None
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
self
.
assertSortedListEqual
(
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
os
.
listdir
(
partition
),
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
[
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
])
def
test_partition_periodicity_is_not_overloaded_if_forced
(
self
):
def
test_partition_periodicity_is_not_overloaded_if_forced
(
self
):
...
@@ -1345,10 +1314,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1345,10 +1314,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -1357,8 +1325,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1357,8 +1325,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
break
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'availableComputerPartition'
,
...
@@ -1370,11 +1337,10 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1370,11 +1337,10 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
# Assert supervisor stopped process
# Assert supervisor stopped process
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
...
@@ -1410,11 +1376,10 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1410,11 +1376,10 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
# Assert supervisor stopped process
# Assert supervisor stopped process
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
...
@@ -1440,10 +1405,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1440,10 +1405,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -1452,8 +1416,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1452,8 +1416,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
break
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'availableComputerPartition'
,
...
@@ -1463,10 +1426,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1463,10 +1426,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
# Then run usage report and see if it is still working
# Then run usage report and see if it is still working
computer
.
sequence
=
[]
computer
.
sequence
=
[]
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -1475,10 +1437,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1475,10 +1437,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
break
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
[
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
])
tries
=
50
tries
=
50
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
while
tries
>
0
:
...
@@ -1504,11 +1465,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1504,11 +1465,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
])
def
test_slapgrid_report_ignore_free_instance
(
self
):
def
test_slapgrid_report_ignore_free_instance
(
self
):
...
@@ -1524,11 +1483,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
...
@@ -1524,11 +1483,9 @@ class TestSlapgridUsageReport(MasterMixin, unittest2.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
])
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
])
...
...
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