From 175a6d52277d321a93310dbe78d81a4ff68d2a10 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Fri, 19 Apr 2019 15:14:25 -0400 Subject: Fix DR subscriber failure Issue-ID: DCAEGEN2-1009 Change-Id: Ieb770b6562123dda78fd4b8c8c514d30767ad7fb Signed-off-by: Jack Lucas --- k8s/tests/test_k8sclient.py | 8 ++++---- k8s/tests/test_tasks.py | 29 +++-------------------------- 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'k8s/tests') diff --git a/k8s/tests/test_k8sclient.py b/k8s/tests/test_k8sclient.py index 43939ad..70ebf05 100644 --- a/k8s/tests/test_k8sclient.py +++ b/k8s/tests/test_k8sclient.py @@ -86,7 +86,7 @@ def test_parse_interval(): _parse_interval(interval) def test_parse_ports(): - from k8sclient.k8sclient import _parse_ports + from k8sclient.k8sclient import parse_ports good_ports = [{"in": input, "ex": expected} for (input, expected) in [ @@ -133,16 +133,16 @@ def test_parse_ports(): } for test_case in good_ports: - container_ports, port_map = _parse_ports([test_case["in"]]) + container_ports, port_map = parse_ports([test_case["in"]]) (cport, hport, proto) = test_case["ex"] assert container_ports == [(cport, proto)] assert port_map == {(cport, proto) : hport} for port in bad_ports: with pytest.raises(ValueError): - _parse_ports([port]) + parse_ports([port]) - container_ports, port_map = _parse_ports(port_list) + container_ports, port_map = parse_ports(port_list) assert port_map == expected_port_map def test_create_container(): diff --git a/k8s/tests/test_tasks.py b/k8s/tests/test_tasks.py index d56a443..933753a 100644 --- a/k8s/tests/test_tasks.py +++ b/k8s/tests/test_tasks.py @@ -174,21 +174,6 @@ def test_setup_for_discovery_streams(monkeypatch, mockconfig): with pytest.raises(NonRecoverableError): tasks._setup_for_discovery_streams(**test_input) - -def test_lookup_service(monkeypatch, mockconfig): - import k8splugin - from k8splugin import tasks - def fake_lookup(conn, scn): - return [{"ServiceAddress": "192.168.1.1", "ServicePort": "80"}] - - monkeypatch.setattr(k8splugin.discovery, "lookup_service", - fake_lookup) - - assert "192.168.1.1" == tasks._lookup_service("some-component") - assert "192.168.1.1:80" == tasks._lookup_service("some-component", - with_port=True) - - def test_verify_container(monkeypatch, mockconfig): import k8sclient from k8splugin import tasks @@ -222,20 +207,12 @@ def test_update_delivery_url(monkeypatch, mockconfig): {'type': 'data_router', 'name': 'feed01', 'username': 'hero', 'password': '123456', 'location': 'Bedminster', 'route': 'some-path'}], - 'topic01': {'type': 'message_router', 'name': 'topic01'}} + 'topic01': {'type': 'message_router', 'name': 'topic01'}, + 'ports': ['8080/tcp:0']} test_input["service_component_name"] = "some-foo-service-component" - def fake_lookup_service(name, with_port=False): - if with_port: - return "10.100.1.100:8080" - else: - return - - monkeypatch.setattr(k8splugin.tasks, "_lookup_service", - fake_lookup_service) - expected = copy.deepcopy(test_input) - expected["feed01"]["delivery_url"] = "http://10.100.1.100:8080/some-path" + expected["feed01"]["delivery_url"] = "http://some-foo-service-component:8080/some-path" assert tasks._update_delivery_url(**test_input) == expected -- cgit 1.2.3-korg