I have a Spring Boot project which passes all it's tests under the mvn clean install command in Windows 10. The same exact code base, against the same database, has some test case failures when executing mvn clean install in Ubuntu 16.04. I traced the problem to a directory not being created by the code inside a failing test case using the mkdirs() function. I don't know why, I mean, I own the project so I wouldn't think it's a permissions issue. I cloned the project in Ubuntu from the remote repository using Intellij IDEA's built in Git functionality. Many of the other test cases (hundreds of them) are passing but a few fail and they are all related to this mkdirs() issue. Just to reiterate, the problem only exists in Ubuntu 16.04, not in Windows 10 where all tests pass. If more information is needed please let me know I'll provide.
Is there any way to resolve it without altering the code?
I found that the issue was a root directory setting being set in a configuration file of the code base. While that root directory would be openly accessible on a Windows platform, on Ubuntu it was restricted. Changing the setting in the configuration file to point to a base directory where I know I had write permission solved the issue.
Related
I'm wanting to run tests on another more powerful machine to speed up testing time, so I've created a run configuration on Intellij which targets my Ubuntu machine rather than my local one.
If I don't use rsync to copy the files to the remote target, the tests all work fine, however when I enable rsync in IntelliJ, I get the following exception when the tests attempt to start:
Error: Could not find or load main class com.intellij.rt.junit.JUnitStarter
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.junit.JUnitStarter
Process finished with exit code 1
Although I could run without rsync enabled, the copy process to the remote host takes longer than running the tests on my local machine.
For context, my local machine is running Windows 10, and my remote machine is running Ubuntu 20.04.
Thanks in advance!
EDIT:
After doing a bit more digging, I found that rsync is copying files in the maven repository and Intellij Ultimate folder using the MS-DOS file structure style. This means that as part of the copy, it's using backslashes instead of forward slashes resulting in linux thinking it's part of the name of the .jar file. In result, it means that the copied maven repository folder is in the wrong file structure:
Changing the file structure manually fixed the issue and tests run successfully however it's just a work around and doesn't directly fix the problem but at least points in the right direction.
This is a bug: https://youtrack.jetbrains.com/issue/IDEA-270106
Will be helpful if you can vote for it and attach idea logs there
In a Java project I have a dependency on my own library. I have installed this library in the local repository by running mvn install in the root of the library's directory.
When I updated the library and re-installed it, VS Code couldn't see a newly-added method (everything compiles fine from the command-line).
I've tried Java: Force Java Compilation (full) and that didn't work.
In pom.xml I right-clicked on my library and chose Update Project and that didn't help either.
If it makes any difference, I am running on WSL2 (Ubuntu-20.04) on Windows 10.
Is there any solution short of restarting VS Code (which is a rather cumbersome workaround)?
Executing the Java: Clean Java Language Server Workspace command from the Command Palette (Ctrl+Shift+P) should work.
If you added new dependencies or jars, java language server will build and compile them automatically.
In some rare cases, you may need to execute the above command to let the language server rebuild your dependencies.
Reference: Library Configuration
I have a project in Java and I also used Gradle and TestNG. It works perfectly without jenkins.
After that I configured Jenkins and now I can run the code with Gradle command in Jenkins on my Local.
Then I tried to run the code on Slave machine. I can see the Slave machine in Jenkins nodes. I also configured Gradle and Java to run on Slave machine. I have to mention that I don't use Version Control in this project.
When I start the job in Jenkins to run on Slave machine, it starts the job but the problem is, it cannot find for example the gradle.build, as it's located in my Local machine and not in Slave machine.
The question is, should I use Version Control? is it going to solve the problem? or should I use Copy Artifact Plugin ?
Complementary Question: If I make a local git for my network on the same machine that runs Jenkins, it is going to be a problem?
Thanks for your help :)
Slave machine need your file gradle.build, so either place it there manually by SFTP.
If your gradle.build going to change regularly then its prefer to use version control like git by which jenkins will fetch the latest files.
Again its not mandatory but recommended to use version control like git to prevent from unnecessary errors
I am trying to set up the environment with Java, git, Jenkins and maven by mentioning the IP address of linux VM. I have written a code to connect to VM, create folders, and move files to folders.
Now I want to install all Java and others software programmatically. Ib tried to install Java using yum -y install java-1.7.0. There is no error but then Java is not installed.
Please suggest what needs to be done so that Java gets installed and java_home path is set programmatically.
Any help is appreciated.
We've been doing this at the office this week. It sounds like you want a solution which would include JscH because you've started down that path. What I have to offer you is a solution that uses Jenkins.
We set up a target machine (two actually) as Jenkins slaves. It's rather easy to do, but you do need to install a JVM. You might look at docker.
Once the Jenkins slave is connected to the jenkins master, we just instruct it to run scripts. Some commands require sudo and so we set that up so that it does not require a password to be entered. Alternatively, you could run the jenkins slave jar after already having sudo -- not recommended.
We made a pom.xml to fetch .jar files and tar.gz files out of maven and copy them into a specific location. Then we executed scripts that manipulated them. The scripts came out of version control via Jenkins, but other files we pulled out of version control using a script.
All in all, I have the following tips for you:
Debug a script by executing it without Jenkins, and then run it under Jenkins for some final debug.
Put plenty of echo statements into your scripts so that you can see what has gone wrong.
You're totally relying on the Jenkins log and print debugging. This is very time consuming. So you would do well to pay attention to point #1.
Good luck :-)
I (Git) pulled my (working) project on a different pc (on both pc's I'm working with Intellij-idea), I (Maven) compiled it but my tests directory is out of sync.
Trying to run it I get "0 test class found in package ''".
Ideas?
As it turns out, the Tests directory was not in the same hierarchy as my code.
The environment on my first pc was configured so it will bypass the issue and just run the tests as they are, but it is only a local bandage.
So if you come across a problem of that sort, first make sure that you have the same hierarchy level (code and tests), otherwise Maven will not find and run the tests.