-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrappers, tests/main/snap-service-timer: restore missing commit, add spread test for timer services #4758
Merged
bboozzoo
merged 6 commits into
snapcore:master
from
bboozzoo:bboozzoo/timer-services-spread-test
Mar 1, 2018
Merged
wrappers, tests/main/snap-service-timer: restore missing commit, add spread test for timer services #4758
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fcffc2f
tests/main/snap-service-timer: spread test for timer services
bboozzoo 8a3eb41
wrappers: proper formatting of multiple OnCalendar entries
bboozzoo 42967e9
tests/main/snap-service-timer: improve compatibility with old systemd…
bboozzoo 965f172
tests/lib/snaps/test-snapd-timer-service: comment the timers
bboozzoo 2407fec
tests/main/snap-service-timer: verify both timers on ubuntu-14.04
bboozzoo c3d3f52
wrappers: perform systemd daemon-reload if any service files were wri…
bboozzoo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
echo "called on $(date) as $1" | ||
|
||
for _ in $(seq 10); do | ||
echo "looping" | ||
sleep 0.5 | ||
done | ||
|
||
echo "finishing on $(date)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: test-snapd-timer-service | ||
version: 1.0 | ||
apps: | ||
regular-timer: | ||
command: bin/loop regular-timer | ||
daemon: simple | ||
# Run every 15 minutes | ||
timer: 0:00-24:00/96 | ||
random-timer: | ||
command: bin/loop random-timer | ||
daemon: simple | ||
# Run roughly every 15 minutes, with (some) random distribution | ||
timer: 0:00~24:00/96 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
summary: Check that snap timer services work | ||
|
||
execute: | | ||
echo "When the service snap is installed" | ||
. $TESTSLIB/snaps.sh | ||
install_local test-snapd-timer-service | ||
|
||
echo "We can see the timers being active" | ||
for service in regular-timer random-timer; do | ||
systemctl show -p ActiveState snap.test-snapd-timer-service.$service.timer | MATCH "ActiveState=active" | ||
systemctl show -p SubState snap.test-snapd-timer-service.$service.timer | MATCH "SubState=waiting" | ||
systemctl show -p Triggers snap.test-snapd-timer-service.$service.timer | \ | ||
MATCH "snap.test-snapd-timer-service.$service.service" | ||
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled" | ||
done | ||
# systemctl list-timers output: | ||
# NEXT LEFT LAST PASSED UNIT ACTIVATES | ||
# Fri 2018-02-23 11:00:00 CET 3min 25s left Fri 2018-02-23 10:45:36 CET 10min ago snap.timer-service-snap.regular-timer.timer snap.timer-service-snap.regular-timer.service | ||
# Fri 2018-02-23 11:01:00 CET 4min 25s left Fri 2018-02-23 10:51:36 CET 4min 58s ago snap.timer-service-snap.random-timer.timer snap.timer-service-snap.random-timer.service | ||
echo "When disabled, times are not listed by systemd" | ||
snap disable test-snapd-timer-service | ||
if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then | ||
for service in regular-timer random-timer; do | ||
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=" | ||
done | ||
else | ||
! systemctl list-timers | MATCH "test-snapd-timer-service" | ||
fi | ||
|
||
echo "When reenabled, the timers are present again" | ||
snap enable test-snapd-timer-service | ||
if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then | ||
for service in regular-timer random-timer; do | ||
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled" | ||
done | ||
else | ||
systemctl list-timers | MATCH "test-snapd-timer-service" | ||
fi | ||
|
||
echo "When removed, times are not listed by systemd" | ||
snap remove test-snapd-timer-service | ||
if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then | ||
for service in regular-timer random-timer; do | ||
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=" | ||
done | ||
else | ||
! systemctl list-timers | MATCH "test-snapd-timer-service" | ||
fi | ||
|
||
echo "No timer files are left behind" | ||
test $(find /etc/systemd/system -name 'snap.test-snapd-timer-service.*.timer' | wc -l) -eq "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we used to generate a broken service file that needs to be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The piece of code that did this got merged just today. On top of this, the snap won't install as systemd will reject the timer file we produced.