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
Hardik Juneja
slapos.core
Commits
496d5613
Commit
496d5613
authored
Nov 27, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SlapOS Core] Make sure periodicity behaves correctly on non-started instances.
Remove early optimization.
parent
625175ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+0
-3
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+12
-10
No files found.
slapos/grid/slapgrid.py
View file @
496d5613
...
...
@@ -592,11 +592,8 @@ class Slapgrid(object):
if
periodicity
==
0
:
os
.
remove
(
timestamp_path
)
elif
int
(
timestamp
)
<=
int
(
old_timestamp
):
if
computer_partition
.
getState
()
!=
COMPUTER_PARTITION_STARTED_STATE
:
return
# Check periodicity, i.e if periodicity is one day, partition
# should be processed at least every day.
# Only do it for "started" instances
if
int
(
time
.
time
())
<=
(
last_runtime
+
periodicity
)
or
periodicity
<
0
:
self
.
logger
.
info
(
'Partition already up-to-date, skipping.'
)
return
...
...
slapos/tests/slapgrid.py
View file @
496d5613
...
...
@@ -1294,7 +1294,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
def
test_one_partition_stopped_is_not_processed_after_periodicity
(
self
):
"""
Check that periodicity
doesn't force processing a partitio
n if it is not
Check that periodicity
forces processing a partition eve
n if it is not
started.
"""
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
20
,
20
)
...
...
@@ -1320,18 +1320,19 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
time
.
sleep
(
1
)
self
.
launchSlapgrid
()
self
.
assertEqual
(
instance0
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
[
'availableComputerPartition'
,
'stoppedComputerPartition'
,
'availableComputerPartition'
,
'stoppedComputerPartition'
])
for
instance
in
computer
.
instance_list
[
1
:]:
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
self
.
assertEqual
(
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance0
.
partition_path
,
'.timestamp'
)),
last_runtime
)
self
.
assert
Not
Equal
(
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance0
.
partition_path
,
'.timestamp'
)),
last_runtime
)
self
.
assertNotEqual
(
wanted_periodicity
,
self
.
grid
.
maximum_periodicity
)
def
test_one_partition_destroyed_is_not_processed_after_periodicity
(
self
):
"""
Check that periodicity
doesn't force processing a partitio
n if it is not
Check that periodicity
forces processing a partition eve
n if it is not
started.
"""
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
20
,
20
)
...
...
@@ -1359,13 +1360,14 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance0
.
requested_state
=
'destroyed'
self
.
launchSlapgrid
()
self
.
assertEqual
(
instance0
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
[
'availableComputerPartition'
,
'stoppedComputerPartition'
,
'stoppedComputerPartition'
])
for
instance
in
computer
.
instance_list
[
1
:]:
self
.
assertEqual
(
instance
.
sequence
,
[
'availableComputerPartition'
,
'stoppedComputerPartition'
])
self
.
assertEqual
(
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance0
.
partition_path
,
'.timestamp'
)),
last_runtime
)
self
.
assert
Not
Equal
(
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance0
.
partition_path
,
'.timestamp'
)),
last_runtime
)
self
.
assertNotEqual
(
wanted_periodicity
,
self
.
grid
.
maximum_periodicity
)
def
test_one_partition_is_never_processed_when_periodicity_is_negative
(
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