How to cleanup CommitLog files using Cassandra in Unit Tests - unit-testing

I've got a problem that's very similar to the one listed here:
How to cleanup embedded cassandra after unittest?
In short, I'm firing up Cassandra to run some integration tests, but when my test classes run they fail as they are unable to delete the CommitLog files that are produced by Cassandra.
I'm following the suggestions in the answer given there, which are to perform cleanup on startup, but at that time the files still cannot be deleted (if I debug through the code, I am also unable to delete the files at that time via the command line or the GUI). The result is that my first test class passes, but all subsequent ones fail.
Further details:
My colleagues are running on OSX and do not have this problem; I am on Windows 7.
I've tried running the tests under DOS and Cygwin, as well as through Eclipse, in all cases both as my local user and as Administrator.
I've used Process Explorer to confirm that nothing apart from a single Java process has a handle on the file in question.
I've debugged through the code right down to the native call in java.io.Win32FileSystem, which is unable to delete the file.
Is there anything I can do to ensure Cassandra has shut down and/or deleted its CommitLog file?
Thanks!

Related

Unable to delete EXE after it crashes even though process not shown in Task Manager

I have a program that I have written that crashes and I'm in the process of debugging it.
However, the issue is that when I attempt to create a new build, very frequently (but not always!) I get the message:
Cannot open file 'TheExecutable.exe'
I am then unable to delete, rename, move, or in any way modify the executable until the system is rebooted. Attempting to do so in Windows explorer gives
The action can't be completed because the file is open in TheExecutable.exe Close the file and try again.
This behavior isn't unique to the particular crash I'm dealing with right now, nor the particular program. Development is becoming a headache as every attempt to debug will now take several minutes to reboot and bring all my tooling back up.
What, if anything, can I do to prevent Windows from "locking" the executable in such a fashion?
No running process for that executable is visible in Task Manager
Full details of build system:
Windows 10
Intel Compiler, 19.1.0.166 Build 20191121
nmake
C++14
Your process is not being terminated all the way. Since it is not list in the task manager, you can use PSKILL to end it manually.
Open power shell or the console in administrator mode and run
pskill name_of_executable
and it should terminate it so you can re-run it.

autoupdate strategy for application

I have application written on C++, and I want to be able to update it like Google Chrome does:
Silently download new version from server,
replace original files and
restart app.
I also want to replace exe file, that locked as it in use now.
Couldn't find any solution for this type of autoupdate.
Maybe wxWidgets have such tools?
Or maybe you know, how to do this?
Make 2 programs. Your primary application, and a launcher. The launcher is what people should click on to start your program, and it is responsible for starting the primary application, and then can shut itself down. If you need to update while the primary application is running, you can download the updated program to a separate file, along with any other files necessary. Then the primary application can launch the launcher and shut itself down. The launcher then is responsible for deleting the old program and renaming the new one, and relaunching it.
Actually, this doesn't even have to be two different programs. It can be the same program operating in two different modes (selected through command line arguments, for example). You still need 2 copies of the executable file on disk though. Note that this is precisely what Google Chrome does.
The theory is described in the comment above. In practice, you should have a look at WinSparkle.
Package your program as an MSI file (Windows installer). Then download your new msi file and launch it. Windows installer takes care of updating your program and you can author the installer to relaunch your app.
Take a look at http://wixtoolset.org/ for how to build your installer.

How to run C++ test on visual studio online

I have test cases that are executable (*.exe files). There is no user interface involved.
How do I use Team center /visual studio online to run these test cases on server.
For now, either on demand running or scheduled running will work for me.
(Currently I have no test case that runs on server. So you may mention the basic setup. )
I have written some test cases (they are exe files). I can run them locally line any other exe file.
My code is in C++.
My test cases are in C++.
You could run them as part of your build. Just configure a build in VSO for your solution, and then modify the msbuild project file to call your tests and send the output to the build folder so it gets uploaded as part of the drop. If you are using VS, you would get a better experience using the VS unit testing support (i.e., get results in VS): http://www.visualstudio.com/get-started/run-tests-with-builds-vs.

VS Command Line "The Process cannot access the file...because it is being used by another process" build fails

I've seen a bunch of other questions that are similar to this one regarding VS, but none in regards to the command line.
Using VS Command line (i.e. BuildConsole "SOLUTIONNAME" /BUILD /cfg="CONFIG_SETTINGS" /prf="PROJECTNAME"), I get the highly reproducable (although not 100%) error shown in the question: "The process cannot access the file because it is being used by another process". However, I only get this error the first 1-5 times I run BuildConsole. It seems to be a timing-related thing. If I run BuildConsole once, then wait a while, then run again, it will work. If I run it 5 times consecutively, it will fail all 5 times or sometimes work on the 5th, depending on how fast the previous runs failed. Also, I can get it to work 100% of the time by opening the solution in VS IDE and then closing the IDE and re-running.
This build command is part of a tool that will report failure if the command fails (which it does, most of the time, although it shouldn't fail). So my question is this: how can I get the BuildConsole command to work the 1st time, 100% of the time? Obviously I don't expect it to work if the solution/project is actually being used by another process, but it should be able to take control from whatever is hanging onto the files.
I had the same problem on windows 7, have moved Visual Studio folder from Documents folder to the root of C:\, changed the location in Tools/Options/Help/Import and Export settings to point to the new location, same with Projects and Solutions all pointing to the new location.
No problems with building at all, unless there is an error with the code.
The problem was not running in administrator mode. When I set my C# program that is running BuildConsole to force admin rights, BuildConsole works every time.

Jenkins build fails when user logs off node

Sometimes, builds done by Jenkins (1.461) will stop at a random spot somewhere in the middle. These builds are manually scripted calls to Visual Studio 2008 SP1's devenv.com for primarily C++ code. Visual Studio emits no error messages; the last message in devenv's log is some random file being built. The Jenkins build fails because of a post-build Windows batch command that relies on some of the build outputs. This happens fairly rarely (roughly 1 in 15 builds). Jenkins's error log shows nothing out of the ordinary around the time the build fails. Surprisingly, it says the build succeeded, even though it shows it as failed everywhere else.
The problem is isolated to Jenkins. The same build script run at a developer's desk has never failed in this way.
The Jenkins nodes are 32-bit Windows XP machines. They all have ample available disk space. Jenkins is configured to only run one job at a time per node. The event logs show no obviously bad things (e.g., Visual Studio crashes) happening at the times when the builds stop.
Does anyone have any ideas of things to look into to troubleshoot this?
I don't recall ever having this problem with jenkins myself, but I have regular linker crashes in MSVC 2008. This happens almost everyday for me. If it is the linker crashing then that could be an explanation.(perhaps a linker crash is not logged?)
Edit:
We use MSVC2008 SP1 on 32-bit Win7.
We use MSBuild 3.5 when building the c++ solutions.
We ended up correlating the random build failures with logoff events on the Jenkins nodes. This lead to this JVM bug/feature (Oracle Java bug ID 6871190), where a logoff event in Windows causes the signal handlers to terminate the JVM. You can disable this behavior (perhaps with other downsides) by passing the -Xrs option to the JVM, but that option will not automatically propagate to child Java processes.
We are passing -Xrs to kick off Jenkins itself, and the Jenkins service itself lives through a logoff. The current hypothesis is that some part of Jenkins's build process is kicked off through another Java child process who is not invoked with -Xrs.