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
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
8d53319d
Commit
8d53319d
authored
Aug 09, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prove that stopping started partition works.
parent
1c4887c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+103
-0
No files found.
slapos/tests/slapgrid.py
View file @
8d53319d
...
@@ -6,6 +6,7 @@ import shutil
...
@@ -6,6 +6,7 @@ import shutil
import
signal
import
signal
import
slapos.slap.slap
import
slapos.slap.slap
import
socket
import
socket
import
sys
import
tempfile
import
tempfile
import
time
import
time
import
unittest
import
unittest
...
@@ -210,3 +211,105 @@ chmod 755 etc/run/wrapper
...
@@ -210,3 +211,105 @@ chmod 755 etc/run/wrapper
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
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
software_hash
])
[
software_hash
])
def
test_one_partition_started_stopped
(
self
):
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
'/'
+
path
)
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'/getComputerInformation'
and
\
'computer_id'
in
parsed_qs
:
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
])
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_requested_state
=
'started'
slap_computer
.
_computer_partition_list
=
[
partition
]
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
else
:
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
os
.
mkdir
(
self
.
software_root
)
os
.
mkdir
(
self
.
instance_root
)
partition_path
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
os
.
mkdir
(
partition_path
,
0750
)
software_hash
=
slapos
.
grid
.
utils
.
getSoftwareUrlHash
(
'http://sr/'
)
srdir
=
os
.
path
.
join
(
self
.
software_root
,
software_hash
)
os
.
mkdir
(
srdir
)
open
(
os
.
path
.
join
(
srdir
,
'template.cfg'
),
'w'
).
write
(
"""[buildout]"""
)
srbindir
=
os
.
path
.
join
(
srdir
,
'bin'
)
os
.
mkdir
(
srbindir
)
open
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
'w'
).
write
(
"""#!/bin/sh
touch worked &&
mkdir -p etc/run &&
(
cat <<'HEREDOC'
#!%(python)s
import signal
def handler(signum, frame):
print 'Signal handler called with signal', signum
raise SystemExit
signal.signal(signal.SIGTERM, handler)
while True:
print "Working"
HEREDOC
)> etc/run/wrapper &&
chmod 755 etc/run/wrapper
"""
%
dict
(
python
=
sys
.
executable
))
os
.
chmod
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
0755
)
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition_path
),
[
'.0_wrapper.log'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
wrapper_log
=
os
.
path
.
join
(
partition_path
,
'.0_wrapper.log'
)
tries
=
10
while
tries
>
0
:
tries
-=
1
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.2
)
last_size
=
os
.
path
.
getsize
(
wrapper_log
)
self
.
assertTrue
(
'Working'
in
open
(
wrapper_log
,
'r'
).
read
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
software_hash
])
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
'/'
+
path
)
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'/getComputerInformation'
and
\
'computer_id'
in
parsed_qs
:
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
])
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_requested_state
=
'stopped'
slap_computer
.
_computer_partition_list
=
[
partition
]
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
else
:
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
partition_path
),
[
'.0_wrapper.log'
,
'.0_wrapper.log.1'
,
'worked'
,
'buildout.cfg'
,
'etc'
])
tries
=
10
while
tries
>
0
:
tries
-=
1
if
os
.
path
.
getsize
(
wrapper_log
)
>
last_size
:
break
time
.
sleep
(
0.2
)
self
.
assertTrue
(
'Signal handler called with signal 15'
in
open
(
wrapper_log
,
'r'
).
read
())
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