Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
02bd813a
Commit
02bd813a
authored
Aug 10, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into promises
Conflicts: slapos/tests/slapgrid.py
parents
a5378e7e
de598443
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
583 additions
and
32 deletions
+583
-32
buildout.cfg
buildout.cfg
+6
-0
master/product/Vifib/tests/testVifibSlapWebService.py
master/product/Vifib/tests/testVifibSlapWebService.py
+307
-27
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+270
-5
No files found.
buildout.cfg
View file @
02bd813a
...
@@ -3,6 +3,7 @@ develop = .
...
@@ -3,6 +3,7 @@ develop = .
parts =
parts =
slapos
slapos
pyflakes
pyflakes
test
find-links =
find-links =
http://www.nexedi.org/static/packages/source/slapos.buildout/
http://www.nexedi.org/static/packages/source/slapos.buildout/
...
@@ -44,5 +45,10 @@ eggs =
...
@@ -44,5 +45,10 @@ eggs =
rstctl
rstctl
interpreter = python
interpreter = python
[test]
recipe = zc.recipe.testrunner
eggs =
slapos.core
[versions]
[versions]
zc.buildout = 1.5.3-dev-SlapOS-005
zc.buildout = 1.5.3-dev-SlapOS-005
master/product/Vifib/tests/testVifibSlapWebService.py
View file @
02bd813a
...
@@ -3103,6 +3103,11 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -3103,6 +3103,11 @@ class TestVifibSlapWebService(testVifibMixin):
def
stepCheckSoftwareInstanceAndRelatedComputerPartition
(
self
,
def
stepCheckSoftwareInstanceAndRelatedComputerPartition
(
self
,
sequence
,
**
kw
):
sequence
,
**
kw
):
self
.
stepCheckSoftwareInstanceAndRelatedComputerPartitionNoPackingList
(
sequence
,
**
kw
)
self
.
_checkSoftwareInstanceAndRelatedPartition
(
software_instance
)
def
stepCheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
(
self
,
sequence
,
**
kw
):
software_instance_uid
=
sequence
[
'software_instance_uid'
]
software_instance_uid
=
sequence
[
'software_instance_uid'
]
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
software_instance_uid
)
uid
=
software_instance_uid
)
...
@@ -3110,7 +3115,6 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -3110,7 +3115,6 @@ class TestVifibSlapWebService(testVifibMixin):
predecessor_value_list
=
software_instance
.
getPredecessorValueList
()
predecessor_value_list
=
software_instance
.
getPredecessorValueList
()
self
.
assertEqual
(
1
,
len
(
predecessor_value_list
))
self
.
assertEqual
(
1
,
len
(
predecessor_value_list
))
self
.
_checkSoftwareInstanceAndRelatedPartition
(
software_instance
)
sequence
.
edit
(
sequence
.
edit
(
requested_software_instance_uid
=
predecessor_value_list
[
0
].
getUid
(),
requested_software_instance_uid
=
predecessor_value_list
[
0
].
getUid
(),
requested_software_instance_reference
=
predecessor_value_list
[
0
].
getReference
())
requested_software_instance_reference
=
predecessor_value_list
[
0
].
getReference
())
...
@@ -7623,12 +7627,42 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7623,12 +7627,42 @@ class TestVifibSlapWebService(testVifibMixin):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
def
stepStoreCurrentSoftwareInstanceUidBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_a_software_instance_uid'
]
=
sequence
[
'software_instance_uid'
]
def
stepStoreCurrentSoftwareInstanceUidBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_b_software_instance_uid'
]
=
sequence
[
'software_instance_uid'
]
def
stepStoreCurrentComputerUidBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_a_computer_uid'
]
=
sequence
[
'computer_uid'
]
def
stepStoreCurrentComputerUidBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_b_computer_uid'
]
=
sequence
[
'computer_uid'
]
def
stepRestoreSoftwareInstanceUidFromBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'software_instance_uid'
]
=
sequence
[
'buffer_a_software_instance_uid'
]
def
stepRestoreSoftwareInstanceUidFromBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'software_instance_uid'
]
=
sequence
[
'buffer_b_software_instance_uid'
]
def
stepRestoreComputerUidFromBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_uid'
]
=
sequence
[
'buffer_a_computer_uid'
]
def
stepRestoreComputerUidFromBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_uid'
]
=
sequence
[
'buffer_b_computer_uid'
]
def
stepStoreCurrentComputerReferenceBufferA
(
self
,
sequence
,
**
kw
):
def
stepStoreCurrentComputerReferenceBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_a_computer_reference'
]
=
sequence
[
'computer_reference'
]
sequence
[
'buffer_a_computer_reference'
]
=
sequence
[
'computer_reference'
]
def
stepStoreCurrentComputerReferenceBufferB
(
self
,
sequence
,
**
kw
):
def
stepStoreCurrentComputerReferenceBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_b_computer_reference'
]
=
sequence
[
'computer_reference'
]
sequence
[
'buffer_b_computer_reference'
]
=
sequence
[
'computer_reference'
]
def
stepStoreCurrentComputerPartitionUidBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_a_computer_partition_uid'
]
=
sequence
[
'computer_partition_uid'
]
def
stepStoreCurrentComputerPartitionUidBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_b_computer_partition_uid'
]
=
sequence
[
'computer_partition_uid'
]
def
stepStoreCurrentComputerPartitionReferenceBufferA
(
self
,
sequence
,
**
kw
):
def
stepStoreCurrentComputerPartitionReferenceBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'buffer_a_computer_partition_reference'
]
=
sequence
[
'computer_partition_reference'
]
sequence
[
'buffer_a_computer_partition_reference'
]
=
sequence
[
'computer_partition_reference'
]
...
@@ -7641,6 +7675,12 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7641,6 +7675,12 @@ class TestVifibSlapWebService(testVifibMixin):
def
stepRestoreComputerReferenceFromBufferB
(
self
,
sequence
,
**
kw
):
def
stepRestoreComputerReferenceFromBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_reference'
]
=
sequence
[
'buffer_b_computer_reference'
]
sequence
[
'computer_reference'
]
=
sequence
[
'buffer_b_computer_reference'
]
def
stepRestoreComputerPartitionUidFromBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_partition_uid'
]
=
sequence
[
'buffer_a_computer_partition_uid'
]
def
stepRestoreComputerPartitionUidFromBufferB
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_partition_uid'
]
=
sequence
[
'buffer_b_computer_partition_uid'
]
def
stepRestoreComputerPartitionReferenceFromBufferA
(
self
,
sequence
,
**
kw
):
def
stepRestoreComputerPartitionReferenceFromBufferA
(
self
,
sequence
,
**
kw
):
sequence
[
'computer_partition_reference'
]
=
sequence
[
'buffer_a_computer_partition_reference'
]
sequence
[
'computer_partition_reference'
]
=
sequence
[
'buffer_a_computer_partition_reference'
]
...
@@ -7652,31 +7692,149 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7652,31 +7692,149 @@ class TestVifibSlapWebService(testVifibMixin):
If software instance originated on computer comes from another computer it
If software instance originated on computer comes from another computer it
shall be possible to sucesfully destroy it.
shall be possible to sucesfully destroy it.
Test is done in a way to trigger unstable Assignor role calculation
on Hosting Subscription which leads to unavailability of Software Instances
from one computer to another.
"""
"""
sequence_list
=
SequenceList
()
sequence_list
=
SequenceList
()
sequence_string
=
self
.
prepare_install_requested_computer_partition_sequence_string
+
\
sequence_string
=
"""
"""
# Prepare software release shared by both Computers
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create first computer
LoginTestVifibAdmin
CreateComputer
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install software on first computer
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Now request and instantiate this software release on first computer
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
ConfirmOrderedSaleOrderActiveSense
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
StoreCurrentComputerPartitionReferenceBufferA
StoreCurrentComputerPartitionReferenceBufferA
"""
+
\
StoreCurrentComputerPartitionUidBufferA
self
.
prepare_formated_computer
+
\
StoreCurrentSoftwareInstanceUidBufferA
"""
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListConfirmed
Logout
# Start it..
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListStopped
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
# ...stop it...
LoginDefaultUser
RequestSoftwareInstanceStop
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListDelivered
Logout
# ...and request destruction
LoginDefaultUser
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# Now prepare second computer
LoginTestVifibAdmin
CreateComputer
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferB
StoreCurrentComputerReferenceBufferB
StoreCurrentComputer
PartitionReference
BufferB
StoreCurrentComputer
Uid
BufferB
LoginTestVifibAdmin
LoginTestVifibAdmin
RequestSoftwareInstallation
RequestSoftwareInstallation
Tic
Tic
Logout
Logout
SlapLoginCurrentComputer
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
ComputerSoftwareReleaseAvailable
Tic
Tic
SlapLogout
SlapLogout
StoreCurrentComputerReferenceBufferB
StoreCurrentComputerUidBufferB
# Now request self software release from one computer to another
RestoreComputerReferenceFromBufferA
RestoreComputerReferenceFromBufferA
RestoreComputer
PartitionReference
FromBufferA
RestoreComputer
Uid
FromBufferA
RestoreSoftwareInstanceUidFromBufferA
SlapLoginCurrentSoftwareInstance
SlapLoginCurrentSoftwareInstance
RequestComputerPartitionNotReadyResponse
RequestComputerPartitionNotReadyResponse
Tic
Tic
...
@@ -7688,55 +7846,179 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7688,55 +7846,179 @@ class TestVifibSlapWebService(testVifibMixin):
SlapLogout
SlapLogout
LoginDefaultUser
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartition
CheckSoftwareInstanceAndRelatedComputerPartition
NoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
CheckRequestedComputerPartitionCleanParameterList
Logout
Logout
StoreCurrentComputerPartitionReferenceBufferB
StoreCurrentComputerPartitionUidBufferB
StoreCurrentSoftwareInstanceUidBufferB
RestoreComputerReferenceFromBufferB
RestoreComputerUidFromBufferB
# Start the requested software instance...
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
CheckComputerPartitionInstanceSetupSalePackingListStopped
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
Logout
RestoreComputerReferenceFromBufferB
SlapLoginCurrentComputer
RestoreComputerPartitionReferenceFromBufferB
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
# ...and stop it
LoginDefaultUser
RequestSoftwareInstanceStop
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
SlapLoginCurrentComputer
SlapLoginCurrentComputer
SoftwareInstance
Building
SoftwareInstance
Stopped
Tic
Tic
SlapLogout
SlapLogout
LoginDefaultUser
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListStarted
CheckComputerPartitionInstanceHostingSalePackingListDelivered
Logout
# Now request destruction of second software instance...
LoginDefaultUser
RequestSoftwareInstanceDestroy
Tic
Logout
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# ...and destroy it
SlapLoginCurrentComputer
SlapLoginCurrentComputer
SoftwareInstance
Available
SoftwareInstance
Destroyed
Tic
Tic
SlapLogout
SlapLogout
LoginDefaultUser
LoginDefaultUser
CheckComputerPartitionInstance
SetupSalePackingListStopp
ed
CheckComputerPartitionInstance
CleanupSalePackingListDeliver
ed
CheckComputerPartitionI
nstanceHostingSalePackingListConfirmed
CheckComputerPartitionI
sFree
Logout
Logout
# Time to switch back to first software instance and destroy it
RestoreComputerPartitionReferenceFromBufferA
RestoreComputerPartitionUidFromBufferA
RestoreSoftwareInstanceUidFromBufferA
RestoreComputerReferenceFromBufferA
RestoreComputerUidFromBufferA
SlapLoginCurrentComputer
SlapLoginCurrentComputer
SoftwareInstance
Start
ed
SoftwareInstance
Destroy
ed
Tic
Tic
SlapLogout
SlapLogout
LoginDefaultUser
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
SetCurrentSoftwareInstanceRequester
CheckComputerPartitionIsFree
Logout
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_bug_hosting_subscription_assignor_role_instability
(
self
):
"""Show instability issue of Assignor role on Hosting Subscription
Related to fact when Hosting Subscription is associated to
Software Instances deployed on many computers"""
raise
NotImplementedError
def
test_bug_destruction_with_unfinished_packing_list
(
self
):
"""Proves that even if some packing lists are not fully delivered
it is possible to destroy software instance"""
sequence_list
=
SequenceList
()
sequence_string
=
"""
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create first computer
LoginTestVifibAdmin
CreateComputer
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install software on first computer
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Now request and instantiate this software release on first computer
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
ConfirmOrderedSaleOrderActiveSense
Tic
SetSelectedComputerPartition
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
SelectCurrentlyUsedSalePackingListUid
Logout
Logout
LoginTestVifibCustomer
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListConfirmed
Logout
# Request destruction...
LoginDefaultUser
RequestSoftwareInstanceDestroy
RequestSoftwareInstanceDestroy
Tic
Tic
Logout
Logout
...
@@ -7745,8 +8027,7 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7745,8 +8027,7 @@ class TestVifibSlapWebService(testVifibMixin):
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
Logout
RestoreComputerReferenceFromBufferA
# ...and destroy it
RestoreComputerPartitionReferenceFromBufferA
SlapLoginCurrentComputer
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
SoftwareInstanceDestroyed
...
@@ -7760,7 +8041,6 @@ class TestVifibSlapWebService(testVifibMixin):
...
@@ -7760,7 +8041,6 @@ class TestVifibSlapWebService(testVifibMixin):
"""
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
raise
NotImplementedError
########################################
########################################
# Other tests
# Other tests
...
...
slapos/tests/slapgrid.py
View file @
02bd813a
...
@@ -6,7 +6,9 @@ import shutil
...
@@ -6,7 +6,9 @@ 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
unittest
import
unittest
import
urlparse
import
urlparse
import
xml_marshaller
import
xml_marshaller
...
@@ -117,7 +119,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -117,7 +119,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'getComputerInformation'
and
\
if
parsed_url
.
path
==
'getComputerInformation'
and
\
'computer_id'
in
parsed_qs
:
'computer_id'
in
parsed_qs
:
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
]
[
0
]
)
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
])
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_software_release_list
=
[]
slap_computer
.
_computer_partition_list
=
[]
slap_computer
.
_computer_partition_list
=
[]
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
return
(
200
,
{},
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
))
...
@@ -138,9 +140,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -138,9 +140,9 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
parsed_qs
=
urlparse
.
parse_qs
(
parsed_url
.
query
)
if
parsed_url
.
path
==
'getComputerInformation'
and
\
if
parsed_url
.
path
==
'getComputerInformation'
and
\
'computer_id'
in
parsed_qs
:
'computer_id'
in
parsed_qs
:
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
]
[
0
]
)
slap_computer
=
slapos
.
slap
.
Computer
(
parsed_qs
[
'computer_id'
])
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'
)
partition
.
_need_modification
=
True
partition
.
_need_modification
=
True
sr
=
slapos
.
slap
.
SoftwareRelease
()
sr
=
slapos
.
slap
.
SoftwareRelease
()
...
@@ -153,14 +155,276 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -153,14 +155,276 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
return
(
404
,
{},
''
)
return
(
404
,
{},
''
)
httplib
.
HTTPConnection
.
_callback
=
server_response
httplib
.
HTTPConnection
.
_callback
=
server_response
instance_path
=
self
.
_create_instance
(
'0'
)
os
.
mkdir
(
self
.
software_root
)
software_hash
=
self
.
_bootstrap
()
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"""
)
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
),
[
'worked'
,
'buildout.cfg'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
software_hash
])
[
software_hash
])
def
test_one_partition_started
(
self
):
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
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 &&
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
)
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'
])
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
),
[
software_hash
])
def
test_one_partition_started_stopped
(
self
):
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
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
.
lstrip
(
'/'
))
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
())
def
test_one_partition_stopped_started
(
self
):
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
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
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 &&
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
)
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'worked'
,
'etc'
,
'buildout.cfg'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
software_hash
])
def
server_response
(
self
,
path
,
method
,
body
,
header
):
parsed_url
=
urlparse
.
urlparse
(
path
.
lstrip
(
'/'
))
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
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertSortedListEqual
(
os
.
listdir
(
partition
),
[
'.0_wrapper.log'
,
'worked'
,
'etc'
,
'buildout.cfg'
])
self
.
assertSortedListEqual
(
os
.
listdir
(
self
.
software_root
),
[
software_hash
])
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
())
def
test_one_failing_promise
(
self
):
def
test_one_failing_promise
(
self
):
def
server_response
(
self_httplib
,
path
,
method
,
body
,
header
):
def
server_response
(
self_httplib
,
path
,
method
,
body
,
header
):
...
@@ -256,3 +520,4 @@ exit 0""")
...
@@ -256,3 +520,4 @@ exit 0""")
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertTrue
(
self
.
grid
.
processComputerPartitionList
())
self
.
assertFalse
(
self
.
error
)
self
.
assertFalse
(
self
.
error
)
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