Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kolla Ansible
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Very Demiurge Very Mindful
Kolla Ansible
Commits
d1e427b7
Commit
d1e427b7
authored
6 years ago
by
Zuul
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Apply Resource Constraints to Openstack Services"
parents
b398cb2f
76210a2d
No related branches found
No related tags found
No related merge requests found
Changes
61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_kolla_docker.py
+76
-0
76 additions, 0 deletions
tests/test_kolla_docker.py
with
76 additions
and
0 deletions
tests/test_kolla_docker.py
+
76
−
0
View file @
d1e427b7
...
...
@@ -810,6 +810,82 @@ class TestAttrComp(base.BaseTestCase):
self
.
dw
=
get_DockerWorker
({
'
state
'
:
'
running
'
})
self
.
assertFalse
(
self
.
dw
.
compare_container_state
(
container_info
))
def
test_compare_dimensions_pos
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
{
'
blkio_weight
'
:
10
,
'
mem_limit
'
:
30
}
container_info
=
dict
()
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
0
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
''
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
0
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
0
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
assertTrue
(
self
.
dw
.
compare_dimensions
(
container_info
))
def
test_compare_dimensions_neg
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
{
'
blkio_weight
'
:
10
}
container_info
=
dict
()
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
0
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
''
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
10
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
0
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
assertFalse
(
self
.
dw
.
compare_dimensions
(
container_info
))
def
test_compare_wrong_dimensions
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
{
'
blki_weight
'
:
0
}
container_info
=
dict
()
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
0
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
''
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
0
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
0
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
dw
.
compare_dimensions
(
container_info
)
self
.
dw
.
module
.
exit_json
.
assert_called_once_with
(
failed
=
True
,
msg
=
repr
(
"
Unsupported dimensions
"
),
unsupported_dimensions
=
set
([
'
blki_weight
'
]))
def
test_compare_empty_dimensions
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
dict
()
container_info
=
dict
()
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
0
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
'
1
'
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
0
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
0
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
assertTrue
(
self
.
dw
.
compare_dimensions
(
container_info
))
def
test_compare_dimensions_removed_and_changed
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
{
'
mem_reservation
'
:
10
}
container_info
=
dict
()
# Here mem_limit and mem_reservation are already present
# Now we are updating only 'mem_reservation'.
# Ideally it should return True stating that the docker
# dimensions have been changed.
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
10
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
''
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
0
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
10
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
assertTrue
(
self
.
dw
.
compare_dimensions
(
container_info
))
def
test_compare_dimensions_explicit_default
(
self
):
self
.
fake_data
[
'
params
'
][
'
dimensions
'
]
=
{
'
mem_reservation
'
:
0
}
container_info
=
dict
()
# Here mem_limit and mem_reservation are already present
# Now we are updating only 'mem_reservation'.
# Ideally it should return True stating that the docker
# dimensions have been changed.
container_info
[
'
HostConfig
'
]
=
{
'
CpuPeriod
'
:
0
,
'
KernelMemory
'
:
0
,
'
Memory
'
:
0
,
'
CpuQuota
'
:
0
,
'
CpusetCpus
'
:
''
,
'
CpuShares
'
:
0
,
'
BlkioWeight
'
:
0
,
'
CpusetMems
'
:
''
,
'
MemorySwap
'
:
0
,
'
MemoryReservation
'
:
0
}
self
.
dw
=
get_DockerWorker
(
self
.
fake_data
[
'
params
'
])
self
.
assertFalse
(
self
.
dw
.
compare_dimensions
(
container_info
))
def
test_compare_container_state_pos
(
self
):
container_info
=
{
'
State
'
:
dict
(
Status
=
'
running
'
)}
self
.
dw
=
get_DockerWorker
({
'
state
'
:
'
exited
'
})
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment