Browse Source

Merge pull request #2082 from dnephin/bump-1.4.2

[WIP] Release 1.4.2
Daniel Nephin 10 years ago
parent
commit
d59c759cdd

+ 7 - 0
CHANGES.md

@@ -1,6 +1,13 @@
 Change log
 ==========
 
+1.4.2 (2015-09-22)
+------------------
+
+Fixes a regression in the 1.4.1 release that would cause `docker-compose up`
+without the `-d` option to exit immediately.
+
+
 1.4.1 (2015-09-10)
 ------------------
 

+ 1 - 1
compose/__init__.py

@@ -1,3 +1,3 @@
 from __future__ import unicode_literals
 
-__version__ = '1.4.1'
+__version__ = '1.4.2'

+ 4 - 1
compose/cli/main.py

@@ -541,8 +541,11 @@ class TopLevelCommand(Command):
 
 
 def build_log_printer(containers, service_names, monochrome):
+    if service_names:
+        containers = [c for c in containers if c.service in service_names]
+
     return LogPrinter(
-        [c for c in containers if c.service in service_names],
+        containers,
         attach_params={"logs": True},
         monochrome=monochrome)
 

+ 1 - 1
docs/install.md

@@ -53,7 +53,7 @@ To install Compose, do the following:
 6. Test the installation.
 
         $ docker-compose --version
-        docker-compose version: 1.4.1
+        docker-compose version: 1.4.2
 
 ## Upgrading
 

+ 24 - 5
tests/integration/cli_test.py

@@ -4,6 +4,7 @@ import sys
 import os
 import shlex
 
+import mock
 from six import StringIO
 from mock import patch
 
@@ -104,7 +105,7 @@ class CLITestCase(DockerClientTestCase):
         output = mock_stdout.getvalue()
         self.assertNotIn(cache_indicator, output)
 
-    def test_up(self):
+    def test_up_detached(self):
         self.command.dispatch(['up', '-d'], None)
         service = self.project.get_service('simple')
         another = self.project.get_service('another')
@@ -112,10 +113,28 @@ class CLITestCase(DockerClientTestCase):
         self.assertEqual(len(another.containers()), 1)
 
         # Ensure containers don't have stdin and stdout connected in -d mode
-        config = service.containers()[0].inspect()['Config']
-        self.assertFalse(config['AttachStderr'])
-        self.assertFalse(config['AttachStdout'])
-        self.assertFalse(config['AttachStdin'])
+        container, = service.containers()
+        self.assertFalse(container.get('Config.AttachStderr'))
+        self.assertFalse(container.get('Config.AttachStdout'))
+        self.assertFalse(container.get('Config.AttachStdin'))
+
+    def test_up_attached(self):
+        with mock.patch(
+            'compose.cli.main.attach_to_logs',
+            autospec=True
+        ) as mock_attach:
+            self.command.dispatch(['up'], None)
+            _, args, kwargs = mock_attach.mock_calls[0]
+            _project, log_printer, _names, _timeout = args
+
+        service = self.project.get_service('simple')
+        another = self.project.get_service('another')
+        self.assertEqual(len(service.containers()), 1)
+        self.assertEqual(len(another.containers()), 1)
+        self.assertEqual(
+            set(log_printer.containers),
+            set(self.project.containers())
+        )
 
     def test_up_with_links(self):
         self.command.base_dir = 'tests/fixtures/links-composefile'

+ 5 - 2
tests/integration/service_test.py

@@ -10,6 +10,7 @@ import shutil
 from six import StringIO, text_type
 
 from .testcases import DockerClientTestCase
+from .testcases import pull_busybox
 from compose import __version__
 from compose.const import (
     LABEL_CONTAINER_NUMBER,
@@ -577,8 +578,10 @@ class ServiceTest(DockerClientTestCase):
         })
 
     def test_create_with_image_id(self):
-        # Image id for the current busybox:latest
-        service = self.create_service('foo', image='8c2e06607696')
+        # Get image id for the current busybox:latest
+        pull_busybox(self.client)
+        image_id = self.client.inspect_image('busybox:latest')['Id'][:12]
+        service = self.create_service('foo', image=image_id)
         service.create_container()
 
     def test_scale(self):

+ 10 - 0
tests/integration/testcases.py

@@ -1,5 +1,8 @@
 from __future__ import unicode_literals
 from __future__ import absolute_import
+
+from docker import errors
+
 from compose.service import Service
 from compose.config import ServiceLoader
 from compose.const import LABEL_PROJECT
@@ -8,6 +11,13 @@ from compose.progress_stream import stream_output
 from .. import unittest
 
 
+def pull_busybox(client):
+    try:
+        client.inspect_image('busybox:latest')
+    except errors.APIError:
+        client.pull('busybox:latest', stream=False)
+
+
 class DockerClientTestCase(unittest.TestCase):
     @classmethod
     def setUpClass(cls):

+ 10 - 0
tests/unit/cli/main_test.py

@@ -31,6 +31,16 @@ class CLIMainTestCase(unittest.TestCase):
         log_printer = build_log_printer(containers, service_names, True)
         self.assertEqual(log_printer.containers, containers[:3])
 
+    def test_build_log_printer_all_services(self):
+        containers = [
+            mock_container('web', 1),
+            mock_container('db', 1),
+            mock_container('other', 1),
+        ]
+        service_names = []
+        log_printer = build_log_printer(containers, service_names, True)
+        self.assertEqual(log_printer.containers, containers)
+
     def test_attach_to_logs(self):
         project = mock.create_autospec(Project)
         log_printer = mock.create_autospec(LogPrinter, containers=[])