Merge pull request #2720 from seguins/2227-improvements-logs

Add flags on logs
This commit is contained in:
Aanand Prasad 2016-03-01 17:41:31 -08:00
commit 0b3561a7d5
9 changed files with 104 additions and 18 deletions

View file

@ -398,6 +398,8 @@ class CLITestCase(DockerClientTestCase):
assert 'simple_1 | simple' in result.stdout
assert 'another_1 | another' in result.stdout
assert 'simple_1 exited with code 0' in result.stdout
assert 'another_1 exited with code 0' in result.stdout
@v2_only()
def test_up(self):
@ -1159,6 +1161,42 @@ class CLITestCase(DockerClientTestCase):
def test_logs_invalid_service_name(self):
self.dispatch(['logs', 'madeupname'], returncode=1)
def test_logs_follow(self):
self.base_dir = 'tests/fixtures/echo-services'
self.dispatch(['up', '-d'], None)
result = self.dispatch(['logs', '-f'])
assert result.stdout.count('\n') == 5
assert 'simple' in result.stdout
assert 'another' in result.stdout
assert 'exited with code 0' in result.stdout
def test_logs_unfollow(self):
self.base_dir = 'tests/fixtures/logs-composefile'
self.dispatch(['up', '-d'], None)
result = self.dispatch(['logs'])
assert result.stdout.count('\n') >= 1
assert 'exited with code 0' not in result.stdout
def test_logs_timestamps(self):
self.base_dir = 'tests/fixtures/echo-services'
self.dispatch(['up', '-d'], None)
result = self.dispatch(['logs', '-f', '-t'], None)
self.assertRegexpMatches(result.stdout, '(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})')
def test_logs_tail(self):
self.base_dir = 'tests/fixtures/logs-tail-composefile'
self.dispatch(['up'], None)
result = self.dispatch(['logs', '--tail', '2'], None)
assert result.stdout.count('\n') == 3
def test_kill(self):
self.dispatch(['up', '-d'], None)
service = self.project.get_service('simple')