Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command "pytest" run tests fail---"connect to 127.0.0.1 port 62651 failed: Connection refused" #10879

Closed
kwind opened this issue Apr 1, 2023 · 1 comment
Assignees
Labels

Comments

@kwind
Copy link

kwind commented Apr 1, 2023

@bagder hi,like "#10863 (comment)"
I have similar problem, when run test in directory “curl/tests/http”,such as,

I did this

curl/tests/http % sudo pytest -k "test_01_basic" -vvv
Password:
================================================ test session starts ================================================
platform darwin -- Python 3.10.10, pytest-7.2.2, pluggy-1.0.0 -- /usr/local/opt/python@3.10/bin/python3.10
cachedir: .pytest_cache
Testing curl 8.1.0-DEV
httpd: 2.4.56, http:60852 https:60853
httpd-proxy: 2.4.56, http:60854 https:60855
rootdir: /Users/zhangfugang/code/curl/curl/tests/http
collected 122 items / 117 deselected / 5 selected

test_01_basic.py::TestBasic::test_01_01_http_get ERROR [ 20%]
test_01_basic.py::TestBasic::test_01_02_https_get ERROR [ 40%]
test_01_basic.py::TestBasic::test_01_03_h2_get ERROR [ 60%]
test_01_basic.py::TestBasic::test_01_04_h2_unsupported ERROR [ 80%]
test_01_basic.py::TestBasic::test_01_05_h3_get SKIPPED (h3 not supported) [100%]

====================================================== ERRORS =======================================================
__________________________________ ERROR at setup of TestBasic.test_01_01_http_get __________________________________

env = <testenv.env.Env object at 0x109945750>

@pytest.fixture(scope='package')
def httpd(env) -> Httpd:
    httpd = Httpd(env=env)
    assert httpd.exists(), f'httpd not found: {env.httpd}'
    httpd.clear_logs()
  assert httpd.start()

E assert False
E + where False = <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>>()
E + where <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>> = <testenv.httpd.Httpd object at 0x109a0a3e0>.start

conftest.py:62: AssertionError
------------------------------------------------ Captured log setup -------------------------------------------------
DEBUG testenv.httpd:httpd.py:182 Server still not responding after 0:00:05
_________________________________ ERROR at setup of TestBasic.test_01_02_https_get __________________________________

env = <testenv.env.Env object at 0x109945750>

@pytest.fixture(scope='package')
def httpd(env) -> Httpd:
    httpd = Httpd(env=env)
    assert httpd.exists(), f'httpd not found: {env.httpd}'
    httpd.clear_logs()
  assert httpd.start()

E assert False
E + where False = <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>>()
E + where <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>> = <testenv.httpd.Httpd object at 0x109a0a3e0>.start

conftest.py:62: AssertionError
___________________________________ ERROR at setup of TestBasic.test_01_03_h2_get ___________________________________

env = <testenv.env.Env object at 0x109945750>

@pytest.fixture(scope='package')
def httpd(env) -> Httpd:
    httpd = Httpd(env=env)
    assert httpd.exists(), f'httpd not found: {env.httpd}'
    httpd.clear_logs()
  assert httpd.start()

E assert False
E + where False = <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>>()
E + where <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>> = <testenv.httpd.Httpd object at 0x109a0a3e0>.start

conftest.py:62: AssertionError
_______________________________ ERROR at setup of TestBasic.test_01_04_h2_unsupported _______________________________

env = <testenv.env.Env object at 0x109945750>

@pytest.fixture(scope='package')
def httpd(env) -> Httpd:
    httpd = Httpd(env=env)
    assert httpd.exists(), f'httpd not found: {env.httpd}'
    httpd.clear_logs()
  assert httpd.start()

E assert False
E + where False = <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>>()
E + where <bound method Httpd.start of <testenv.httpd.Httpd object at 0x109a0a3e0>> = <testenv.httpd.Httpd object at 0x109a0a3e0>.start

conftest.py:62: AssertionError
============================================== short test summary info ==============================================
ERROR test_01_basic.py::TestBasic::test_01_01_http_get - assert False
ERROR test_01_basic.py::TestBasic::test_01_02_https_get - assert False
ERROR test_01_basic.py::TestBasic::test_01_03_h2_get - assert False
ERROR test_01_basic.py::TestBasic::test_01_04_h2_unsupported - assert False
=================================== 1 skipped, 117 deselected, 4 errors in 11.96s ==...

The curl code branch
curl/tests/http % git branch -a

  • master
    remotes/origin/HEAD -> origin/master
    ......

the commit id:
curl/tests/http % git log
commit 0409f63 (HEAD -> master, origin/master, origin/HEAD)
Author: Viktor Szakats commit@vsz.me
Date: Fri Mar 31 18:03:43 2023 +0000

cmake: do not add zlib headers for openssl

......

But runtests.pl is success,as follows
curl/tests % ./runtests.pl 3 -s
********* System characteristics ********

  • curl 8.1.0-DEV (x86_64-apple-darwin22.1.0)
  • libcurl/8.1.0-DEV OpenSSL/3.1.0 zlib/1.2.11 libidn2/2.3.4 nghttp2/1.52.0
  • Features: alt-svc AsynchDNS Debug HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM NTLM_WB SSL threadsafe TLS-SRP TrackMemory UnixSockets
  • Disabled:
  • Host: B-Q1BDMD6R-2034.local
  • System: Darwin B-Q1BDMD6R-2034.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64
  • OS: darwin

*** DISABLES memory tracking when using threaded resolver
*

  • Servers: SSL HTTP-IPv6 HTTP-unix FTP-IPv6
  • Env:
  • Seed: 206474

test 0003...OK (1 out of 1 , remaining: 00:00, took 1.417s, duration: 00:01)
TESTDONE: 1 tests were considered during 1 seconds.
TESTDONE: 1 tests out of 1 reported OK: 100%

the curl.trace:
15:19:37.125160 == Info: !!! WARNING !!!
15:19:37.125763 == Info: This is a debug build of libcurl, do not use in production.
15:19:37.125789 == Info: Added one.http.curl.se:60852:127.0.0.1 to DNS cache
15:19:37.125802 == Info: STATE: INIT => CONNECT handle 0x7f8ab1011c08; line 1950 (connection #-5000)
15:19:37.125853 == Info: Added connection 0. The cache now contains 1 members
15:19:37.125863 == Info: Hostname one.http.curl.se was found in DNS cache
15:19:37.125874 == Info: STATE: CONNECT => CONNECTING handle 0x7f8ab1011c08; line 2003 (connection #0)
15:19:37.125951 == Info: Trying 127.0.0.1:60852...
15:19:37.126069 == Info: connect to 127.0.0.1 port 60852 failed: Connection refused
15:19:37.126083 == Info: Failed to connect to one.http.curl.se port 60852 after 0 ms: Couldn't connect to server
15:19:37.126092 == Info: multi_done: status: 7 prem: 1 done: 0
15:19:37.126101 == Info: multi_done, not re-using connection=0, forbid=0, close=0, premature=1, conn_multiplex=0
15:19:37.126109 == Info: The cache now contains 0 members
15:19:37.126114 == Info: Curl_disconnect(conn #0, dead=1)
15:19:37.126123 == Info: Closing connection 0
15:19:37.126132 == Info: Expire cleared (transfer 0x7f8ab1011c08)

I expected the following
The pytest command is successful.

curl/libcurl version
curl 8.0.1-DEV (x86_64-apple-darwin22.1.0) libcurl/8.0.1-DEV OpenSSL/3.1.0 zlib/1.2.11 libidn2/2.3.4 nghttp2/1.52.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM NTLM_WB SSL threadsafe TLS-SRP UnixSockets

operating system
Darwin B-Q1BDMD6R-2034.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64

@icing
Copy link
Contributor

icing commented Apr 3, 2023

Thanks for the report. The check on a suitable httpd for the pytests was not very helpful so far. I added #10883 to improve this and the error messages it gives.

Generally, I would not advise to run sudo pytest. It is not necessary.

Note that the pytest suite looks for three commands httpd, apachectl and apxs. You seem to be on macOS, which provides the first two, but not apxs. On Linux distributions, apxs is installed via the apache2-dev package. On macOS, I am not sure if homebrew or other package managers do that.

It would be nice to hear if #10883 improves the situation for you.

@bagder bagder closed this as completed in e0c3424 Apr 4, 2023
bch pushed a commit to bch/curl that referenced this issue Jul 19, 2023
- better error messages when not found/complete
- handling of `--without-test-httpd`

Reported-by: kwind on github
Fixes curl#10879
Closes curl#10883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants