docker / docker/docker-py

Some tests are broken on Windows and non-UTC timezones and slow with multiple network interfaces

Open
#3,335 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Hi, I tried to run tests (pytest tests/unit) on Windows, but they produced errors and are slow. After spending quite a while going down the rabbit hole, it seems quite simple to patch.

  1. Replace (deprecated) datetime.datetime.utcfromtimestamp(ts) with datetime.datetime.fromtimestamp(ts, datetime.UTC)

On my non-UTC system, the roundtrip between timestamp and time object confuses the tests, since at some point in there local time is involved. Plus it is deprecated, so at some point this will need to be patched anyway.

  1. Replace USERPROFILE environment variable instead of HOME on Windows

HOME is usually not used by Wwindows applications, including Python. Using the native Windows equivalent USERPROFILE seems to have the same effect / fix it, at least on my machine.

  1. Hardcode localhost loopback

I notice on WSL the tests ran very fast, while on Windows it ran very slow. Turns out it's getting stuck on tests/unit/api_test.py, test 25-33. Sprinkling in some debug logs (print(self.server.server_address)), I notice it is hitting some random virtual network interface on Windows (I have plenty of those due to running VMs...) but using the loopback 127.0.0.1 on WSL. I'm not sure why, and I'm not sure if the tests are relying on a random IP and port, but hardcoding it to the loopback address (+ fixed port, since I couldn't figure out how to make it work by changing only the address) makes the tests pass significantly faster for me (a few seconds vs half a minute).

Happy to submit PRs and/or my patches, if it werent for requiring a legal name...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running pytest tests/unit on Windows and a non-UTC system, then inspect the failures in tests/unit/api_test.py, especially tests 25–33. Check the timestamp conversion, Windows home-directory environment variable, and server address behavior described in the issue. Done means the unit tests pass reliably and no longer incur the reported delay on systems with multiple network interfaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
networking, operating-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.