首页 > 解决方案 > 为什么弹性搜索 Junit 测试在 /tmp 文件夹中创建 jna 文件夹?

问题描述

我目前正在运行来自 maven spring boot 项目的弹性搜索 junit 集成测试。我可以看到它正在 /tmp/elasticsearch/jna 下创建一个文件夹。我怎样才能避免这种情况,以便在我的 Maven 项目目标/文件夹中创建它。

以下是我如何从我的 junit 测试创建弹性搜索实例的示例。

@RunWith(SpringRunner.class)
@SpringBootTest(classes = PrimecastApp.class)
public class MessageHistoryReportingResourceIntTest 
{

    private static final String EMBEDDED_ELASTIC_SEARCH_DOWNLOAD_DIRECTORY = "./target/embeddedElasticSearch";

    private static final String EMBEDDED_ELASTIC_SEARCH_INSTALLATION_DIRECTORY = "./target/embeddedElasticSearch";

@BeforeClass
    public static void startElasticServer() throws Exception {

        port = RandomUtil.getRandomNumberInRange(50000, 60000);
        embeddedElastic = EmbeddedElastic.builder().withElasticVersion("6.6.1")
                .withSetting(PopularProperties.HTTP_PORT, port)
                .withSetting(PopularProperties.CLUSTER_NAME, "my_cluster").withStartTimeout(5, TimeUnit.MINUTES)
                .withDownloadDirectory(new File(EMBEDDED_ELASTIC_SEARCH_DOWNLOAD_DIRECTORY))
                .withInstallationDirectory(new File(EMBEDDED_ELASTIC_SEARCH_INSTALLATION_DIRECTORY))
                .withCleanInstallationDirectoryOnStop(true)
                .build().start();

      }
   }
}

我正在使用 allegro/embedded-elasticsearch 库

如果你能帮忙谢谢谢谢

标签: elasticsearch

解决方案


推荐阅读