#!/bin/bash

echo "Run from AS root folder."
echo ""
echo "will test clustered cl leaks by deploying repeatedly"
echo ""

export SOURCE="testsuite/output/lib/cluster-clleak-nopass.war" 
export TARGET="build/target/jboss-6.0.0-SNAPSHOT/server/all/deploy/cluster-clleak-nopass.war"

cp "testsuite/output/lib/classloader-leak-test.sar" "build/target/jboss-6.0.0-SNAPSHOT/server/all/deploy/"

for i in {1..2}
do
   echo "deploy loop $i"

   cp $SOURCE $TARGET

   echo "sleep 10"
   sleep 10
curl http://localhost:8080/clustered-clleak/SimpleServlet

   echo "sleep 10"
   sleep 10

   echo "undeploy by removing $TARGET"
   rm $TARGET

   echo "sleep 20"
   sleep 20

#   echo "memory dump to memory.txt"
#   jmap -heap 3178 >> memory.txt

done


rm "build/target/jboss-6.0.0-SNAPSHOT/server/all/deploy/classloader-leak-test.sar"
