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
Łukasz Nowak
slapos.core
Commits
ed00b4b5
Commit
ed00b4b5
authored
Oct 16, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test to have correct return values
parent
71543fcc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
41 deletions
+47
-41
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+47
-41
No files found.
slapos/tests/slapgrid.py
View file @
ed00b4b5
...
@@ -432,14 +432,14 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -432,14 +432,14 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertSortedListEqual
(
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
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -458,7 +458,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -458,7 +458,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.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
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -478,7 +478,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -478,7 +478,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
software_amount
=
0
)
software_amount
=
0
)
partition
=
computer
.
instance_list
[
0
]
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'destroyed'
partition
.
requested_state
=
'destroyed'
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
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
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[])
...
@@ -489,7 +489,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -489,7 +489,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
partition
=
computer
.
instance_list
[
0
]
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
...
@@ -533,7 +533,7 @@ HEREDOC
...
@@ -533,7 +533,7 @@ HEREDOC
)> etc/run/wrapper &&
)> etc/run/wrapper &&
chmod 755 etc/run/wrapper
chmod 755 etc/run/wrapper
"""
%
dict
(
python
=
sys
.
executable
))
"""
%
dict
(
python
=
sys
.
executable
))
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
...
@@ -556,7 +556,7 @@ chmod 755 etc/run/wrapper
...
@@ -556,7 +556,7 @@ chmod 755 etc/run/wrapper
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'stopped'
instance
.
requested_state
=
'stopped'
self
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
self
.
assertSortedListEqual
(
...
@@ -582,7 +582,7 @@ chmod 755 etc/run/wrapper
...
@@ -582,7 +582,7 @@ chmod 755 etc/run/wrapper
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'stopped'
instance
.
requested_state
=
'stopped'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
...
@@ -598,7 +598,7 @@ chmod 755 etc/run/wrapper
...
@@ -598,7 +598,7 @@ chmod 755 etc/run/wrapper
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
computer
.
sequence
=
[]
computer
.
sequence
=
[]
self
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -634,7 +634,7 @@ chmod 755 etc/run/wrapper
...
@@ -634,7 +634,7 @@ chmod 755 etc/run/wrapper
dummy_file
.
write
(
'dummy'
)
dummy_file
.
write
(
'dummy'
)
dummy_file
.
close
()
dummy_file
.
close
()
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
...
@@ -680,7 +680,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
...
@@ -680,7 +680,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
self
.
assertSortedListEqual
(
...
@@ -730,7 +730,7 @@ touch worked
...
@@ -730,7 +730,7 @@ touch worked
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
self
.
RUN_CONTENT
)
partition
.
software
.
setBuildout
(
self
.
RUN_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
.
partition_path
),
...
@@ -825,7 +825,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -825,7 +825,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
timestamp
=
str
(
int
(
time
.
time
()))
timestamp
=
str
(
int
(
time
.
time
()))
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -835,7 +835,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -835,7 +835,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
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
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertTrue
(
timestamp
in
open
(
timestamp_path
,
'r'
).
read
())
self
.
assertTrue
(
timestamp
in
open
(
timestamp_path
,
'r'
).
read
())
self
.
assertEqual
(
instance
.
sequence
,
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
[
'availableComputerPartition'
,
...
@@ -848,7 +848,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -848,7 +848,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
timestamp
=
str
(
int
(
time
.
time
()))
timestamp
=
str
(
int
(
time
.
time
()))
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -857,8 +857,9 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -857,8 +857,9 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertTrue
(
self
.
launchSlapgrid
(
develop
=
True
))
self
.
assertEqual
(
self
.
launchSlapgrid
(
develop
=
True
),
self
.
assertTrue
(
self
.
launchSlapgrid
())
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
instance
.
sequence
,
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
,
...
@@ -870,7 +871,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -870,7 +871,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
timestamp
=
str
(
int
(
time
.
time
()))
timestamp
=
str
(
int
(
time
.
time
()))
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -879,7 +880,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -879,7 +880,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertSortedListEqual
(
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
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
instance
.
sequence
,
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
...
@@ -890,7 +891,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -890,7 +891,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
timestamp
=
str
(
int
(
time
.
time
()))
timestamp
=
str
(
int
(
time
.
time
()))
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
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'
)
...
@@ -899,8 +900,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -899,8 +900,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertSortedListEqual
(
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
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assert
True
(
self
.
launchSlapgrid
()
)
self
.
assert
Equal
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'stoppedComputerPartition'
,
'getFullComputerInformation'
,
'stoppedComputerPartition'
,
'getFullComputerInformation'
,
...
@@ -953,7 +954,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
...
@@ -953,7 +954,7 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self
.
setSlapgrid
()
self
.
setSlapgrid
()
self
.
grid
.
force_periodicity
=
True
self
.
grid
.
force_periodicity
=
True
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertNotEqual
(
unwanted_periodicity
,
self
.
grid
.
maximum_periodicity
)
self
.
assertNotEqual
(
unwanted_periodicity
,
self
.
grid
.
maximum_periodicity
)
self
.
assertEqual
(
computer
.
sequence
,
self
.
assertEqual
(
computer
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
...
@@ -1104,7 +1105,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1104,7 +1105,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.0_wrapper.log'
,
...
@@ -1128,7 +1129,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1128,7 +1129,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
# Then destroy the instance
# Then destroy the instance
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assert
True
(
self
.
grid
.
agregateAndSendUsage
()
)
self
.
assert
Equal
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
...
@@ -1165,7 +1166,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1165,7 +1166,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assert
True
(
self
.
grid
.
agregateAndSendUsage
()
)
self
.
assert
Equal
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
...
@@ -1199,7 +1200,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1199,7 +1200,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assert
True
(
self
.
grid
.
agregateAndSendUsage
()
)
self
.
assert
Equal
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
...
@@ -1227,7 +1228,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1227,7 +1228,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertSortedListEqual
(
os
.
listdir
(
instance
.
partition_path
),
...
@@ -1250,7 +1251,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1250,7 +1251,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.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
.
assert
True
(
self
.
grid
.
agregateAndSendUsage
()
)
self
.
assert
Equal
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
'var'
])
self
.
assertSortedListEqual
(
self
.
assertSortedListEqual
(
...
@@ -1288,7 +1289,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1288,7 +1289,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
[
'0'
,
'etc'
,
'var'
])
...
@@ -1576,11 +1577,12 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
...
@@ -1576,11 +1577,12 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
fail
=
(
"""#!/usr/bin/env sh
fail
=
(
"""#!/usr/bin/env sh
touch "%(worked_file)s"
touch "%(worked_file)s"
exit 127"""
%
{
'worked_file'
:
worked_file
})
exit 127"""
%
{
'worked_file'
:
worked_file
})
instance
.
setPromise
(
'fail'
,
fail
)
instance
.
setPromise
(
'fail'
,
fail
)
self
.
assertFalse
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
instance
.
error
)
self
.
assertTrue
(
instance
.
error
)
self
.
assertNotEqual
(
'started'
,
instance
.
state
)
self
.
assertNotEqual
(
'started'
,
instance
.
state
)
def
test_one_succeeding_promise
(
self
):
def
test_one_succeeding_promise
(
self
):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
...
@@ -1591,12 +1593,12 @@ exit 127""" % {'worked_file': worked_file})
...
@@ -1591,12 +1593,12 @@ exit 127""" % {'worked_file': worked_file})
succeed
=
(
"""#!/usr/bin/env sh
succeed
=
(
"""#!/usr/bin/env sh
touch "%(worked_file)s"
touch "%(worked_file)s"
exit 0"""
%
{
'worked_file'
:
worked_file
})
exit 0"""
%
{
'worked_file'
:
worked_file
})
instance
.
setPromise
(
'succeed'
,
succeed
)
instance
.
setPromise
(
'succeed'
,
succeed
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertFalse
(
instance
.
error
)
self
.
assertFalse
(
instance
.
error
)
self
.
assertEqual
(
instance
.
state
,
'started'
)
self
.
assertEqual
(
instance
.
state
,
'started'
)
def
test_stderr_has_been_sent
(
self
):
def
test_stderr_has_been_sent
(
self
):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
)
...
@@ -1616,7 +1618,8 @@ touch "%(worked_file)s"
...
@@ -1616,7 +1618,8 @@ touch "%(worked_file)s"
echo Error 1>&2
echo Error 1>&2
exit 127"""
%
{
'worked_file'
:
worked_file
})
exit 127"""
%
{
'worked_file'
:
worked_file
})
os
.
chmod
(
succeed
,
0777
)
os
.
chmod
(
succeed
,
0777
)
self
.
assertFalse
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertEqual
(
instance
.
error_log
,
'Error'
)
self
.
assertEqual
(
instance
.
error_log
,
'Error'
)
...
@@ -1641,7 +1644,8 @@ touch "%(worked_file)s"
...
@@ -1641,7 +1644,8 @@ touch "%(worked_file)s"
sleep 5
sleep 5
exit 0"""
%
{
'worked_file'
:
worked_file
})
exit 0"""
%
{
'worked_file'
:
worked_file
})
os
.
chmod
(
succeed
,
0777
)
os
.
chmod
(
succeed
,
0777
)
self
.
assertFalse
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
instance
.
error
)
self
.
assertTrue
(
instance
.
error
)
...
@@ -1661,7 +1665,7 @@ touch "%(worked_file)s"
...
@@ -1661,7 +1665,7 @@ touch "%(worked_file)s"
exit 0"""
%
{
'worked_file'
:
worked_file
})
exit 0"""
%
{
'worked_file'
:
worked_file
})
instance
.
setPromise
(
'succeed_%s'
%
i
,
succeed
)
instance
.
setPromise
(
'succeed_%s'
%
i
,
succeed
)
self
.
assert
True
(
self
.
grid
.
processComputerPartitionList
()
)
self
.
assert
Equal
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
for
i
in
range
(
0
,
2
):
for
i
in
range
(
0
,
2
):
worked_file
=
os
.
path
.
join
(
instance
.
partition_path
,
'succeed_%s_worked'
%
i
)
worked_file
=
os
.
path
.
join
(
instance
.
partition_path
,
'succeed_%s_worked'
%
i
)
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
self
.
assertTrue
(
os
.
path
.
isfile
(
worked_file
))
...
@@ -1687,7 +1691,8 @@ else
...
@@ -1687,7 +1691,8 @@ else
exit 127
exit 127
fi"""
%
{
'worked_file'
:
worked_file
,
'lockfile'
:
lockfile
})
fi"""
%
{
'worked_file'
:
worked_file
,
'lockfile'
:
lockfile
})
instance
.
setPromise
(
'promise_%s'
%
i
,
promise
)
instance
.
setPromise
(
'promise_%s'
%
i
,
promise
)
self
.
assertFalse
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
self
.
assertEquals
(
instance
.
error
,
1
)
self
.
assertEquals
(
instance
.
error
,
1
)
self
.
assertNotEqual
(
'started'
,
instance
.
state
)
self
.
assertNotEqual
(
'started'
,
instance
.
state
)
...
@@ -1710,7 +1715,8 @@ fi
...
@@ -1710,7 +1715,8 @@ fi
exit 0"""
%
{
'worked_file'
:
worked_file
,
'lockfile'
:
lockfile
})
exit 0"""
%
{
'worked_file'
:
worked_file
,
'lockfile'
:
lockfile
})
instance
.
setPromise
(
'promise_%d'
%
i
,
promise
)
instance
.
setPromise
(
'promise_%d'
%
i
,
promise
)
self
.
assertFalse
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapos
.
grid
.
slapgrid
.
SLAPGRID_PROMISE_FAIL
)
self
.
assertEquals
(
instance
.
error
,
1
)
self
.
assertEquals
(
instance
.
error
,
1
)
self
.
assertNotEqual
(
instance
.
state
,
'started'
)
self
.
assertNotEqual
(
instance
.
state
,
'started'
)
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