testcontainers / testcontainers/testcontainers-python

Bug: MSSQL (SqlServerContainer) ignores some parameters

未关闭
#736 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
2.3k
派生
386
平均合并
4 小时 40 分钟
30 天内合并 PR
1

描述

Describe the bug

When running the SqlServerContainer, in this example with the image mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04, some parameters have no effect on the actual database and lead to failures. It seems like they are just not respected.

To Reproduce

import sqlalchemy
from testcontainers.mssql import SqlServerContainer

def test_showcase_bug():
    with SqlServerContainer(image="mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04", username="dummy") as mssql:
        engine = sqlalchemy.create_engine(mssql.get_connection_url()) # this includes the username "dummy" now.
        print(mssql.get_connection_url())
        with engine.begin() as connection:
            result = connection.execute(sqlalchemy.text("select @@VERSION"))

It loads a while. When looking at the database logs, it prints:

2024-11-14 10:39:43.81 Logon       Error: 18456, Severity: 14, State: 5.
2024-11-14 10:39:43.81 Logon       Login failed for user 'dummy'. Reason: Could not find a login matching the name provided. [CLIENT: 172.17.0.3]

Same thing for other parameters, for example db_name.

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

Windows 11
Python 3.11.9
testcontainers 4.8.2
sqlalchemy 2.0.36
pymssql 2.3.1

Thanks for your work!

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 SqlServerContainer 的实现开始,使用指定的 MSSQL 镜像以及 username 和 db_name 参数复现该示例。跟踪这些参数如何传递给容器和连接 URL,然后验证正在运行的数据库应用了这些参数,并且该示例不再因身份验证而失败。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, python, sqlalchemy
领域
database
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。