dapr / dapr/java-sdk

Remove Maven dependency to run apps in ITs and stop process leaks.

Đang mở
#201 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/test/integration-tests kind/enhancement P2 size/M triaged/resolved
Ngôn ngữ chính
Java
Star
300
Fork
230
Merge trung bình
5 ngày 1 giờ
Pull request đã merge (30 ngày)
5

Mô tả

Integration tests invoke `dapr run` with a `mvn` command. Instead, change how services are invoked for ITs.

### 1. Use `daprd` instead of `dapr`
Follow instructions in [debugging with daprd in IntelliJ](https://github.com/dapr/docs/tree/master/howto/intellij-debugging-daprd) to understand how `daprd` can be invoked directly. Change [DaprRun.java](https://github.com/dapr/java-sdk/blob/master/sdk-tests/src/test/java/io/dapr/it/DaprRun.java) to invoke daprd in a separate process.

### 2. Run test app as a new thread in same JVM as tests
Now, instead of running the service application as a process by invoking `mvn`, run the main function directly as a new thread inside the same JVM as tests. This will avoid having to build a separate fatjar only for test apps. There are environment variables expected by the test app, and those cannot be changed at runtime. On the other hand, all environment variables defined in [Properties.java](https://github.com/dapr/java-sdk/blob/master/sdk/src/main/java/io/dapr/utils/Properties.java) can be overridden via System properties. Since System Properties are global, see this [work around](https://stackoverflow.com/questions/9579958/system-setproperty-used-by-a-thread-impacts-other-thread-in-communication-to-ext) on how to have System Properties in ThreadLocal (not ideal for production but OK for tests IMO).

### 3. Make test app optional in `DaprRun.java`
Some tests do not need a test app, they just need `daprd`. So, offer a new constructor in `DaprRun.java` that does not have a test app class. Remove [EmptyService.java](https://github.com/dapr/java-sdk/blob/master/sdk-tests/src/test/java/io/dapr/it/services/EmptyService.java) and use the new constructor for all previous uses of that class.

### 4. Stopping `daprd`
Make sure that `DaprRun.java` stops `daprd` in `stop()` method - try gracefully for 1 minute and then forcefully. Because we are not using `dapr` anymore, `dapr stop` will not work anymore. Stop the process from JVM directly.

### 5. Verify process leaks.
* Run ITs once and use Sysinternals' `pskill.exe` as `pskill daprd.exe` and validate no process was killed. For unix systems, use `ps auxwww | grep daprd` and validate there is no `daprd` process in the output, only the `grep` process. Feel free to use another solution to validate this if preferred.
* Artificially make one of the ITs fail an assertion and run ITs. Replay validation for no `daprd` process leaked.
* Artificially throw an exception in the `@Before` method of an IT and run ITs. Replay validation for no `daprd` process leaked.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với sdk-tests/src/test/java/io/dapr/it/DaprRun.java và xem xét sdk/src/main/java/io/dapr/utils/Properties.java để biết các dịch vụ IT được khởi chạy và cấu hình như thế nào. Kiểm tra tất cả các chỗ sử dụng sdk-tests/src/test/java/io/dapr/it/services/EmptyService.java, sau đó chạy các bài kiểm thử tích hợp và xác minh rằng daprd được dừng sau khi hoàn tất bình thường, khi có lỗi assertion và khi có ngoại lệ @Before, mà không để lại các tiến trình bị rò rỉ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
testing
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
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
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.