Can't unit test own usage of InClusterFactory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- go
- Lĩnh vực
- backend-api-design, testing
Hướng nghiên cứu
Start with conditions/factory.go at readNamespace, then trace InClusterFactory.GetNamespacedName through internal/utils/utils.go and review the override used in conditions/conditions_test.go. Determine an externally usable way to supply or override the namespace for unit tests, with tests that exercise wrapper code using a fake runtime client without requiring the current environment namespace.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
What did you do?
Created a wrapper function in our operator code that finds the name of the associated OLM OperatorCondition and then uses the InClusterFactory API to set the upgradeable condition. Then we started writing tests to test this function.
What did you expect to see?
Tests to pass or fail depending on the correct writing of the wrapper function and calling the correct InClusterFactory and Condition code.
What did you see instead? Under which circumstances?
The error: get operator condition namespace: namespace not found for current environment.
Since the unit tests are using a fake runtime client and running locally, this was to be expected since InClusterFactory.GetNamespacedName() calls utils.GetOperatorNamespace(). However, what was unexpected was in our tests there is no way to override this since:
- utils package is internal so private
- readNamespace is private
- the library's own tests can override since they share the same package as
readNamespace.
Environment
- operator-lib version: 0.9.x
- github.com/operator-framework/operator-lib v0.9.0
Possible Solutions
- make
readNamespacepublic - provide an interface to allow
GetNamespacedNameto be overridden - allow the namespace to be injected into InClusterFactory (since the operator provides the namespace through
request.namespace, it might be a nice alternative?)
Additional context
Add any other context about the problem here.
- Ngôn ngữ chính
- Go
- Star
- 40
- Fork
- 42
- Merge trung bình
- 4 ngày 46 phút
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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.
Issue khác của operator-framework/operator-lib
-
Prune package?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
lifecycle/frozen
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
operator-framework/operator-lib#48 · 4 bình luận ·
Tất cả issue của operator-framework/operator-lib
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
prime-radiant-inc/evener#4223 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-telemetry/opentelemetry-go-compile-instrumentation#1467 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
yetone/magpie#1490 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: a request sent before initialize is answered with JSON-RPC error code 0 instead of -32600Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/go-sdk#1367 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày