hector-client / hector

a high level client for cassandra
http://prettyprint.me/2010/02/23/hector-a-java-cassandra-client/
MIT License
643 stars 299 forks source link

Tests fail in IDE (eclipse) #543

Open jhhdk opened 11 years ago

jhhdk commented 11 years ago

While mvn test works perfectly, running all test in src/test/java within eclipse fails, due to incomplete cleanup of schema.

I get following exception trace in LatencyAwareHClientPoolTest: java.lang.RuntimeException: Attempting to load already loaded column family Keyspace1.JdbcLong at org.apache.cassandra.config.Schema.load(Schema.java:382) at org.apache.cassandra.config.Schema.load(Schema.java:106) at org.apache.cassandra.config.Schema.load(Schema.java:91) at me.prettyprint.hector.testutils.EmbeddedSchemaLoader.loadSchema(EmbeddedSchemaLoader.java:36) at me.prettyprint.hector.testutils.EmbeddedServerHelper.loadSchemaFromYaml(EmbeddedServerHelper.java:177) at me.prettyprint.hector.testutils.EmbeddedServerHelper.setup(EmbeddedServerHelper.java:64) at me.prettyprint.cassandra.BaseEmbededServerSetupTest.setup(BaseEmbededServerSetupTest.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

The test works perfectly if run by itself. Unsure whether this is because all tests run in sequence within the same JVM inside eclipse while maven runs testcases within their own JVM instance.

patricioe commented 11 years ago

how do you run all of them together?

jhhdk commented 11 years ago

Within eclipse after fresly imported maven project, rightclick /hector-core/stc/test/java Run As JUnit Test.

patricioe commented 11 years ago

it looks like the @AfterClass is not called and thus the JVM is not being killed properly.

pauloricardomg commented 11 years ago

problem still happening. any fix for this?

patricioe commented 11 years ago

How about mvn test?

Try from latest master. On Jun 1, 2013 4:54 PM, "Paulo Ricardo Motta Gomes" < notifications@github.com> wrote:

problem still happening. any fix for this?

— Reply to this email directly or view it on GitHubhttps://github.com/hector-client/hector/issues/543#issuecomment-18799270 .

pauloricardomg commented 11 years ago

yep. mvn test works fine, thanks. since eclipse runs all tests (including the cassandra daemon) in one JVM, all static classes from cassandra are only loaded once, and thus the metadata is not cleared after the daemon is restarted. I tried clearing these classes manually, so I could run the tests with "run all JUnit tests" on Eclipse, but some of the static properties are "unclearable" (for instance, DatabaseDescriptor.class). well, not a big deal anyway. will just stick to mvn test then. :) cheers!