Example #1
0
    def test_get_task_ip_and_ports_ip_per_task_no_ip_marathon13(self):
        app = {
            'ipAddress': {},
            'container': {
                'type': 'DOCKER',
                'docker': {
                    'network': 'USER',
                    'portMappings': [
                        {
                            'containerPort': 80,
                            'servicePort': 10000,
                        },
                        {
                            'containerPort': 81,
                            'servicePort': 10001,
                        },
                     ],
                },
            },
        }
        task = {
            "id": "testtaskid",
        }

        result = utils.get_task_ip_and_ports(app, task)
        expected = (None, None)

        self.assertEquals(result, expected)
Example #2
0
def get_svnames_from_task(app, task):
    prefix = task['host'].replace('.', '_')
    task_ip, task_port = get_task_ip_and_ports(app, task)
    if task['host'] == task_ip:
        for port in task['ports']:
            yield('{}_{}'.format(prefix, port))
    else:
        for port in task['ports']:
            yield('{}_{}_{}'.format(prefix, task_ip.replace('.', '_'), port))
Example #3
0
    def test_get_task_ip_and_ports_ip_per_task_marathon15(self):
        app = {
            'container': {
                'type': 'DOCKER',
                'docker': {
                    'image': 'nginx'
                },
                'portMappings': [
                    {
                        'containerPort': 80,
                        'servicePort': 10000,
                    },
                    {
                        'containerPort': 81,
                        'servicePort': 10001,
                    },
                ]
            },
            'networks': [
                {
                    'mode': 'container',
                    'name': 'dcos'
                }
            ]
        }
        task = {
            "id": "testtaskid",
            "ipAddresses": [{"ipAddress": "1.2.3.4"}]
        }

        result = utils.get_task_ip_and_ports(app, task)
        expected = ("1.2.3.4", [80, 81])
        self.assertEquals(result, expected)

        task_no_ip = {
            "id": "testtaskid",
        }

        result = utils.get_task_ip_and_ports(app, task_no_ip)
        expected = (None, None)
        self.assertEquals(result, expected)
Example #4
0
    def test_get_task_ip_and_ports_port_map_no_ip(self):
        app = {}
        task = {
            "id": "testtaskid",
            "ports": [234, 345, 567],
            "host": "agent1"
        }

        with patch("utils.resolve_ip", return_value=None):
            result = utils.get_task_ip_and_ports(app, task)
            expected = (None, None)

            self.assertEquals(result, expected)
Example #5
0
    def test_get_task_ip_and_ports_ip_per_task_no_ip(self):
        app = {
            "ipAddress": {
                "discovery": {
                    "ports": [{"number": 123}, {"number": 234}]
                }
            },
        }
        task = {
            "id": "testtaskid"
        }

        result = utils.get_task_ip_and_ports(app, task)
        expected = (None, None)

        self.assertEquals(result, expected)
Example #6
0
    def test_get_task_ip_and_ports_ip_per_task(self):
        app = {
            "ipAddress": {
                "discovery": {
                    "ports": [{"number": 123}, {"number": 234}]
                }
            },
        }
        task = {
            "id": "testtaskid",
            "ipAddresses": [{"ipAddress": "1.2.3.4"}]
        }

        result = utils.get_task_ip_and_ports(app, task)
        expected = ("1.2.3.4", [123, 234])

        self.assertEquals(result, expected)
Example #7
0
    def test_get_task_ip_and_ports_portmapping_null(self):
        app = {
            'ipAddress': {},
            'container': {
                'type': 'DOCKER',
                'docker': {
                    'network': 'USER',
                    'portMappings': [{
                    }]
                },
            },
        }
        task = {
            "id": "testtaskid",
        }

        result = utils.get_task_ip_and_ports(app, task)
        expected = (None, None)

        self.assertEquals(result, expected)