Implement Docker healthcheck functionality and improve progress message handling
All checks were successful
Publish Twitch Archive Container / publish (push) Successful in 1m30s
All checks were successful
Publish Twitch Archive Container / publish (push) Successful in 1m30s
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
cd3e37ff59
commit
9d5c707646
5 changed files with 96 additions and 7 deletions
|
|
@ -767,6 +767,55 @@ class TestEnvironmentLoadingRegression(unittest.TestCase):
|
|||
self.module.TwitchArchive._load_environment_variables(archive)
|
||||
|
||||
|
||||
class TestHealthcheckRegression(unittest.TestCase):
|
||||
"""Regression tests for Docker healthcheck behavior."""
|
||||
|
||||
def setUp(self):
|
||||
self.module = load_twitch_archive_module()
|
||||
|
||||
@patch.object(os, 'getenv', side_effect=lambda name, default=None: default)
|
||||
def test_run_healthcheck_fails_when_heartbeat_is_missing(self, _mock_getenv):
|
||||
config_manager = MagicMock()
|
||||
config_manager.get_all_enabled_streamers.return_value = ['maddoscientist0']
|
||||
config_manager.load_streamer_config.return_value = {'downloadVOD': False, 'downloadCHAT': False, 'uploadCloud': False}
|
||||
|
||||
archive = MagicMock()
|
||||
archive.os_type = 'linux'
|
||||
archive.downloadVOD = False
|
||||
archive.downloadCHAT = False
|
||||
archive.uploadCloud = False
|
||||
|
||||
with patch.object(self.module, 'ConfigManager', return_value=config_manager), \
|
||||
patch.object(self.module, 'TwitchArchive', return_value=archive), \
|
||||
patch.object(self.module, 'verify_streamlink', return_value=True), \
|
||||
patch.object(self.module, 'verify_ffmpeg', return_value=True), \
|
||||
patch.object(self.module, 'has_fresh_healthcheck_heartbeat', return_value=False):
|
||||
result = self.module.run_healthcheck('maddoscientist0')
|
||||
|
||||
self.assertEqual(result, 1)
|
||||
|
||||
@patch.object(os, 'getenv', side_effect=lambda name, default=None: default)
|
||||
def test_run_healthcheck_succeeds_with_fresh_heartbeat(self, _mock_getenv):
|
||||
config_manager = MagicMock()
|
||||
config_manager.get_all_enabled_streamers.return_value = ['maddoscientist0']
|
||||
config_manager.load_streamer_config.return_value = {'downloadVOD': False, 'downloadCHAT': False, 'uploadCloud': False}
|
||||
|
||||
archive = MagicMock()
|
||||
archive.os_type = 'linux'
|
||||
archive.downloadVOD = False
|
||||
archive.downloadCHAT = False
|
||||
archive.uploadCloud = False
|
||||
|
||||
with patch.object(self.module, 'ConfigManager', return_value=config_manager), \
|
||||
patch.object(self.module, 'TwitchArchive', return_value=archive), \
|
||||
patch.object(self.module, 'verify_streamlink', return_value=True), \
|
||||
patch.object(self.module, 'verify_ffmpeg', return_value=True), \
|
||||
patch.object(self.module, 'has_fresh_healthcheck_heartbeat', return_value=True):
|
||||
result = self.module.run_healthcheck('maddoscientist0')
|
||||
|
||||
self.assertEqual(result, 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Run tests with verbose output
|
||||
print("="*70)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue