gpt4 book ai didi

How to access filesystem of app container while running container tests in Quarkus?(如何在Quarkus中运行容器测试时访问应用程序容器的文件系统?)

转载 作者:bug小助手 更新时间:2023-10-28 10:11:32 24 4
gpt4 key购买 nike



When running native tests in Quarkus, the application runs in a container. I have functionality that involves reading and writing to the filesystem. Therefore, I must prepare test data before each test run by writing the desired files to the filesystem.

在Quarkus中运行本机测试时,应用程序在容器中运行。我的功能涉及对文件系统的读写。因此,我必须在每次测试运行之前通过将所需文件写入文件系统来准备测试数据。


For regular QuarkusTest, this works fine, as everything runs locally. When running a native QuarkusIntegrationTest, this obviously will not work. The container running my native image has its own filesystem, and the data that I do prepare in my test runner will end up on the container host machine.

对于常规QuarkusTest,这很好,因为一切都在本地运行。当运行原生QuarkusIntegrationTest时,这显然不起作用。运行我的本机映像的容器有自己的文件系统,我在测试运行器中准备的数据将最终在容器主机上。


It would be really neat if one could map a volume for integration testing, but as far as I know, this is not possible. Another option is to create a REST API for testing purposes to write and read files. But this would need to be specifically secured.

如果一个人可以映射一个卷来进行集成测试,那就太好了,但据我所知,这是不可能的。另一种选择是创建一个REST API用于测试,以写入和读取文件。但这需要得到特别的保障。


What would be a feasible way to prepare test data on the filesystem of the app container?

在应用程序容器的文件系统上准备测试数据的可行方法是什么?


更多回答
优秀答案推荐

You can mount your resources for them to be available to your native executable.

您可以挂载您的资源,以便它们可供您的本机可执行文件使用。


The attribute you're looking for is

您要查找的属性是


quarkus.native.resources.includes

I would enable the include for the test profile.

我会为测试配置文件启用Include。


#Replace with what works for your use case:
%test.quarkus.native.resources.includes=/data/cfg/**/*.txt,/config/**

Refer to https://quarkus.io/guides/all-config#quarkus-core_quarkus.native.resources.includes for more details.

有关更多详细信息,请参阅https://quarkus.io/guides/all-config#quarkus-core_quarkus.native.resources.includes。



The possibilty to mount a volume for a container test will be available with Quarkus 3.5
https://github.com/quarkusio/quarkus/issues/35864

Quarkus3.5 https://github.com/quarkusio/quarkus/issues/35864将提供装载用于容器测试的卷的可能性


更多回答

Yes, but this are static recoures. I need to be able to clean and regenerate new testdata for each test

是的,但这是静态资源。我需要能够为每个测试清理和重新生成新的测试数据

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com