diff --git a/e2e/test_provider_proxy.py b/e2e/test_provider_proxy.py index a66675f7c..bc26f8d4f 100644 --- a/e2e/test_provider_proxy.py +++ b/e2e/test_provider_proxy.py @@ -1,4 +1,5 @@ """Proxy and Outpost e2e tests""" +from dataclasses import asdict from sys import platform from time import sleep from typing import Any, Dict, Optional @@ -14,7 +15,14 @@ from e2e.utils import USER, SeleniumTestCase from passbook import __version__ from passbook.core.models import Application from passbook.flows.models import Flow -from passbook.outposts.models import Outpost, OutpostDeploymentType, OutpostType +from passbook.outposts.models import ( + Outpost, + OutpostConfig, + OutpostDeploymentType, + OutpostType, + default_outpost_config, +) +from passbook.providers.proxy.controllers.docker import ProxyDockerController from passbook.providers.proxy.models import ProxyProvider @@ -104,27 +112,6 @@ class TestProviderProxy(SeleniumTestCase): class TestProviderProxyConnect(ChannelsLiveServerTestCase): """Test Proxy connectivity over websockets""" - proxy_container: Container - - def tearDown(self) -> None: - self.proxy_container.kill() - super().tearDown() - - def start_proxy(self, outpost: Outpost) -> Container: - """Start proxy container based on outpost created""" - client: DockerClient = from_env() - container = client.containers.run( - image=f"beryju/passbook-proxy:{__version__}", - detach=True, - network_mode="host", - auto_remove=True, - environment={ - "PASSBOOK_HOST": self.live_server_url, - "PASSBOOK_TOKEN": outpost.token.token_uuid.hex, - }, - ) - return container - def test_proxy_connectivity(self): """Test proxy connectivity over websocket""" SeleniumTestCase().apply_default_data() @@ -144,13 +131,14 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase): outpost: Outpost = Outpost.objects.create( name="proxy_outpost", type=OutpostType.PROXY, - deployment_type=OutpostDeploymentType.CUSTOM, + deployment_type=OutpostDeploymentType.DOCKER, + _config=asdict( + OutpostConfig(passbook_host=self.live_server_url, log_level="debug") + ), ) outpost.providers.add(proxy) outpost.save() - self.proxy_container = self.start_proxy(outpost) - # Wait until outpost healthcheck succeeds healthcheck_retries = 0 while healthcheck_retries < 50: @@ -164,3 +152,6 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase): state = outpost.state self.assertTrue(len(state), 1) self.assertEqual(state[0].version, __version__) + + # Make sure to delete the outpost to remove the container + outpost.delete() diff --git a/passbook/outposts/controllers/base.py b/passbook/outposts/controllers/base.py index e7af7b363..371ba65e1 100644 --- a/passbook/outposts/controllers/base.py +++ b/passbook/outposts/controllers/base.py @@ -35,11 +35,7 @@ class BaseController: """Call .up() but capture all log output and return it.""" with capture_logs() as logs: self.up() - log_messages = [] - for log in logs: - self.logger.debug(**log) - log_messages.append(f"{log['controller']}: {log['event']}") - return log_messages + return [f"{x['controller']}: {x['event']}" for x in logs] def down(self): """Handler to delete everything we've created""" diff --git a/passbook/outposts/controllers/docker.py b/passbook/outposts/controllers/docker.py index a47e1a7ae..e78624951 100644 --- a/passbook/outposts/controllers/docker.py +++ b/passbook/outposts/controllers/docker.py @@ -118,7 +118,7 @@ class DockerController(BaseController): try: container, _ = self._get_container() container.kill() - container.remove(force=True) + container.remove() except DockerException as exc: raise ControllerException from exc