-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SW-1882 Back propagate Stable into Beta #1580
Back propagate Stable into Beta
- Loading branch information
Showing
14 changed files
with
196 additions
and
14 deletions.
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
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/var/log/iobeam.log { | ||
size 2M | ||
rotate 4 | ||
rotate 3 | ||
compress | ||
delaycompress | ||
missingok | ||
notifempty | ||
copytruncate | ||
dateext | ||
dateformat .%Y-%m-%d | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
/var/log/mount_manager.log { | ||
size 2M | ||
rotate 2 | ||
rotate 3 | ||
compress | ||
delaycompress | ||
missingok | ||
notifempty | ||
copytruncate | ||
create 644 root root | ||
dateext | ||
dateformat .%Y-%m-%d | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
/var/log/mrb_check.log { | ||
size 5M | ||
rotate 4 | ||
rotate 3 | ||
compress | ||
delaycompress | ||
missingok | ||
notifempty | ||
copytruncate | ||
create 644 root root | ||
dateext | ||
dateformat .%Y-%m-%d | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
/var/log/mrbeam_ledstrips.log { | ||
size 2M | ||
rotate 2 | ||
rotate 3 | ||
compress | ||
delaycompress | ||
missingok | ||
notifempty | ||
copytruncate | ||
create 644 root root | ||
dateext | ||
dateformat .%Y-%m-%d | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/var/log/netconnectd.log { | ||
size 2M | ||
rotate 2 | ||
rotate 3 | ||
compress | ||
delaycompress | ||
missingok | ||
notifempty | ||
copytruncate | ||
dateext | ||
dateformat .%Y-%m-%d | ||
} |
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,54 @@ | ||
import os | ||
|
||
from octoprint_mrbeam.migration.migration_base import ( | ||
MigrationBaseClass, | ||
) | ||
|
||
|
||
class Mig003EnableLogrotateBuster(MigrationBaseClass): | ||
""" | ||
This migration should add logrotate for the buster image and change the lorotate for the legacy image | ||
""" | ||
|
||
MIGRATE_LOGROTATE_FOLDER = "files/migrate_logrotate/" | ||
BEAMOS_VERSION_LOW = "0.14.0" | ||
BEAMOS_VERSION_HIGH = "0.18.2" | ||
|
||
def __init__(self, plugin): | ||
super(Mig003EnableLogrotateBuster, self).__init__(plugin) | ||
|
||
@property | ||
def id(self): | ||
return "003" | ||
|
||
def _run(self): | ||
self._logger.debug("delete wrong iobeam logrotate") | ||
self.exec_cmd("sudo rm /etc/logrotate.d/iobeam.logrotate", optional=True) | ||
|
||
logrotates = [ | ||
"analytics", | ||
"iobeam", | ||
"mount_manager", | ||
"mrb_check", | ||
"mrbeam_ledstrips", | ||
"netconnectd", | ||
] | ||
for logrotate in logrotates: | ||
self._logger.debug("enable logrotate of " + logrotate) | ||
src = os.path.join( | ||
__package_path__, self.MIGRATE_LOGROTATE_FOLDER, logrotate | ||
) | ||
dst = os.path.join("/etc/logrotate.d/" + logrotate) | ||
self.exec_cmd("sudo cp {src} {dst}".format(src=src, dst=dst)) | ||
|
||
self._logger.debug( | ||
"restarting logrotate in order for the changed config to take effect" | ||
) | ||
|
||
# needs to be optional for legacy image, as this is returning 1 instead of 0 | ||
self.exec_cmd("sudo logrotate /etc/logrotate.conf", optional=True) | ||
super(Mig003EnableLogrotateBuster, self)._run() | ||
|
||
def _rollback(self): | ||
# no rollback needed | ||
super(Mig003EnableLogrotateBuster, self)._rollback() |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
|
||
from mock import patch | ||
|
||
from octoprint_mrbeam.migration import Mig003EnableLogrotateBuster | ||
import unittest | ||
|
||
|
||
class TestMigrationMig003(unittest.TestCase): | ||
""" | ||
Testclass for the migration Mig001 | ||
""" | ||
|
||
def setUp(self): | ||
self.m003 = Mig003EnableLogrotateBuster(None) | ||
|
||
def test_beamos_versions(self): | ||
# beamos versions where the migration should not run | ||
self.assertFalse(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0.19.0")) | ||
|
||
# beamos versions where the migration should run | ||
self.assertTrue(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0.14.0")) | ||
self.assertTrue(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0.18.0")) | ||
self.assertTrue(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0.18.1")) | ||
self.assertTrue(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0.18.2")) | ||
|
||
# not matching pattern strings | ||
self.assertFalse(self.m003.shouldrun(Mig003EnableLogrotateBuster, None)) | ||
self.assertFalse(self.m003.shouldrun(Mig003EnableLogrotateBuster, "14.0")) | ||
self.assertFalse(self.m003.shouldrun(Mig003EnableLogrotateBuster, "0")) | ||
|
||
def test_migration_id(self): | ||
self.assertEqual(self.m003.id, "003") | ||
|
||
@patch.object( | ||
Mig003EnableLogrotateBuster, | ||
"exec_cmd", | ||
) | ||
def test_commands_executed(self, exec_cmd_mock): | ||
self.m003.run() | ||
exec_cmd_mock.assert_any_call( | ||
"sudo rm /etc/logrotate.d/iobeam.logrotate", optional=True | ||
) | ||
logrotates = [ | ||
"analytics", | ||
"iobeam", | ||
"mount_manager", | ||
"mrb_check", | ||
"mrbeam_ledstrips", | ||
"netconnectd", | ||
] | ||
for logrotate in logrotates: | ||
dst = os.path.join("/etc/logrotate.d/" + logrotate) | ||
src = os.path.join( | ||
__package_path__, | ||
"files/migrate_logrotate", | ||
logrotate, | ||
) | ||
exec_cmd_mock.assert_any_call( | ||
"sudo cp {src} {dst}".format(src=src, dst=dst) | ||
) | ||
|
||
exec_cmd_mock.ssert_any_call("sudo logrotate /etc/logrotate.conf") |
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