Skip to content

Commit

Permalink
Reverting as Github actions don't run this test as a swarm node:
Browse files Browse the repository at this point in the history
docker.errors.APIError: 503 Server Error for http+docker://localhost/v1.43/services/create: Service Unavailable ("This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.")

Revert "Final commit of this PR marking the test case that validates logging in the Docker Swarm Operator. We log two times a different message and we assert that the two lines are given back in the logs in the expected sequence."

This reverts commit 048ba1e.
  • Loading branch information
stavdav143 committed Dec 3, 2023
1 parent 6882e56 commit 235e565
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions tests/providers/docker/operators/test_docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
from __future__ import annotations

from unittest import TestCase, mock
from unittest import mock

import pytest
from docker import APIClient, types
Expand Down Expand Up @@ -209,33 +209,3 @@ def test_on_kill_client_not_created(self, docker_api_client_patcher):
op.on_kill()
docker_api_client_patcher.return_value.remove_service.assert_not_called()
mock_service.assert_not_called()

def test_logging(self):
"""
Test logging of operator.
"""
operator = DockerSwarmOperator(
command="""
/bin/bash -c '
echo "Test message 1";
echo "Test message 2";
'
""",
environment={"UNIT": "TEST"},
image="ubuntu:latest",
task_id="unit_test_logging",
enable_logging=True,
tty=False,
docker_url="unix://var/run/docker.sock",
mode=types.ServiceMode(mode="replicated-job"),
)

this_test = TestCase()
with this_test.assertLogs("airflow.task.operators", level="INFO") as logs:
operator.execute(None)

logs = "\n".join(logs.output)
this_test.assertRegex(
logs,
r"INFO:airflow\.task\.operators\.airflow\.providers\.docker\.operators\.docker_swarm.DockerSwarmOperator:Test message 1\nINFO:airflow\.task\.operators\.airflow\.providers\.docker\.operators\.docker_swarm.DockerSwarmOperator:Test message 2\n",
)

0 comments on commit 235e565

Please sign in to comment.