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
Boxiang Sun
slapos.core
Commits
65fbdbd3
Commit
65fbdbd3
authored
Sep 07, 2012
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed _need_modification from tests, fixed timestamp test
parent
0226c889
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
56 deletions
+24
-56
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+24
-56
No files found.
slapos/tests/slapgrid.py
View file @
65fbdbd3
...
@@ -168,7 +168,6 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -168,7 +168,6 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -228,7 +227,6 @@ touch worked""")
...
@@ -228,7 +227,6 @@ touch worked""")
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -305,7 +303,6 @@ chmod 755 etc/run/wrapper
...
@@ -305,7 +303,6 @@ chmod 755 etc/run/wrapper
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -390,7 +387,6 @@ chmod 755 etc/run/wrapper
...
@@ -390,7 +387,6 @@ chmod 755 etc/run/wrapper
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -447,7 +443,6 @@ chmod 755 etc/run/wrapper
...
@@ -447,7 +443,6 @@ chmod 755 etc/run/wrapper
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -514,7 +509,6 @@ chmod 755 etc/run/wrapper
...
@@ -514,7 +509,6 @@ chmod 755 etc/run/wrapper
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -571,26 +565,28 @@ chmod 755 etc/run/wrapper
...
@@ -571,26 +565,28 @@ chmod 755 etc/run/wrapper
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
partition
.
_requested_state
=
'st
opp
ed'
partition
.
_requested_state
=
'st
art
ed'
partition
.
_parameter_dict
=
{
'timestamp'
:
self
.
timestamp
}
partition
.
_parameter_dict
=
{
'timestamp'
:
self
.
timestamp
}
slap_computer
.
_computer_partition_list
=
[
partition
]
slap_computer
.
_computer_partition_list
=
[
partition
]
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
if
parsed_url
.
path
==
'availableComputerPartition'
and
\
if
parsed_url
.
path
==
'availableComputerPartition'
and
\
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
return
(
200
,
{},
''
)
return
(
200
,
{},
''
)
if
parsed_url
.
path
==
'st
opp
edComputerPartition'
and
\
if
parsed_url
.
path
==
'st
art
edComputerPartition'
and
\
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
self
.
assertEqual
(
parsed_qs
[
'computer_partition_id'
][
0
],
'0'
)
self
.
started
=
True
return
(
200
,
{},
''
)
return
(
200
,
{},
''
)
else
:
else
:
return
(
404
,
{},
''
)
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
httplib
.
HTTPConnection
.
_callback
=
server_response
self
.
sequence
=
[]
self
.
sequence
=
[]
self
.
timestamp
=
str
(
time
.
time
())
self
.
timestamp
=
str
(
int
(
time
.
time
()))
self
.
started
=
False
os
.
mkdir
(
self
.
software_root
)
os
.
mkdir
(
self
.
software_root
)
os
.
mkdir
(
self
.
instance_root
)
os
.
mkdir
(
self
.
instance_root
)
...
@@ -604,54 +600,33 @@ chmod 755 etc/run/wrapper
...
@@ -604,54 +600,33 @@ chmod 755 etc/run/wrapper
srbindir
=
os
.
path
.
join
(
srdir
,
'bin'
)
srbindir
=
os
.
path
.
join
(
srdir
,
'bin'
)
os
.
mkdir
(
srbindir
)
os
.
mkdir
(
srbindir
)
open
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
'w'
).
write
(
"""#!/bin/sh
open
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
'w'
).
write
(
"""#!/bin/sh
touch worked"""
)
touch worked &&
mkdir -p etc/run &&
echo "#!/bin/sh" > etc/run/wrapper &&
echo "while :; do echo "Working
\
\
nWorking
\
\
n" ; done" >> etc/run/wrapper &&
chmod 755 etc/run/wrapper
"""
)
os
.
chmod
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
0755
)
os
.
chmod
(
os
.
path
.
join
(
srbindir
,
'buildout'
),
0755
)
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
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'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition_path
),
[
'.0_wrapper.log'
,
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.timestamp'
,
'worked'
,
'worked'
,
'buildout.cfg'
,
'etc'
,
'.timestamp'
])
'buildout.cfg'
])
tries
=
10
wrapper_log
=
os
.
path
.
join
(
partition_path
,
'.0_wrapper.log'
)
while
tries
>
0
:
tries
-=
1
if
os
.
path
.
getsize
(
wrapper_log
)
>
0
:
break
time
.
sleep
(
0.2
)
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
server_response
(
self_httplib
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
self
.
sequence
.
append
(
parsed_url
.
path
)
if
method
==
'GET'
:
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
else
:
parsed_qs
=
urlparse
.
parse_qs
(
body
)
if
parsed_url
.
path
==
'getFullComputerInformation'
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
=
False
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_requested_state
=
'stopped'
partition
.
_parameter_dict
=
{
'timestamp'
:
self
.
timestamp
}
slap_computer
.
_computer_partition_list
=
[
partition
]
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
if
parsed_url
.
path
==
'availableComputerPartition'
and
\
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
return
(
200
,
{},
''
)
if
parsed_url
.
path
==
'stoppedComputerPartition'
and
\
method
==
'POST'
and
'computer_partition_id'
in
parsed_qs
:
return
(
200
,
{},
''
)
else
:
return
(
404
,
{},
''
)
self
.
setSlapgrid
()
self
.
setSlapgrid
()
self
.
grid
.
develop
=
True
httplib
.
HTTPConnection
.
_callback
=
server_response
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertEqual
(
self
.
sequence
,
self
.
assertEqual
(
self
.
sequence
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
[
'getFullComputerInformation'
,
'availableComputerPartition'
,
'st
opp
edComputerPartition'
,
'getFullComputerInformation'
])
'st
art
edComputerPartition'
,
'getFullComputerInformation'
])
...
@@ -753,7 +728,6 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
...
@@ -753,7 +728,6 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -815,7 +789,6 @@ exit 127""" % {'worked_file': worked_file})
...
@@ -815,7 +789,6 @@ exit 127""" % {'worked_file': worked_file})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -877,7 +850,6 @@ exit 0""" % {'worked_file': worked_file})
...
@@ -877,7 +850,6 @@ exit 0""" % {'worked_file': worked_file})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -945,7 +917,6 @@ exit 127""" % {'worked_file': worked_file})
...
@@ -945,7 +917,6 @@ exit 127""" % {'worked_file': worked_file})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -1013,7 +984,6 @@ exit 0""" % {'worked_file': worked_file})
...
@@ -1013,7 +984,6 @@ exit 0""" % {'worked_file': worked_file})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -1086,7 +1056,6 @@ exit 0""" % {'worked_file': worked_file_2})
...
@@ -1086,7 +1056,6 @@ exit 0""" % {'worked_file': worked_file_2})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
@@ -1160,7 +1129,6 @@ fi""" % {'worked_file': worked_file, 'lockfile': lockfile})
...
@@ -1160,7 +1129,6 @@ fi""" % {'worked_file': worked_file, 'lockfile': lockfile})
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
partition
=
slapos
.
slap
.
ComputerPartition
(
parsed_qs
[
'computer_id'
][
0
],
'0'
)
'0'
)
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
.
_software_release
=
'http://sr/'
sr
.
_software_release
=
'http://sr/'
partition
.
_software_release_document
=
sr
partition
.
_software_release_document
=
sr
...
...
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