testcontainers / testcontainers/testcontainers-python
Bug: MSSQL (SqlServerContainer) ignores some parameters
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 386
- Merge trung bình
- 4 giờ 40 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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!
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ phần triển khai SqlServerContainer và tái hiện ví dụ với image MSSQL được chỉ định cùng các tham số username và db_name. Theo dõi cách các tham số này được truyền đến container và URL kết nối, sau đó xác minh rằng cơ sở dữ liệu đang chạy áp dụng chúng và ví dụ không còn thất bại do xác thực.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, python, sqlalchemy
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100