Skip to content

Conversation

@moe-ad
Copy link
Contributor

@moe-ad moe-ad commented Oct 13, 2025

Closes #2676.

@moe-ad moe-ad self-assigned this Oct 13, 2025
@codecov
Copy link

codecov bot commented Oct 13, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2063 2 2061 90
View the top 2 failed test(s) by shortest run time
test_server.test_server::test_docker_busy_port[ansys-grpc-dpf]
Stack Traces | 30.4s run time
remote_config_server_type = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000028A36105030>
clean_up = None

    @pytest.mark.skipif(not running_docker, reason="Only works on Docker")
    def test_docker_busy_port(remote_config_server_type, clean_up):
        my_serv = start_local_server(config=remote_config_server_type)
        busy_port = my_serv.external_port
        with pytest.raises(errors.InvalidPortError):
            running_docker_config = dpf.core.server_factory.RunningDockerConfig(
                docker_config=dpf.core.server.RUNNING_DOCKER
            )
>           server_types.launch_dpf_on_docker(
                port=busy_port, running_docker_config=running_docker_config
            )

test_server\test_server.py:204: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\ansys\dpf\core\server_types.py:312: in launch_dpf_on_docker
    _wait_and_check_server_connection(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

process = <Popen: returncode: 125 args: 'docker run -d   -e ANSYS_DPF_ACCEPT_LA=Y  -e ...>
port = 60059, timeout = 120.0, lines = []
current_errors = ['docker: Error response from daemon: failed to create endpoint magical_taussig on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The specified port already exists. (0x803b0013).\n']
stderr = <function launch_dpf_on_docker.<locals>.read_stderr at 0x0000028A37F98670>
stdout = <function launch_dpf_on_docker.<locals>.read_stdout at 0x0000028A37F98160>

    def _wait_and_check_server_connection(
        process, port, timeout, lines, current_errors, stderr=None, stdout=None
    ):
        if not stderr:
    
            def read_stderr():
                with io.TextIOWrapper(process.stderr, encoding="utf-8") as log_err:
                    for line in log_err:
                        LOG.debug(line)
                        current_errors.append(line)
    
            stderr = read_stderr
            # check to see if the service started
        if not stdout:
    
            def read_stdout():
                with io.TextIOWrapper(process.stdout, encoding="utf-8") as log_out:
                    for line in log_out:
                        LOG.debug(line)
                        lines.append(line)
    
            stdout = read_stdout
        # must be in the background since the process reader is blocking
        Thread(target=stdout, daemon=True).start()
        Thread(target=stderr, daemon=True).start()
    
        t_timeout = time.time() + timeout
        started = False
        timedout = False
        while not started and len(current_errors) == 0:
            # print(lines)
            started = any("server started" in line for line in lines)
    
            if time.time() > t_timeout:
                if timedout:
                    raise TimeoutError(f"Server did not start in {timeout + timeout} seconds")
                timedout = True
                t_timeout += timeout
    
        # verify there were no errors
        time.sleep(0.01)
        if current_errors:
            try:
                process.kill()
            except PermissionError:
                pass
            errstr = "\n".join(current_errors)
            if (
                "Only one usage of each socket address" in errstr
                or "port is already allocated" in errstr
            ):
                raise errors.InvalidPortError(f"Port {port} in use")
>           raise RuntimeError(errstr)
E           RuntimeError: docker: Error response from daemon: failed to create endpoint magical_taussig on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The specified port already exists. (0x803b0013).

C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\ansys\dpf\core\server_types.py:221: RuntimeError
test_server.test_server::test_docker_busy_port[gRPC CLayer]
Stack Traces | 34.4s run time
remote_config_server_type = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000028A36105330>
clean_up = None

    @pytest.mark.skipif(not running_docker, reason="Only works on Docker")
    def test_docker_busy_port(remote_config_server_type, clean_up):
        my_serv = start_local_server(config=remote_config_server_type)
        busy_port = my_serv.external_port
        with pytest.raises(errors.InvalidPortError):
            running_docker_config = dpf.core.server_factory.RunningDockerConfig(
                docker_config=dpf.core.server.RUNNING_DOCKER
            )
>           server_types.launch_dpf_on_docker(
                port=busy_port, running_docker_config=running_docker_config
            )

test_server\test_server.py:204: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\ansys\dpf\core\server_types.py:312: in launch_dpf_on_docker
    _wait_and_check_server_connection(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

process = <Popen: returncode: 125 args: 'docker run -d   -e ANSYS_DPF_ACCEPT_LA=Y  -e ...>
port = 60059, timeout = 120.0, lines = []
current_errors = ['docker: Error response from daemon: failed to create endpoint silly_euler on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The specified port already exists. (0x803b0013).\n']
stderr = <function launch_dpf_on_docker.<locals>.read_stderr at 0x0000028A3809DEA0>
stdout = <function launch_dpf_on_docker.<locals>.read_stdout at 0x0000028A3809E560>

    def _wait_and_check_server_connection(
        process, port, timeout, lines, current_errors, stderr=None, stdout=None
    ):
        if not stderr:
    
            def read_stderr():
                with io.TextIOWrapper(process.stderr, encoding="utf-8") as log_err:
                    for line in log_err:
                        LOG.debug(line)
                        current_errors.append(line)
    
            stderr = read_stderr
            # check to see if the service started
        if not stdout:
    
            def read_stdout():
                with io.TextIOWrapper(process.stdout, encoding="utf-8") as log_out:
                    for line in log_out:
                        LOG.debug(line)
                        lines.append(line)
    
            stdout = read_stdout
        # must be in the background since the process reader is blocking
        Thread(target=stdout, daemon=True).start()
        Thread(target=stderr, daemon=True).start()
    
        t_timeout = time.time() + timeout
        started = False
        timedout = False
        while not started and len(current_errors) == 0:
            # print(lines)
            started = any("server started" in line for line in lines)
    
            if time.time() > t_timeout:
                if timedout:
                    raise TimeoutError(f"Server did not start in {timeout + timeout} seconds")
                timedout = True
                t_timeout += timeout
    
        # verify there were no errors
        time.sleep(0.01)
        if current_errors:
            try:
                process.kill()
            except PermissionError:
                pass
            errstr = "\n".join(current_errors)
            if (
                "Only one usage of each socket address" in errstr
                or "port is already allocated" in errstr
            ):
                raise errors.InvalidPortError(f"Port {port} in use")
>           raise RuntimeError(errstr)
E           RuntimeError: docker: Error response from daemon: failed to create endpoint silly_euler on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The specified port already exists. (0x803b0013).

C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\ansys\dpf\core\server_types.py:221: RuntimeError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support windows-based containers

2 participants