Skip to content
This repository was archived by the owner on Jan 6, 2018. It is now read-only.

Commit ae825cf

Browse files
Merge pull request #15 from deepeshmittal/master
Execution script display, text file view fixes, New Daytona logo and header, Handshake mechanism fixed, Test level logger added
2 parents 988c470 + 0d9a760 commit ae825cf

21 files changed

+441
-310
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Daytona
1+
# <img src="docs/img/daytona_dark_text.png" alt="Daytona" width="250px">
22

33
Daytona is an application-agnostic framework for automated performance testing and analysis. Any performance testing script running on command line can be integrated into a Daytona framework for repeatable execution and methodical analysis.
44

Scheduler+Agent/action.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import subprocess
44
import threading
55
import common
6-
from common import CommunicationError
76
import os
87
import time
98
import shutil
@@ -13,6 +12,7 @@
1312
import client
1413
import config
1514
import signal
15+
import envelope
1616
from logger import LOG
1717

1818
lctx = None
@@ -243,6 +243,16 @@ def log(self, *args):
243243
lctx.debug(args)
244244

245245

246+
def scheduler_handshake(current_test):
247+
cl = client.TCPClient(LOG.getLogger("clientlog", "Agent"))
248+
env = envelope.DaytonaEnvelope()
249+
ret = cl.send(current_test.serverip, current_test.serverport, env.construct("DAYTONA_HANDSHAKE", "handshake2"))
250+
if ret == "SUCCESS":
251+
return True
252+
else:
253+
return False
254+
255+
246256
def startMonitor(self, *args):
247257
(obj, command, params, actionID, sync) = (args[0], args[1], args[2], args[3], args[4])
248258

Scheduler+Agent/envelope.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# -*- coding:cp949 -*-
33
import uuid
44

5-
class DaytonaEnvelope():
6-
#todo : write all members correctly
7-
def __init__(self):
8-
self.msgid = None
9-
self.timestamp = None
10-
self.host = None
115

12-
def construct(self, command, data):
13-
self.msgid = uuid.uuid4()
14-
#todo : include security appid here/ hostip_name
15-
return "DAYTONA_CMD:" + command + ":" + str(self.msgid) + ":" + data
6+
class DaytonaEnvelope:
7+
# todo : write all members correctly
8+
def __init__(self):
9+
self.msgid = None
10+
self.timestamp = None
11+
self.host = None
1612

13+
def construct(self, command, data):
14+
self.msgid = uuid.uuid4()
15+
# todo : include security appid here/ hostip_name
16+
return "DAYTONA_CMD:" + command + ":" + str(self.msgid) + ":" + data
1717

Scheduler+Agent/logger.py

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,65 @@
11
#!/usr/bin/env python
22
# -*- coding:cp949 -*-
3-
import glob
43
import logging
54
import logging.handlers
65

6+
77
class Singleton(type):
8-
_instances = {}
8+
_instances = {}
99

10-
def __call__(cls, *args, **kwargs):
11-
if cls not in cls._instances.keys():
12-
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
13-
return cls._instances[cls]
10+
def __call__(cls, *args, **kwargs):
11+
if cls not in cls._instances.keys():
12+
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
13+
return cls._instances[cls]
1414

1515

1616
class LOG(object):
17-
__metaclass__ = Singleton
18-
19-
_loggers = {}
20-
21-
def __init__(self, *args, **kwargs):
22-
pass
23-
24-
@staticmethod
25-
def getLogger(name=None, ROLE=""):
26-
name = name+ROLE
27-
if name not in LOG._loggers.keys():
28-
LOG_FILENAME = ROLE + '_logging_rotatingfile.log'
29-
logging.basicConfig(level=logging.DEBUG,
30-
format='%(asctime)s %(threadName)-12s %(name)-16s %(levelname)-6s {%(filename)-12s %(lineno)-4d} %(message)-100s',
31-
datefmt='%m-%d %H:%M',
32-
filename=LOG_FILENAME,
33-
filemode='w')
34-
35-
# Add the log message handler to the logger
36-
handler = logging.handlers.RotatingFileHandler(
37-
LOG_FILENAME, maxBytes=1073741824, backupCount=2)
38-
39-
console = logging.StreamHandler()
40-
formatter = logging.Formatter('%(asctime)s %(threadName)-14s %(name)-19s %(message)s')
41-
console.setLevel(logging.INFO)
42-
console.setFormatter(formatter)
43-
44-
formatter = logging.Formatter('%(asctime)s - %(name)16s - %(message)s')
45-
LOG._loggers[name] = logging.getLogger(str(name))
46-
LOG._loggers[name].setLevel(logging.DEBUG)
47-
LOG._loggers[name].addHandler(handler)
48-
handler.setFormatter(formatter)
49-
LOG._loggers[name].addHandler(console)
50-
51-
return LOG._loggers[name]
17+
__metaclass__ = Singleton
18+
19+
_loggers = {}
20+
21+
def __init__(self, *args, **kwargs):
22+
pass
23+
24+
@staticmethod
25+
def getLogger(role=None, filename="", testlogger=False, filepath=""):
26+
role += filename
27+
28+
if role not in LOG._loggers.keys():
29+
if testlogger:
30+
log_filename = filepath + filename + '_logging_rotatingfile.log'
31+
else:
32+
log_filename = filename + '_logging_rotatingfile.log'
33+
34+
logging.basicConfig(level=logging.DEBUG,
35+
format='%(asctime)s %(threadName)-12s %(name)-16s %(levelname)-6s {%(filename)-12s %(lineno)-4d} %(message)-100s',
36+
datefmt='%m-%d %H:%M',
37+
filename=log_filename,
38+
filemode='w')
39+
40+
# Add the log message handler to the logger
41+
handler = logging.handlers.RotatingFileHandler(
42+
log_filename, maxBytes=1073741824, backupCount=2)
43+
44+
console = logging.StreamHandler()
45+
formatter = logging.Formatter('%(asctime)s %(threadName)-14s %(name)-19s %(message)s')
46+
console.setLevel(logging.INFO)
47+
console.setFormatter(formatter)
48+
49+
formatter = logging.Formatter('%(asctime)s %(levelname)-s : %(message)-100s','%m-%d %H:%M')
50+
LOG._loggers[role] = logging.getLogger(str(role))
51+
LOG._loggers[role].setLevel(logging.DEBUG)
52+
53+
LOG._loggers[role].addHandler(handler)
54+
handler.setFormatter(formatter)
55+
LOG._loggers[role].addHandler(console)
56+
57+
return LOG._loggers[role]
58+
59+
60+
@staticmethod
61+
def removeLogger(role, filename):
62+
role += filename
63+
if role in LOG._loggers.keys():
64+
del LOG._loggers[role]
5265

0 commit comments

Comments
 (0)