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
Léo-Paul Géneau
slapos.core
Commits
98d89154
Commit
98d89154
authored
Jul 31, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: test instance bang implementation in slapproxy
parent
43e3828c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
18 deletions
+46
-18
slapos/tests/test_slapproxy.py
slapos/tests/test_slapproxy.py
+46
-18
No files found.
slapos/tests/test_slapproxy.py
View file @
98d89154
...
...
@@ -479,29 +479,57 @@ class TestRequest(MasterMixin):
time
.
sleep
(.
1
)
# check timestamp does not change for an identical request
self
.
assertEqual
(
partition
.
__dict__
,
do_request
().
__dict__
)
def
test_instance_bang
(
self
):
"""
Check that instance bang update the timestamps of all partitions in the
instance.
"""
self
.
add_free_partition
(
3
)
requested_at
=
time
.
time
()
parent
=
self
.
request
(
'http://sr//'
,
None
,
'MyFirstInstance'
)
child
=
self
.
request
(
'http://sr//'
,
None
,
'MySubInstance'
,
parent
.
_partition_id
)
other
=
self
.
request
(
'http://sr//'
,
None
,
'AnotherInstance'
)
for
partition
in
parent
,
child
,
other
:
self
.
assertLessEqual
(
float
(
str
(
requested_at
)),
float
(
partition
.
_parameter_dict
[
'timestamp'
]))
other_timestamp
=
other
.
_parameter_dict
[
'timestamp'
]
def
getTimestamp
(
partition
):
return
self
.
getPartitionInformation
(
partition
.
_partition_id
).
_parameter_dict
[
'timestamp'
]
for
partition
in
parent
,
child
:
time
.
sleep
(.
1
)
bang_at
=
time
.
time
()
self
.
app
.
post
(
'/softwareInstanceBang'
,
data
=
{
'computer_id'
:
self
.
computer_id
,
'computer_partition_id'
:
partition
.
_partition_id
,
'message'
:
self
.
id
()})
timestamp
=
getTimestamp
(
parent
)
self
.
assertLessEqual
(
float
(
str
(
requested_at
)),
float
(
timestamp
))
self
.
assertEqual
(
getTimestamp
(
child
),
timestamp
)
self
.
assertEqual
(
getTimestamp
(
other
),
other_timestamp
)
def
test_request_propagate_partition_state
(
self
):
"""
Request will return same partition for two equal requests
"""
self
.
add_free_partition
(
2
)
partition_parent
=
self
.
request
(
'http://sr//'
,
None
,
'MyFirstInstance'
)
parent_dict
=
partition_parent
.
__dict__
partition_child
=
self
.
request
(
'http://sr//'
,
None
,
'MySubInstance'
,
parent_dict
[
'_partition_id'
])
self
.
assertEqual
(
partition_parent
.
getState
(),
'started'
)
self
.
assertEqual
(
partition_child
.
getState
(),
'started'
)
partition_parent
=
self
.
request
(
'http://sr//'
,
None
,
'MyFirstInstance'
,
state
=
'stopped'
)
partition_child
=
self
.
request
(
'http://sr//'
,
None
,
'MySubInstance'
,
parent_dict
[
'_partition_id'
])
self
.
assertEqual
(
partition_parent
.
getState
(),
'stopped'
)
self
.
assertEqual
(
partition_child
.
getState
(),
'stopped'
)
partition_parent
=
self
.
request
(
'http://sr//'
,
None
,
'MyFirstInstance'
,
state
=
'started'
)
partition_child
=
self
.
request
(
'http://sr//'
,
None
,
'MySubInstance'
,
parent_dict
[
'_partition_id'
])
self
.
assertEqual
(
partition_parent
.
getState
(),
'started'
)
self
.
assertEqual
(
partition_child
.
getState
(),
'started'
)
def
request_parent
(
**
kw
):
return
self
.
request
(
'http://sr//'
,
None
,
'MyFirstInstance'
,
**
kw
)
def
request_child
():
return
self
.
request
(
'http://sr//'
,
None
,
'MySubInstance'
,
parent_id
)
parent
=
request_parent
()
parent_id
=
parent
.
_partition_id
child
=
request_child
()
self
.
assertEqual
(
'started'
,
parent
.
getState
())
self
.
assertEqual
(
'started'
,
child
.
getState
())
for
state
in
'stopped'
,
'started'
:
parent
=
request_parent
(
state
=
state
)
child
=
request_child
()
self
.
assertEqual
(
state
,
parent
.
getState
())
self
.
assertEqual
(
state
,
child
.
getState
())
def
test_request_parent_started_children_stopped
(
self
):
"""
...
...
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