GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-131178: add E2E mockless tests for `http.server` command-line interface by picnixz · Pull Request #134279 · python/cpython

Conversation

@picnixz

@picnixz picnixz commented May 19, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is a fresh PR because I don't know why GHA is stuck. Locally it works, and I don't know why it now fails remotely.

  • Issue: Add tests for command-line interface #131178

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ggqlq reacted with heart emoji
All reactions
  • ❤️ 1 reaction
picnixz added 5 commits May 19, 2025 19:48
@picnixz
fix test_httpservers
038047a
@picnixz
add timeouts
444549b
@picnixz
only lookup a suitable address
b189d06
@picnixz
early abort
5c136f3
@picnixz
docstring
bcef30f
@picnixz picnixz added the skip news label May 19, 2025
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label May 19, 2025
@bedevere-app bedevere-app Bot mentioned this pull request May 19, 2025
Add tests for command-line interface #131178
Open
7 of 9 tasks
@bedevere-app bedevere-app Bot added the awaiting core review label May 19, 2025
@picnixz picnixz mentioned this pull request May 19, 2025
gh-131178: fix SSL tests for http.server command-line interface #134224
Closed
@picnixz
make the runtime test linux-specific
529b409
@picnixz

picnixz commented May 19, 2025

Copy link
Copy Markdown
Member Author

Ok, so the tests hang on macOS & Windows for some reason I'm not aware of. The tests are really more E2E tests but they can help catching possible issues so I'm keeping them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 19, 2025

Copy link
Copy Markdown
Member Author

!buildbot ASAN

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Ok, since the build bots are struggling, I'll first remove the bits where we test the HTTP server. I'll try to see how we can reliably test this component later (I'm essentially applying PEP-11 recommendations when a Tier-1 bot is failing).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz added 3 commits May 20, 2025 00:02
@picnixz
Merge remote-tracking branch 'upstream/main' into patch/httpserver-te…
ef659a2
…st-131178
@picnixz
Merge remote-tracking branch 'upstream/main' into patch/httpserver-te…
71bb403
…st-131178

# Conflicts:
#	Lib/test/test_httpservers.py
@picnixz
take 2
19e4972
@picnixz
picnixz marked this pull request as draft May 19, 2025 22:30
@bedevere-app bedevere-app Bot removed the awaiting core review label May 19, 2025
@picnixz
more debug info
6a1e821
@picnixz

picnixz commented May 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Ha!

0:11:22 load avg: 11.90 [1/2/1] test_httpservers failed (2 failures)
Re-running test_httpservers in verbose mode (matching: test_http_client, test_https_client)
test_http_client (test.test_httpservers.CommandLineRunTimeTestCase.test_http_client) ... 
python -m http.server:  Serving HTTP on :: port 54285 (http://[::]:54285/) ...
failed to start HTTP(s) server. Output was: 'Serving HTTP on :: port 54285 (http://[::]:54285/) ...\n'
FAIL
test_https_client (test.test_httpservers.CommandLineRunTimeTestCase.test_https_client) ... 
python -m http.server:  Traceback (most recent call last):
failed to start HTTP(s) server. Output was: 'Traceback (most recent call last):\n'

So there is something happening! I'll continue investigating this. At least, I think I know why it failed on the build bots. Presumably, the address being served was incorrectly parsed for some reason (namely it wasn't 127.0.0.1 or there was some exception being raised that I wasn't aware of)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz added 4 commits May 20, 2025 00:59
@picnixz
use 'localhost'
368d709
@picnixz
automatic deduction
a46c9c2
@picnixz
use 127.0.0.1 for HTTPS test
4ad442a
@picnixz
reuse 127.0.0.1 everywhere???
f735ee5
@picnixz

picnixz commented May 20, 2025

Copy link
Copy Markdown
Member Author

!buildbot ASAN

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 20, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @picnixz for commit f735ee5 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134279%2Fmerge

The command will test the builders whose names match following regular expression: ASAN

The builders matched are:

  • AMD64 Arch Linux Asan PR
  • x86-64 MacOS Intel ASAN NoGIL PR
  • AMD64 Arch Linux Asan Debug PR
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
picnixz marked this pull request as ready for review May 20, 2025 01:05
@bedevere-app bedevere-app Bot added the awaiting core review label May 20, 2025
@picnixz
Merge branch 'main' into patch/httpserver-test-131178
7686f3a
@ggqlq

ggqlq commented May 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I tried to reproduce these problems locally based on the commit that cause the buildbot failed(commit hash 605022a) and It appears that both of the AttributeError: 'NoneType' object has no attribute 'create_default_context' and AssertionError: False is not true issues mentioned in PR #134224 stem from running ssl in an environment that is missing the ssl module build. The server process in test_https_client will exit prematurely due to the missing ssl module and print the error traceback. The proc.stdout.readline() loop in the wait_for_server function will never find the server startup message because the output contains only the error traceback and the function returns False after timeout. The assertion self.assertTrue(wait_for_server(...)) fails with AssertionError: False is not true, while the subsequent fetch_file call will never reach SSL context operation that throw AttributeError, it explains why test_http_client and test_https_client failed with different reasons. I think both of the runtime tests failed are related to my mistake that I didn't check the ssl module build in PR #132540 and not due to specific environment, I think this PR have already fixed them by adding the skipIf(ssl is None) decorator.

Here's my reproduction of these bugs

  • CPU: AMD64
  • OS: Debian 12
$ git reset --hard 605022aeb69ae19cae1c020a6993ab5c433ce907

$ ./configure --with-openssl=donotexist
# ...

$ make -j12
# ...
Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

$ ./python -m test test_httpservers -v
# ...
======================================================================
ERROR: test_http_client (test.test_httpservers.CommandLineRunTimeTestCase.test_http_client)
----------------------------------------------------------------------
# ...
AttributeError: 'NoneType' object has no attribute 'create_default_context'

======================================================================
FAIL: test_https_client (test.test_httpservers.CommandLineRunTimeTestCase.test_https_client)
----------------------------------------------------------------------
# ...
AssertionError: False is not true

----------------------------------------------------------------------
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 23, 2025

Copy link
Copy Markdown
Member Author

The proc.stdout.readline() loop in the wait_for_server function will never find the server startup message because the output contains only the error traceback and the function returns False after timeout

Ah thank you! this is something I couldn't understand as I couldn't show the traceback in full. Thank you very much for that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 23, 2025

Copy link
Copy Markdown
Member Author

Actually, there is something else. The errors were:

FAIL: test_https_client (test.test_httpservers.CommandLineRunTimeTestCase.test_https_client)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ec2-user/buildbot/buildarea/3.x.itamaro-macos-intel-aws.macos-with-brew.asan.nogil/build/Lib/test/test_httpservers.py", line 1533, in test_https_client
    self.assertTrue(self.wait_for_server(proc, 'https', port, bind))
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: False is not true

However, I've already disabled the test if ssl is None, so False is being returned for another reason, not because of missing ssl.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 23, 2025

Copy link
Copy Markdown
Member Author

!buildbot x86-64 MacOS Intel

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 23, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @picnixz for commit 7686f3a 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134279%2Fmerge

The command will test the builders whose names match following regular expression: x86-64 MacOS Intel

The builders matched are:

  • x86-64 MacOS Intel NoGIL PR
  • x86-64 MacOS Intel ASAN NoGIL PR
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented May 24, 2025

Copy link
Copy Markdown
Member Author

Ok, I think I know what happened. When requesting 127.0.0.1, the response may be "Serving 127.0.0.1 on port (http://:)" where HOST is different from 127.0.0.1. So instead, we can just assume that having this message means that I can use 127.0.0.1 as a host component (sometimes I would see http://[::]:PORT but I wouldn't be able to use urllib.request on [::], which is why I would need 127.0.0.1 instead).

Therefore, I think I can merge this one without worries. If build bot fails (I can't seem to run them), I'll revert the PR (again). But the failing build bots now succeed, so it should be fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
Merge branch 'main' into patch/httpserver-test-131178
b35ef01
@picnixz
picnixz merged commit 5d9c8fe into python:main May 24, 2025
@bedevere-app bedevere-app Bot removed the awaiting core review label May 24, 2025
@picnixz
picnixz deleted the patch/httpserver-test-131178 branch May 24, 2025 11:48
@picnixz picnixz changed the title gh-131178: fix SSL tests for http.server command-line interface gh-131178: add E2E mockless tests for http.server command-line interface May 24, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@picnixz @Pranjal095
pythongh-131178: add E2E mockless tests for http.server command-lin…
ff7da11
…e interface (python#134279)
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@picnixz @taegyunkim
pythongh-131178: add E2E mockless tests for http.server command-lin…
0402b6e
…e interface (python#134279)
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
@picnixz @gostak-dd
pythongh-131178: add E2E mockless tests for http.server command-lin…
423fdca
…e interface (python#134279)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@picnixz @bedevere-bot @ggqlq
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.