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
e33d0947
Commit
e33d0947
authored
Aug 24, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: introduce crontab mixin
Helper class to check crontabs in software release tests
parent
85e411bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
slapos/testing/utils.py
slapos/testing/utils.py
+32
-0
No files found.
slapos/testing/utils.py
View file @
e33d0947
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
import
socket
import
socket
import
hashlib
import
hashlib
import
unittest
import
unittest
import
os
import
subprocess
from
contextlib
import
closing
from
contextlib
import
closing
try
:
try
:
...
@@ -60,6 +62,36 @@ def getPortFromPath(path):
...
@@ -60,6 +62,36 @@ def getPortFromPath(path):
16
)
%
(
65535
-
1024
)
16
)
%
(
65535
-
1024
)
class
CrontabMixin
(
object
):
computer_partition_root_path
=
None
# type: str
def
_getCrontabCommand
(
self
,
crontab_name
):
# type: (str) -> str
"""Read a crontab and return the command that is executed.
"""
with
open
(
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'etc'
,
'cron.d'
,
crontab_name
,
))
as
f
:
crontab_spec
=
f
.
read
()
return
" "
.
join
(
crontab_spec
.
split
()[
5
:])
def
_executeCrontabAtDate
(
self
,
crontab_name
,
date
):
# type: (str, str) -> None
"""Executes a crontab as if the current date was `date`.
`date` will be passed to faketime time command, it can also
be a relative time.
"""
crontab_command
=
self
.
_getCrontabCommand
(
crontab_name
)
subprocess
.
check_call
(
"faketime {date} bash -o pipefail -e -c '{crontab_command}'"
.
format
(
**
locals
()),
shell
=
True
,
)
class
ImageComparisonTestCase
(
unittest
.
TestCase
):
class
ImageComparisonTestCase
(
unittest
.
TestCase
):
"""TestCase with utility method to compare images.
"""TestCase with utility method to compare images.
...
...
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