Geode: Add control for executing test using docker

Change-Id: Iee635e08a461b9b53c0d1c20016a6c6a733c483e
diff --git a/jjb/geode/apache-geode-test/execute_stressnew.sh b/jjb/geode/apache-geode-test/execute_stressnew.sh
index cf0ff78..059fd04 100755
--- a/jjb/geode/apache-geode-test/execute_stressnew.sh
+++ b/jjb/geode/apache-geode-test/execute_stressnew.sh
@@ -112,12 +112,16 @@
 
 if [[ -n "${PARALLEL_DUNIT}" && "${PARALLEL_DUNIT}" == "true" ]]; then
   PARALLEL_DUNIT="-PparallelDunit"
-  if [ -n "${DUNIT_PARALLEL_FORKS}" ]; then
+  if [[ -n "${DUNIT_PARALLEL_FORKS}" && "${TEST_USING_DOCKER}" == "false" ]] ; then
     DUNIT_PARALLEL_FORKS="--max-workers=${DUNIT_PARALLEL_FORKS} -PtestMaxParallelForks=${DUNIT_PARALLEL_FORKS} -PdunitParallelForks=${DUNIT_PARALLEL_FORKS}"
+  elif [[ -n "${DUNIT_PARALLEL_FORKS}" && "${TEST_USING_DOCKER}" == "true" ]] ; then
+    DUNIT_PARALLEL_FORKS="-PdunitParallelForks=${DUNIT_PARALLEL_FORKS}"
+    DOCKER_TESTING_OPTIONS="-PdunitDockerUser=geode -PdunitDockerImage=\$(docker images --format '{{.Repository}}:{{.Tag}}' | grep test-container)"
   fi
 else
   PARALLEL_DUNIT=""
   DUNIT_PARALLEL_FORKS=""
+  DOCKER_TESTING_OPTIONS=""
 fi
 
 case $ARTIFACT_SLUG in
@@ -156,6 +160,7 @@
     -PtestJava17Home=${TEST_JAVA_17_HOME} \
     ${PARALLEL_DUNIT} \
     ${DUNIT_PARALLEL_FORKS} \
+    ${DOCKER_TESTING_OPTIONS} \
     ${DEFAULT_GRADLE_TASK_OPTIONS} \
     ${GRADLE_SKIP_TASK_OPTIONS} \
     ${GRADLE_TASK} \
@@ -173,4 +178,12 @@
 echo "${EXEC_COMMAND}"
 eval "${EXEC_COMMAND}"
 
+# Cleanup
+# Make sure all test containers are stopped and removed when tests are finished
+DOCKER_CONTAINERS=$(sudo docker ps -a -q 2> /dev/null)
+if [ -n "${DOCKER_CONTAINERS}" ]; then
+  docker stop ${DOCKER_CONTAINERS} > /dev/null
+  echo -e  "Removing containers with ID:"
+  docker rm ${DOCKER_CONTAINERS}
+fi