Пример #1
0
    def test_create_container_with_user(self, create_call_mock, get_call_mock):
        """Test _create_container with user in docker image
        """
        # pylint: disable=protected-access

        client = docker.from_env()

        sproc_docker._create_container(client, 'foo', mock.Mock(), None,
                                       ['cmd'], [
                                           {
                                               'Hard': 10000,
                                               'Soft': 10000,
                                               'Name': 'nproc'
                                           },
                                           {
                                               'Hard': 10000,
                                               'Soft': 10000,
                                               'Name': 'nofile'
                                           },
                                           {
                                               'Hard': -1,
                                               'Soft': -1,
                                               'Name': 'core'
                                           },
                                       ])

        get_call_mock.assert_called_with('foo')
        create_call_mock.assert_called_with(
            command=['cmd'],
            detach=True,
            entrypoint=None,
            ipc_mode='host',
            name='foo',
            network_mode='host',
            pid_mode='host',
            stdin_open=True,
            tty=True,
            image=mock.ANY,
            ulimits=[
                {
                    'Hard': 10000,
                    'Soft': 10000,
                    'Name': 'nproc'
                },
                {
                    'Hard': 10000,
                    'Soft': 10000,
                    'Name': 'nofile'
                },
                {
                    'Hard': -1,
                    'Soft': -1,
                    'Name': 'core'
                },
            ],
        )
Пример #2
0
    def test_create_container_no_user(self, create_call_mock):
        """Test _create_container without user in docker image
        """
        # pylint: disable=protected-access

        client = docker.from_env()

        sproc_docker._create_container(
            client, 'bar', 'foo', mock.Mock(), ['entrypoint'], ['cmd']
        )

        create_call_mock.assert_called_with(
            command=['cmd'], detach=True, entrypoint=['entrypoint'],
            image='foo', ipc_mode='host', name='bar', network_mode='host',
            pid_mode='host', stdin_open=True, tty=True, user='******'
        )
Пример #3
0
    def test_create_container_with_user(self, create_call_mock, get_call_mock):
        """Test _create_container with user in docker image
        """
        # pylint: disable=protected-access

        client = docker.from_env()

        sproc_docker._create_container(client, 'bar', 'foo', ['cmd'])

        get_call_mock.assert_called_with('bar')
        create_call_mock.assert_called_with(command=['cmd'],
                                            detach=True,
                                            image='foo',
                                            ipc_mode='host',
                                            name='bar',
                                            network_mode='host',
                                            pid_mode='host',
                                            stdin_open=True,
                                            tty=True)