Issue
I am doing functional testing with geb.
My application is deployed using virgo and uses HSQLDB to store data. I would like to perform tests on this working version of application, but I would like to start with empty database, every time I run webtests.
#!/bin/sh
rm -rf $VIRGO_HOME/aresdb*
$VIRGO_HOME/bin/shutdown.sh &
sleep 10
$VIRGO_HOME/bin/startup.sh &
which removes the database and restarts virgo.
However, when I add it to my build.gradle task executing command never ends.
task cleanDB(type: Exec) {
commandLine './clean.sh'
}
Why is it this way? When I run this script in console it returns quickly (but virgo still writes to the console).
I have tried to run it in separate thread, but I encountered following error:
task cleanDBThread()<<{
def cleanDBThread1 = Thread.start {
cleanDB.execute()
}
sleep 10000
println "wake up!"
}
Exception in thread "Thread-32" java.lang.IllegalStateException:
Cannot start long running operation, as the task artifact state cache
(/home/tomasz/ares/.gradle/1.0-milestone-9/taskArtifacts) has not been locked.
I also tried setting 'create-drop' in hibernate configuration, but it also requires restarting virgo. Even redeploying the application does not help.
What should I do to run webtests with empty database?
Solution
That's weird
I created a task
task callCL(type: Exec) {
commandLine './cl.sh'
}
that calls cl.sh file
#!/bin/sh
echo "starting "
./acl.sh &
sleep 10
./acl.sh &
that call acl.sh
#!/bin/sh
echo "I am not doing anything"
and it worked! but one thing though, when you add ./acl.sh ampersand character & you're calling the task from a different thread that started gradle, and kinda looks like it's hanging. I would remove the & from your calls to shutdown and start like this
#!/bin/sh
rm -rf $VIRGO_HOME/aresdb*
$VIRGO_HOME/bin/shutdown.sh
$VIRGO_HOME/bin/startup.sh
anyways you want to wait in the same thread from shutdown to start, and no need to call sleep too!
Answered By - Luis Ramirez-Monterosa
Answer Checked By - Gilberto Lyons (JavaFixing Admin)