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
Ivan Tyagov
slapos.core
Commits
d9e40d34
Commit
d9e40d34
authored
Jun 06, 2013
by
Thomas Larrieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished working on periodicity 'always force/always skip'
parent
0b2b9f6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+4
-2
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+42
-0
No files found.
slapos/grid/slapgrid.py
View file @
d9e40d34
...
...
@@ -587,13 +587,15 @@ class Slapgrid(object):
last_runtime
=
int
(
os
.
path
.
getmtime
(
timestamp_path
))
if
timestamp
:
try
:
if
int
(
timestamp
)
<=
int
(
old_timestamp
):
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
):
if
int
(
time
.
time
())
<=
(
last_runtime
+
periodicity
)
or
periodicity
<
0
:
self
.
logger
.
info
(
'Partition already up-to-date, skipping.'
)
return
else
:
...
...
slapos/tests/slapgrid.py
View file @
d9e40d34
...
...
@@ -1168,6 +1168,48 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
last_runtime
)
self
.
assertNotEqual
(
wanted_periodicity
,
self
.
grid
.
maximum_periodicity
)
def
test_one_partition_is_never_processed_when_periodicity_is_negative
(
self
):
"""
Checks that a partition is not processed when
its periodicity is negative
"""
def
get_runtime
(
instance
):
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)))
return
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
))
periodicity
=
-
1
timestamp
=
str
(
int
(
time
.
time
()))
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
1
,
1
)
instance
=
computer
.
instance_list
[
0
]
instance
.
software
.
setPeriodicity
(
periodicity
)
instance
.
timestamp
=
timestamp
self
.
launchSlapgrid
()
first_runtime
=
get_runtime
(
instance
)
self
.
launchSlapgrid
()
second_runtime
=
get_runtime
(
instance
)
self
.
assertEqual
(
first_runtime
,
second_runtime
)
def
test_one_partition_is_always_processed_when_periodicity_is_zero
(
self
):
"""
Checks that a partition is always processed when
its periodicity is 0
"""
def
get_runtime
(
instance
):
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
)))
return
os
.
path
.
getmtime
(
os
.
path
.
join
(
instance
.
partition_path
,
'.timestamp'
))
periodicity
=
0
timestamp
=
str
(
int
(
time
.
time
()))
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
1
,
1
)
instance
=
computer
.
instance_list
[
0
]
instance
.
software
.
setPeriodicity
(
periodicity
)
instance
.
timestamp
=
timestamp
self
.
launchSlapgrid
()
first_runtime
=
get_runtime
(
instance
)
self
.
launchSlapgrid
()
second_runtime
=
get_runtime
(
instance
)
self
.
assertNotEqual
(
first_runtime
,
second_runtime
)
def
test_one_partition_buildout_fail_does_not_disturb_others
(
self
):
"""
1. We set up two instance one using a corrupted buildout
...
...
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