I am trying to build cassandra binaries from source and when I try to compile unit test cases, one of them fails. I am build cassandra-2.1.4 with Java 8.
These are the commands I run:
ant -Dfile.encoding="UTF-8"
ant test
ant artifacts
Failure details:
[junit] Testsuite: org.apache.cassandra.tools.SSTableExportTest
[junit] Tests run: 8, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.903 sec
[junit]
[junit] ------------- Standard Output ---------------
[junit] WARN 17:48:26 No host ID found, created eeaaa375-22f0-4a4c-845a-31decd240218 (Note: This should happen exactly once per node).
[junit] WARN 17:48:26 No host ID found, created eeaaa375-22f0-4a4c-845a-31decd240218 (Note: This should happen exactly once per node).
[junit] Importing 1 keys...
[junit] 1 keys imported successfully.
[junit] ------------- ---------------- ---------------
[junit] Testcase: testExportColumnsWithMetadata(org.apache.cassandra.tools.SSTableExportTest): FAILED
[junit] unexpected serialization format for topLevelDeletion expected:<{"[markedForDeleteAt":0,"localDeletionTime]":0}> but was:<{"[localDeletionTime":0,"markedForDeleteAt]":0}>
[junit] junit.framework.AssertionFailedError: unexpected serialization format for topLevelDeletion expected:<{"[markedForDeleteAt":0,"localDeletionTime]":0}> but was:<{"[localDeletionTime":0,"markedForDeleteAt]":0}>
[junit] at org.apache.cassandra.tools.SSTableExportTest.testExportColumnsWithMetadata(SSTableExportTest.java:298)
[junit]
[junit]
[junit] Test org.apache.cassandra.tools.SSTableExportTest FAILED
[junit] Testsuite: org.apache.cassandra.tools.SSTableImportTest
[junit] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.759 sec
This is a known issue and has been fixed in Apache Cassandra's trunk (will become 2.2) branch. https://issues.apache.org/jira/browse/CASSANDRA-9065
Related
I am trying to build cassandra binaries from source and when I try to compile unit test cases, some of them give me errors. I tried versions 2.0.14, 2.1.4 and 2.1.5 with ubuntu 14.04 and Java 7 as well as Java 8. This is the message I get after building the test cases:
BUILD FAILED
/opt/cassandra/build.xml:1139: Some test bucket 0 test(s) failed.
Total time: 17 minutes 13 seconds
Buildfile: `/opt/cassandra/build.xml`
Am I doing something wrong? This is how I am trying to build:
ant
ant build
ant build-test
ant test
ant artifacts
[junit] Testsuite: org.apache.cassandra.utils.BitSetTest
[junit] Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.075 sec
[junit]
[junit] Testcase: compareBitSets(org.apache.cassandra.utils.BitSetTest): Caused an ERROR
[junit] java.io.FileNotFoundException: /usr/share/dict/words (No such file or directory)
[junit] java.lang.RuntimeException: java.io.FileNotFoundException: /usr/share/dict/words (No such file or directory)
[junit] at org.apache.cassandra.utils.KeyGenerator$WordGenerator.reset(KeyGenerator.java:137)
[junit] at org.apache.cassandra.utils.KeyGenerator$WordGenerator.<init>(KeyGenerator.java:126)
[junit] at org.apache.cassandra.utils.BitSetTest.compareBitSets(BitSetTest.java:50)
[junit] Caused by: java.io.FileNotFoundException: /usr/share/dict/words (No such file or directory)
[junit] at java.io.FileInputStream.open(Native Method)
[junit] at java.io.FileInputStream.<init>(FileInputStream.java:146)
[junit] at java.io.FileInputStream.<init>(FileInputStream.java:101)
[junit] at org.apache.cassandra.utils.KeyGenerator$WordGenerator.reset(KeyGenerator.java:135)
[junit]
[junit]
[junit] Test org.apache.cassandra.utils.BitSetTest FAILED
There's your error. The test is looking for /usr/share/dict/words.
apt-get install wamerican
I am having trouble with setting up unit tests for a project developed under Netbeans in Hudson. So far, Hudson is running fine, monitoring my git repository, and automatically starting builds.
But when building is finished, Hudson starts the unit tests. And here lies the problem: Some classes use awt, and when started from within Hudson, the tests fail like this:
[junit] Testcase: testParse_SimpleTextAndSymbols(com.dua3.util.text.LatexParserTest): Caused an ERROR
[junit] Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
[junit] java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
[junit] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
[junit] at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:190)
[junit] at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
[junit] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
[junit] at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:119)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:190)
[junit] at java.awt.Toolkit$2.run(Toolkit.java:868)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:860)
[junit] at sun.swing.SwingUtilities2.getSystemMnemonicKeyMask(SwingUtilities2.java:1877)
[junit] at javax.swing.plaf.basic.BasicLookAndFeel.initComponentDefaults(BasicLookAndFeel.java:752)
[junit] at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:434)
[junit] at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:148)
[junit] at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1589)
[junit] at javax.swing.UIManager.setLookAndFeel(UIManager.java:536)
[junit] at javax.swing.UIManager.setLookAndFeel(UIManager.java:576)
[junit] at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1345)
[junit] at javax.swing.UIManager.initialize(UIManager.java:1455)
[junit] at javax.swing.UIManager.maybeInitialize(UIManager.java:1422)
[junit] at javax.swing.UIManager.getLookAndFeelDefaults(UIManager.java:1034)
[junit] at com.dua3.util.graph.javase.swing.SwingFont$SwingFontProvider.getDefaultFont(SwingFont.java:50)
[junit] at com.dua3.util.graph.Font.getDefault(Font.java:52)
[junit] at com.dua3.util.text.LatexParser$Settings.<init>(LatexParser.java:39)
[junit] at com.dua3.util.text.LatexParser.parse(LatexParser.java:61)
[junit] at com.dua3.util.text.LatexParserTest.testParse_SimpleTextAndSymbols(LatexParserTest.java:49)
I thought it should be enough to check GraphicsEnvironment.isHeadless(), but obviously it isn't. This is the code snippet were it goes wrong:
if(!GraphicsEnvironment.isHeadless()) {
final UIDefaults lookAndFeelDefaults = UIManager.getLookAndFeelDefaults(); // SwingFont.java:50
if (lookAndFeelDefaults!=null) {
swingFont = lookAndFeelDefaults.getFont("defaultFont");
}
}
I tried in the following in Hudson:
Setting Java Options to -Djava.awt.headless=true in the "Build" section
Entering a line "java.awt.headless=true" in the Build Properties
All of that doesn't work. It seems those are only passed on to ant, but not onwards when invoking java to run the JUnit tests.
Is there any way to tell ant that I want my tests be run in headless mode?
I spend some time looking for this and finally found the answer. In short: setting java.awt.headless=true is not enough on linux. You have to unset DISPLAY. So, go to "Manage Hudson", "Configure System", make sure "Environment variables" is checked under "Global Properties" and add a new variable of name DISPLAY (leave the value field blank).
Currently, I have an application which uses a Versant DB. I can build this application in ant and have an ant-task for unit testing. When I run the testing task from command line, all of the test cases will run correctly. However, when I try to run the ant testing task through Jenkins/Hudson, some of the test cases throw a NoClassDefFoundError looking for one of the Versant files. Can anyone tell me what I'm missing in Jenkins to fix this?
Stack Trace:
[junit] Testcase: warning(junit.framework.TestSuite$1): FAILED
[junit] Exception in constructor: testGetTransactionWithStubSelector (java.lang.NoClassDefFoundError: Could not initialize class com.versant.trans.TransSession
[junit] at com.projectName.database.SessionPool.createPooledObject(SessionPool.java:45)
[junit] at com.projectName.util.pooling.PoolManager$ReflectivePooledObjectHandler.createPooledObject(PoolManager.java:210)
[junit] at com.projectName.util.pooling.PoolManager.init(PoolManager.java:58)
[junit] at com.projectName.database.SessionPool.<init>(SessionPool.java:20)
[junit] at com.projectName.database.DB.<init>(DB.java:507)
[junit] at com.projectName.database.DB.get(DB.java:62)
I've got a SWT application (not Eclipse RCP based) and I currently test it using SWTBot. This works fine while running the tests from Eclipse. I'm using ant as buildsystem.
On Jenkins the tests fail - an exception is thrown
[junit] Testcase: testPasswordChange(de.rssit.kgepc.swtbot.ChangePasswordTest): Caused an ERROR
[junit] null
[junit] java.lang.ExceptionInInitializerError
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacter(Keyboard.java:100)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Keyboard.java:89)
[junit] at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:92)
[junit] at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:78)
[junit] at de.foo.swtbot.pages.PasswordDialogPage.setText(PasswordDialogPage.java:70)
[junit] at de.foo.swtbot.pages.PasswordDialogPage.setOldPassword(PasswordDialogPage.java:30)
[junit] at de.foo.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:43)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getKeyboardLayout(KeyboardLayout.java:89)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:75)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.<clinit>(Keystrokes.java:110)
Searching for this specific problem did not result in any helpful solution.
Edit:
Adding the jvm args to set US english fixes this isse and makes some tests run; all other bring the following stacktrace:
[junit] Running foo.bar.swtbot.ChangePasswordTest
[junit] Testsuite: foo.bar.swtbot.ChangePasswordTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit]
[junit] Testcase: testPasswordChange(foo.bar.swtbot.ChangePasswordTest): FAILED
[junit] null
[junit] junit.framework.AssertionFailedError: null
[junit] at foo.bar.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:46)
[junit]
[junit]
[junit] Cobertura: Loaded information on 219 classes.
[junit] Cobertura: Saved information on 219 classes.
[junit] Test foo.bar.swtbot.ChangePasswordTest FAILED
[junit] Running foo.bar.swtbot.LoginDialogTest
[junit] Testsuite: foo.bar.swtbot.LoginDialogTest
[junit] Exception in thread "UIThread" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
[junit] at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
[junit] at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
[junit] at foo.bar.swtbot.UIThread$1.run(UIThread.java:79)
[junit] at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
[junit] at foo.bar.swtbot.UIThread.startEventLoop(UIThread.java:74)
[junit] at foo.bar.swtbot.UIThread.run(UIThread.java:59)
[junit] Caused by: org.eclipse.swt.SWTException: Widget is disposed
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit] at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit] at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
[junit] at org.eclipse.swt.widgets.Control.setVisible(Control.java:3725)
[junit] at foo.bar.gui.Main.tryLogin(Main.java:142)
[junit] at foo.bar.gui.Main.open(Main.java:117)
[junit] at foo.bar.swtbot.AbstractMainTest$1.run(AbstractMainTest.java:46)
[junit] at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
[junit] at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
[junit] ... 6 more
[junit] Exception in thread "Timer-0" org.eclipse.swt.SWTException: Widget is disposed
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit] at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit] at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:582)
[junit] at foo.bar.gui.AbstractKGEAdminDialog$1.run(AbstractKGEAdminDialog.java:46)
[junit] at java.util.TimerThread.mainLoop(Timer.java:512)
[junit] at java.util.TimerThread.run(Timer.java:462)
Regarding java.lang.ExceptionInInitializerError
I notice that there are / have been Eclipse bugs relating to missing keyboard layout for DE_DE locale. Could I suggest you check the locale settings of the process running the junit tests. If you set the locale to en_US, does the problem still arise?
Apart from setting the locale for the server process (e.g. LC_ALL environment variable?), perhaps you could use explicit locale in your junit task, e.g.
<junit fork="yes">
<jvmarg value="-Duser.language=en"/>
<jvmarg value="-Duser.region=US"/>
Regarding org.eclipse.swt.SWTException: Widget is disposed
Maybe this is exposing a real bug in your UI code, but I suspect you need to look at your unit tests. Are they stateless, or do they depend on a certain execution order to work reliably? Perhaps this error can arise if the tests are executed in a different order than you expect.
I meet this problem when I try to run Junit test case in fork mode (starting each test in a separate JVM) using Build ant file.
[junit] Exception in thread "main" java.lang.NoClassDefFoundError:
weblogic/management/WebLogicMBean [junit] at
java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [junit] at
java.security.AccessController.doPrivileged(Native Method) [junit] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) [junit] at
java.lang.ClassLoader.loadClass(ClassLoader.java:307) [junit] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [junit]
at java.lang.ClassLoader.loadClass(ClassLoader.java:252) [junit] at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) [junit]
at java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [junit] at
java.security.AccessController.doPrivileged(Native Method) [junit] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) [junit] at
java.lang.ClassLoader.loadClass(ClassLoader.java:307) [junit] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [junit]
at java.lang.ClassLoader.loadClass(ClassLoader.java:252) [junit] at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) [junit]
at java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) ....
I have the library weblogic.jar in my build library folders, which is set as classpath for the junit task. I look at this file and can't find the WeblogicMBean.class inside.
However, in Jdev, I can import weblogic.management.WeblogicMBean into my class if I set library reference to this weblogic.jar file and compile my class without problem.
Any suggestion of what really goes wrong?
Thanks a lot.
NoClassDefFoundError usually means the correct version of the class was not found at runtime.
Since your compile is fine, does your CLASSPATH at compile time refer to the same jar as at runtime?
Also check if there are multiple weblogic.jar in the runtime CLASSPATH for JUnit.
Whats your version of weblogic, the class is in the weblogic.jar for version 9 at least.