-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monitor: Skip repo errors involving CDROM/file source
When using the rhsm command anaconda first tries the cdrom, and when it fails then tries the CDN. This causes lorax-composer to see the repo failure and exit too early, preventing it from working with rhsm. This should never show up during normal lmc usage, so it's safe to skip. Includes new tests in LogMonitorTest (cherry picked from commit df6cdfd) Resolves: RHEL-4658
- Loading branch information
Showing
2 changed files
with
71 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import socket | ||
import time | ||
import unittest | ||
|
||
from pylorax.monitor import LogMonitor | ||
|
||
class LogMonitorTest(unittest.TestCase): | ||
def test_monitor(self): | ||
monitor = LogMonitor(timeout=1) | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.connect((monitor.host, monitor.port)) | ||
s.sendall("Just a test string\nwith two and a half\nlines in it".encode("utf8")) | ||
time.sleep(1) | ||
self.assertFalse(monitor.server.log_check()) | ||
s.sendall("\nAnother line\nTraceback (Not a real traceback)\n".encode("utf8")) | ||
time.sleep(1) | ||
self.assertTrue(monitor.server.log_check()) | ||
self.assertEqual(monitor.server.error_line, "Traceback (Not a real traceback)") | ||
finally: | ||
monitor.shutdown() | ||
|
||
def test_monitor_repo(self): | ||
monitor = LogMonitor(timeout=1) | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.connect((monitor.host, monitor.port)) | ||
# Test a base repo cdrom failure | ||
# This does NOT cause an error, it can happen when using rhsm in the kickstart | ||
s.sendall("18:10:59,811 ERR anaconda:packaging: base repo (CDROM/file:///run/install/sources/mount-0000-cdrom) not valid -- removing it\n".encode("utf8")) | ||
time.sleep(1) | ||
self.assertFalse(monitor.server.log_check()) | ||
|
||
# Test a base repo failure message | ||
s.sendall("18:10:59,811 ERR anaconda:packaging: base repo (https://foo.bar) not valid -- removing it\n".encode("utf8")) | ||
time.sleep(1) | ||
self.assertTrue(monitor.server.log_check()) | ||
finally: | ||
monitor.shutdown() | ||
|
||
def test_monitor_IGNORED(self): | ||
monitor = LogMonitor(timeout=1) | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.connect((monitor.host, monitor.port)) | ||
s.sendall("Just a test string\nwith two and a half\nlines in it".encode("utf8")) | ||
time.sleep(1) | ||
self.assertFalse(monitor.server.log_check()) | ||
s.sendall("\nAnother line\nIGNORED: Traceback (Not a real traceback)\n".encode("utf8")) | ||
time.sleep(1) | ||
self.assertFalse(monitor.server.log_check()) | ||
self.assertEqual(monitor.server.error_line, "") | ||
finally: | ||
monitor.shutdown() | ||
|
||
def test_monitor_timeout(self): | ||
# Timeout is in minutes so to shorten the test we pass 0.1 | ||
monitor = LogMonitor(timeout=0.1) | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.connect((monitor.host, monitor.port)) | ||
s.sendall("Just a test string\nwith two and a half\nlines in it".encode("utf8")) | ||
time.sleep(1) | ||
self.assertFalse(monitor.server.log_check()) | ||
time.sleep(7) | ||
self.assertTrue(monitor.server.log_check()) | ||
self.assertEqual(monitor.server.error_line, "") | ||
finally: | ||
monitor.shutdown() |