如何在单元测试后清除嵌入的cassandra? [英] How to cleanup embedded cassandra after unittest?

查看:281
本文介绍了如何在单元测试后清除嵌入的cassandra?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Hectors EmbeddedServerHelper 来设置嵌入的Cassandra。它有 teardown() cleanup()方法。

I'm using Hectors EmbeddedServerHelper to set up embedded Cassandra. It has teardown() and cleanup() methods.

问题是cleanup方法不能删除由cassandra创建的一些提交日志文件。可能是因为还有一些cassandra守护进程没有被teardown()方法正确关闭。这里我们设置和拆卸代码:

The problem is that cleanup method cannot delete some commit log files created by cassandra. Probably because there are still some cassandra daemons that were not properly shut down by the teardown() method. Here us the setup and teardown code:

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    EmbeddedServerHelper sh = new EmbeddedServerHelper();
    sh.setup();
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
    EmbeddedServerHelper.teardown();
    EmbeddedServerHelper.cleanup();     
    doDelete(new File("tmp"));
}

如何删除这些文件?

推荐答案

在启动时检查和删除数据文件和提交日志,因为很难知道什么时候cassandra进程是从上下文清理JUnit。

The data files and commit logs are checked-for and deleted on startup as it was quite difficult to know when the cassandra process was done with cleaning up from the context of JUnit.

这篇关于如何在单元测试后清除嵌入的cassandra?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆