Commit b6e4ed15 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

made runs random and added statistics

parent a720e5a7
run.cfg
\ No newline at end of file
run.cfg
statistics.txt
run.txt
\ No newline at end of file
......@@ -45,10 +45,10 @@ if [ $1 -gt 1 ]; then
/usr/bin/systemctl stop %{name}.timer
# Sleep just to be on the safe side
sleep 10
# Remove all but the logs directory
find /local_disk/%{name} -mindepth 1 -maxdepth 1 -depth -not -name logs -print0 | xargs -0 rm -rf
# Remove all log files older than 10 days
find /local_disk/%{name}/logs -type f -mtime +10 -print0 | xargs -0 rm -rf
# Remove all but the run output directory
find /local_disk/%{name}/run -mindepth 1 -maxdepth 1 -depth -not -name output -print0 | xargs -0 rm -rf
# Remove all log files older than 30 days
find /local_disk/%{name}/run/output -type f -mtime +30 -print0 | xargs -0 rm -rf
fi
......
......@@ -4,6 +4,7 @@
import sys
import json
import requests
import random
from requests.auth import HTTPBasicAuth
from time import time, strftime, sleep
from datetime import datetime, timedelta
......@@ -48,13 +49,15 @@ class Runner(object):
end = time()
# done
hasError = requests.get('/'.join([self.url, "workarea", "v2", wid, "error.txt"])).status_code == 200
with open(path+'/output/'+name+'.txt', 'w') as outputfile:
with open(path+'/output/run.txt', 'w') as outputfile:
if (status != 'COMPLETE') or hasError:
outputfile.write('0')
with open(path+'/output/'+name+'_'+datetime.utcnow().strftime("%Y%m%d%H%M")+'.txt', 'w') as errorfile:
errorfile.write(wid)
else:
outputfile.write('1')
with open(path+'/output/statistics.txt', 'a') as statisticsfile:
statisticsfile.write(datetime.utcnow().strftime("%Y%m%d%H%M")+' '+wid+' '+name+'\n')
class HELCOM_NEMO(Runner):
def __init__(self, value):
......@@ -84,13 +87,19 @@ class VN_NEMO(Runner):
super(VN_NEMO, self).__call__(self.jdata, self.name, "VN_NEMO")
# TODO
# Change user to stw when ready
# Create packages to be able to run tests in separate files
# Install in prod
# Create Ester for monitor signal
def main():
start = time()
try:
for v in [HELCOM_NEMO(1), HELCOM_NEMO(2), VN_NEMO(1), BF_NEMO(1)]:
v()
end = time()
print "All done in "+str(end-start)+" seconds"
v = [HELCOM_NEMO(1), HELCOM_NEMO(2), VN_NEMO(1), BF_NEMO(1)]
r = random.choice(v)
r();
sys.exit(0)
except Exception as error:
print error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment