@@ -3,7 +3,6 @@ |
# <war_upd.sh> <platform> <context> |
# |
# * * * * * flock -xn /var/tmp/warman.lck -c "/od/projects/csip-all/csip-core/deploy/warman.sh localhost csip-lmod /var/tmp/warman >> /var/tmp/warman/out 2>&1" |
- |
|
platform=$1 |
context=$2 |
@@ -11,11 +10,11 @@ |
cd $3 |
|
tomcat=/opt/apache-tomcat-8.0.20 |
-jenkins_host=https://alm.engr.colostate.edu |
+jenkins=https://alm.engr.colostate.edu/jenkins |
|
#const |
deployfile="${context}-${platform}-csip.sh" |
-deployfile_url=${jenkins_host}/jenkins/job/${context}/ws/work/deploy/${platform}/csip.sh |
+deployfile_url=${jenkins}/job/${context}/ws/work/deploy/${platform}/csip.sh |
|
#cmds |
WGET="wget -N -q -O " |
@@ -24,12 +23,6 @@ |
now=`date` |
echo "[${now}] checking ${context} on ${platform}..." |
|
-# check if tomcat is running: |
-${CHECK} http://localhost:8080 |
-if [ $? -ne 0 ] ; then |
- echo 'tomcat not running, no action taken.' |
- exit 99 |
-fi |
|
# check if alm is there |
${CHECK} ${deployfile_url} |
@@ -44,63 +37,127 @@ |
#cat ${deploy_file} |
source ${deployfile} |
|
+#### don't do anything. |
if [ "${action}" == "disabled" ] ; then |
echo 'disabled' |
+ exit 0 |
+fi |
+ |
+#### star tomcat |
+if [ "${action}" == "tomstart" ] ; then |
+ echo 'starting tomcat..' |
+ ${tomcat}/bin/startup.sh |
+ exit 0 |
+fi |
+ |
+#### stop tomcat |
+if [ "${action}" == "tomstop" ] ; then |
+ echo 'stopping tomcat..' |
+ ${tomcat}/bin/shutdown.sh |
+ exit 0 |
+fi |
+ |
+war="${context}##${version}.war" |
+conf="${context}##${version}.json" |
+war_url=${jenkins}/job/${context}/lastBuild/artifact/work/dist/${context}%23%23${version}.war |
+conf_url=${jenkins}/job/${context}/ws/work/deploy/${platform}/${version}-conf.json |
+ |
+# check if tomcat is running: |
+${CHECK} http://localhost:8080 |
+if [ $? -ne 0 ] ; then |
+ echo 'tomcat not running, no action taken.' |
exit 99 |
fi |
|
-war="${context}##${ver}.war" |
-conf="${context}-${platform}-conf.json" |
-war_url=${jenkins_host}/jenkins/job/${context}/lastBuild/artifact/work/dist/${context}%23%23${ver}.war |
-conf_url=${jenkins_host}/jenkins/job/${context}/ws/work/deploy/${platform}/conf.json |
+#### undeploy this context. |
+if [ "${action}" == "undeploy" ] ; then |
+ if [ -f ${tomcat}/webapps/${war} ] ; then |
+ rm -f ${tomcat}/webapps/${context}##*.war |
+ rm -f ${tomcat}/webapps/${context}##*.json |
+ echo "removed ${context} ..." |
+ while : |
+ do |
+ sleep 1 |
+ echo "undeploying ..." |
+ a=`find ${tomcat}/webapps/${context}##* -maxdepth 0 -type d 2>/dev/null` |
+ if [ "$a" = "" ] ; then |
+ echo " done." |
+ break |
+ fi |
+ done |
+ exit 0 |
+ fi |
+fi |
|
|
-# check |
-diff ${deployfile} ${deployfile}.local > /dev/null 2>&1; |
-if [ $? -ne 0 ] ; then |
- echo "update needed." |
- echo " checking if ${war} is already deployed." |
- if [ ! -f ${tomcat}/webapps/${war} ] ; then |
- echo " ${war} does not exist in ${tomcat}" |
- |
- # delete all prev war files of this context. |
- rm -f ${tomcat}/webapps/${context}##*.war |
- |
- while : |
- do |
+#### (re)deploy, remove any previous deployment |
+if [ "${action}" == "deploy" ] ; then |
+ # check |
+ diff ${deployfile} ${deployfile}.local > /dev/null 2>&1; |
+ if [ $? -ne 0 ] ; then |
+ echo "update needed." |
+ echo " checking if ${war} is already deployed." |
+ if [ ! -f ${tomcat}/webapps/${war} ] ; then |
+ echo " ${war} does not exist in ${tomcat}" |
+ |
+ echo "downloading ${war} ..." |
+ ${CHECK} ${war_url} |
+ if [ $? -ne 0 ] ; then |
+ echo " ${war_url} not found." |
+ exit 99 |
+ fi |
+ ${WGET} ${war} ${war_url} |
+ if [ ! -f ${war} ] ; then |
+ echo " ${war} not found." |
+ exit 99 |
+ fi |
+ |
+ |
+ # delete all prev war/json files of this context and wait. |
+ rm -f ${tomcat}/webapps/${context}##*.war |
+ rm -f ${tomcat}/webapps/${context}##*.json |
+ |
+ while : |
+ do |
+ sleep 1 |
+ echo "undeploying ..." |
+ a=`find ${tomcat}/webapps/${context}##* -maxdepth 0 -type d 2>/dev/null` |
+ if [ "$a" = "" ] ; then |
+ echo " done." |
+ break |
+ fi |
+ done |
+ |
+ echo "downloading ${conf_url} ..." |
+ ${CHECK} ${conf_url} |
+ if [ $? -eq 0 ] ; then |
+ ${WGET} ${conf} ${conf_url} |
+ if [ -f ${conf} ] ; then |
+ echo "use ${conf}" |
+ cp ${conf} ${tomcat}/webapps |
+ fi |
+ fi |
+ |
+ echo "copy ${war}" |
+ cp ${war} ${tomcat}/webapps |
+ |
+ # conf |
+ while : |
+ do |
+ echo "deploying ..." |
sleep 1 |
- echo "undeploying ..." |
- a=`find ${tomcat}/webapps/${context}##* -maxdepth 0 -type d 2>/dev/null` |
- if [ "$a" = "" ] ; then |
- echo " done." |
+ # probe for the context to be available |
+ ${CHECK} http://localhost:8080/${context}/c/conf |
+ if [ $? -eq 0 ] ; then |
+ echo " alive." |
+ sleep 1 |
break |
fi |
- done |
+ done |
+ fi |
+ fi |
+ mv ${deployfile} ${deployfile}.local |
+ exit 0 |
+fi |
|
- echo "downloading ${war}" |
- ${WGET} ${war} ${war_url} |
- |
- echo "deploying ${war}" |
- cp ${war} ${tomcat}/webapps |
- |
- |
- # conf |
- while : |
- do |
- echo "deploying ..." |
- sleep 1 |
- # probe for the context to be available |
- ${CHECK} http://localhost:8080/${context}/c/conf |
- if [ $? -eq 0 ] ; then |
- echo " alive." |
- sleep 1 |
- break |
- fi |
- done |
- |
- echo "configuring with ${conf} ..." |
- ${WGET} ${conf} ${conf_url} |
- curl -H "Content-Type:application/json" -H "Accept:application/json" -X POST -d @${conf} http://localhost:8080/${context}/c/conf 1>&2 2>/dev/null |
- fi |
-fi |
-mv ${deployfile} ${deployfile}.local |
+exit 99 |
\ No newline at end of file |
@@ -59,7 +59,7 @@ |
File[] files; |
File target; |
|
- String testing; |
+ String testing = NONE; |
int concurrent = 1; |
int timeout = 1000; |
int delay = 0; |
@@ -67,16 +67,15 @@ |
String contextUrl = null; |
|
boolean downloadFiles = true; |
- String logLevel = "WARNING"; |
final JSONArray reports = new JSONArray(); |
|
- static final Logger log = Logger.getLogger("ServiceTest"); |
+ static final Logger log = Logger.getLogger("ServiceTest "); |
+ static final StreamHandler sh = new StreamHandler(System.out, new SimpleFormatter()); |
|
|
static { |
- log.setLevel(Level.SEVERE); |
- SimpleFormatter fmt = new SimpleFormatter(); |
- StreamHandler sh = new StreamHandler(System.out, fmt); |
+ sh.setLevel(Level.INFO); |
+ log.setLevel(Level.INFO); |
log.addHandler(sh); |
} |
|
@@ -98,45 +97,58 @@ |
} |
|
// load the service testing settings. |
- testing = config.getProperty("verify", NONE); // strict, keys |
- if (!VALIDTESTING.contains(testing)) { |
- throw new RuntimeException("invalid testing method: " + testing); |
+ String s = config.getProperty("csip.test.verify", System.getProperty("csip.test.verify")); |
+ if (VALIDTESTING.contains(s)) { |
+ testing = s; |
} |
|
- String d = config.getProperty("contextURL", System.getProperty("csip.test.contexturl")); |
- if (d != null && !d.equals("${csip.test.contexturl}")) { |
- contextUrl = d; |
+ s = config.getProperty("csip.test.contexturl", System.getProperty("csip.test.contexturl")); |
+ if (s != null && !s.isEmpty()) { |
+ contextUrl = s; |
} |
|
- d = config.getProperty("concurrency", System.getProperty("csip.test.concurrency")); |
- if (d != null) { |
- concurrent = Integer.parseInt(d); |
+ s = config.getProperty("csip.test.concurrency", System.getProperty("csip.test.concurrency")); |
+ if (s != null) { |
+ try { |
+ concurrent = Integer.parseInt(s); |
+ } catch (NumberFormatException E) { |
+ } |
} |
|
- d = config.getProperty("timeout", System.getProperty("csip.test.timeout")); |
- if (d != null) { |
- timeout = Integer.parseInt(d); |
+ s = config.getProperty("csip.test.timeout", System.getProperty("csip.test.timeout")); |
+ if (s != null) { |
+ try { |
+ timeout = Integer.parseInt(s); |
+ } catch (NumberFormatException E) { |
+ } |
} |
|
- d = config.getProperty("delay", System.getProperty("csip.test.delay")); |
- if (d != null) { |
- delay = Integer.parseInt(d); |
+ s = config.getProperty("csip.test.delay", System.getProperty("csip.test.delay")); |
+ if (s != null) { |
+ try { |
+ delay = Integer.parseInt(s); |
+ } catch (NumberFormatException E) { |
+ } |
} |
|
- d = config.getProperty("rounds", System.getProperty("csip.test.rounds")); |
- if (d != null) { |
- rounds = Integer.parseInt(d); |
+ s = config.getProperty("csip.test.rounds", System.getProperty("csip.test.rounds")); |
+ if (s != null) { |
+ try { |
+ rounds = Integer.parseInt(s); |
+ } catch (NumberFormatException E) { |
+ } |
} |
|
// warmup phase: 0-off, 1-on |
- d = config.getProperty("download_files", System.getProperty("csip.test.downloadfiles")); |
- if (d != null) { |
- downloadFiles = Boolean.parseBoolean(d); |
+ s = config.getProperty("csip.test.downloadfiles", System.getProperty("csip.test.downloadfiles")); |
+ if (s != null) { |
+ downloadFiles = Boolean.parseBoolean(s); |
} |
|
- logLevel = config.getProperty("logLevel", "WARNING"); |
- if ((logLevel != null) && (logLevel.length() > 0)) { |
- log.setLevel(Level.parse(logLevel)); |
+ s = config.getProperty("csip.test.loglevel", System.getProperty("csip.test.loglevel")); |
+ if (s != null && !s.isEmpty()) { |
+ sh.setLevel(Level.parse(s)); |
+ log.setLevel(Level.parse(s)); |
} |
} |
|
@@ -227,7 +239,7 @@ |
report.put("test", E.getMessage()); |
stats.incFailed(); |
} catch (JSONException ex) { |
- Logger.getLogger(ServiceTest2.class.getName()).log(Level.SEVERE, null, ex); |
+ log.log(Level.SEVERE, null, ex); |
} |
} finally { |
synchronized (reports) { |