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

Not working on Windows #45

Open
LostInDarkMath opened this issue Aug 4, 2022 · 6 comments
Open

Not working on Windows #45

LostInDarkMath opened this issue Aug 4, 2022 · 6 comments

Comments

@LostInDarkMath
Copy link

Hi there!

I'm using your library on Linux and it works fine. Now I tried it on WIndows (WIndows 10) and it doesn't work. Is there a way to make your library work with Windows?

Here is the error I'm getting:

Waiting for container to be ready.

test setup failed
mariadb_container = <pytest_docker_tools.wrappers.container.Container object at 0x0000020293B30460>

    @pytest.fixture(scope="session")
    def mariadb(mariadb_container):
>       mariadb_ip, mariadb_port = mariadb_container.get_addr('3306/tcp')

..\..\..\..\fixtures\mariadb.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pytest_docker_tools.wrappers.container.Container object at 0x0000020293B30460>
port = '3306/tcp'

    def get_addr(self, port):
        if tests_inside_container():
            return (self.ips.primary, int(port.split("/")[0]))
        else:
>           return ("127.0.0.1", self.ports[port][0])
E           IndexError: list index out of range

C:\Users\Test\AppData\Local\pypoetry\Cache\virtualenvs\maddox-IYXXq9hF-py3.10\lib\site-packages\pytest_docker_tools\wrappers\container.py:248: IndexError

I don't anything special in my code:

mariadb_container = container(
    name='{mariadb_service_name}',
    image='{mariadb_image.id}',
    ports={'3306/tcp': None},
    network='{test_net.name}',
    tmpfs={'/var/lib/mysql': ''},
    environment={
        'MYSQL_ROOT_PASSWORD': MARIA_DB_ROOT_PASSWORD,
    },
    scope="session",
    command="--innodb-ft-min-token-size=1",
    restart_policy={'Name': 'always'}
)

@pytest.fixture(scope="session")
def mariadb(mariadb_container):
    mariadb_ip, mariadb_port = mariadb_container.get_addr('3306/tcp')
    mariadb = MariaDBData(name=mariadb_container.name, host=mariadb_ip, port=mariadb_port, internal_port='3306',
                          username=MARIA_DB_USER, password=MARIA_DB_ROOT_PASSWORD, schema=DATABASE_NAME)
    return mariadb

How can I fix this?

@LostInDarkMath LostInDarkMath changed the title Not working in Windows Not working on Windows Aug 4, 2022
@Jc2k
Copy link
Owner

Jc2k commented Aug 4, 2022

Hi! Sorry I only use Linux and macOS myself so I know very little about how Docker on Windows and how it differs. I certainly don't do any testing there.

The self.ports you see above is IIRC a wrapper around ["NetworkSettings"]["Ports"] as returned by the docker api. So someone with a Windows box needs to figure out why that field is different and what we can do instead.

@LostInDarkMath
Copy link
Author

Thanks for your fast reply! I'll try to investigate.

@LostInDarkMath
Copy link
Author

LostInDarkMath commented Aug 4, 2022

It's very strange: Sometimes it works fine but most of the time it fails with the error above. It seems to be flaky.

But there are also lots of other issues with your library on windows:

  1. reusable containers does not work
  2. Your tests aren't executable.

@Jc2k
Copy link
Owner

Jc2k commented Aug 4, 2022

I'm not surprised - I mean there are generally lots of failures when you port software to a completely new OS 😆 I would take patches for Windows support if (a) someone was willing to help maintain it and (b) we could get CI running for it.

I did look into (b), but whilst it's quite easy to do Python CI on Windows with GitHub actions, I don't think you could really test Docker for Windows on a Windows GitHub actions.

Unfortunately all my "volunteer" hours are set aside for Home Assistant, so i'm unlikely to be able to help much beyond patch review.

@alpex8
Copy link
Contributor

alpex8 commented Aug 5, 2022

Other alternatives would be executing tests in a container or using WSL to execute tests. The latter is supported in PyCharm Pro and I´ve found a WSL supporting extension for VSCode.

Maybe this are valid workarounds. This could even be mentioned in the READ.ME in case other users are affected as well.

@LostInDarkMath
Copy link
Author

LostInDarkMath commented Aug 5, 2022

Yes, I completely agee with you. The WSL seems to be a very good solution, I'll try it later in detail. I think it isn't worth the effort to make this package 100 % percent Windows compatible. But it would be very nice if you could add a section in the README.md that explains that this package is not designed to work on Windows and Windows users should use the WSL.

Using WSL with PyCharm Pro: https://www.jetbrains.com/help/pycharm/using-wsl-as-a-remote-interpreter.html

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

No branches or pull requests

3 participants