Skip to content

Commit 7cc9423

Browse files
Santhosh EdukullaGirish Shilamkar
authored andcommitted
CLOUDSTACk-5674: Added few misc changes to make it work.
1 parent c1d3436 commit 7cc9423

10 files changed

Lines changed: 110 additions & 86 deletions

tools/marvin/marvin/asyncJobMgr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
import threading
19-
import cloudstackException
19+
from marvin import cloudstackException
2020
import time
2121
import Queue
2222
import copy

tools/marvin/marvin/cloudstackConnection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Timeout,
3939
RequestException
4040
)
41-
from cloudstackException import GetDetailExceptionInfo
41+
from marvin.cloudstackException import GetDetailExceptionInfo
4242

4343

4444
class CSConnection(object):

tools/marvin/marvin/cloudstackTestClient.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,24 @@
2626
USER, SUCCESS, XEN_SERVER)
2727
from configGenerator import ConfigManager
2828
from marvin.lib import utils
29-
from cloudstackException import GetDetailExceptionInfo
29+
from marvin.cloudstackException import GetDetailExceptionInfo
3030
from marvin.lib.utils import (random_gen, validateList)
3131
from marvin.cloudstackAPI.cloudstackAPIClient import CloudStackAPIClient
3232

33-
'''
34-
@Desc : CloudStackTestClient is encapsulated entity for creating and
33+
class CSTestClient(object):
34+
'''
35+
@Desc : CloudStackTestClient is encapsulated entity for creating and
3536
getting various clients viz., apiclient,
3637
user api client, dbconnection, test Data parsed
3738
information etc
38-
@Input : mgmtDetails : Management Server Details
39+
@Input : mgmtDetails : Management Server Details
3940
dbSvrDetails: Database Server details of Management \
4041
Server. Retrieved from configuration file.
4142
asyncTimeout : Timeout for Async queries
4243
defaultWorkerThreads : Number of worker threads
4344
logger : provides logging facilities for this library
4445
zone : The zone on which test suites using this test client will run
45-
'''
46-
47-
48-
class CSTestClient(object):
46+
'''
4947
def __init__(self, mgmt_details,
5048
dbsvr_details,
5149
async_timeout=3600,

tools/marvin/marvin/dbConnection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from mysql import connector
2121
from mysql.connector import errors
2222
from contextlib import closing
23-
import cloudstackException
23+
from marvin import cloudstackException
2424
import sys
2525
import os
2626

tools/marvin/marvin/deployDataCenter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ def deploy(self):
686686
log_check = False
687687
if log_obj is not None:
688688
log_check = True
689-
ret = log_obj.createLogs("DataCenter",
689+
ret = log_obj.createLogs("DeployDataCenter",
690690
cfg.logger)
691691
if ret != FAILED:
692692
log_folder_path = log_obj.getLogFolderPath()

tools/marvin/marvin/lib/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import datetime
3131
from platform import system
3232
from marvin.cloudstackAPI import cloudstackAPIClient, listHosts
33-
from cloudstackException import GetDetailExceptionInfo
33+
from marvin.cloudstackException import GetDetailExceptionInfo
3434
from marvin.sshClient import SshClient
3535
from marvin.codes import (
3636
SUCCESS,

tools/marvin/marvin/marvinInit.py

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
'''
18-
@Desc: Initializes the marvin and does required prerequisites
18+
Initializes the marvin and does required prerequisites
1919
for starting it.
2020
1. Parses the configuration file passed to marvin and creates a
2121
parsed config
@@ -25,8 +25,7 @@
2525
2626
'''
2727

28-
from marvin import configGenerator
29-
from marvin import cloudstackException
28+
from marvin.configGenerator import getSetupConfig
3029
from marvin.marvinLog import MarvinLog
3130
from marvin.deployDataCenter import DeployDataCenters
3231
from marvin.cloudstackTestClient import CSTestClient
@@ -49,7 +48,8 @@
4948

5049

5150
class MarvinInit:
52-
def __init__(self, config_file, load_api_flag=None,
51+
def __init__(self, config_file,
52+
load_api_flag=None,
5353
deploy_dc_flag=None,
5454
test_module_name=None,
5555
zone=None):
@@ -67,14 +67,14 @@ def __init__(self, config_file, load_api_flag=None,
6767

6868
def __parseConfig(self):
6969
'''
70+
@Name: __parseConfig
7071
@Desc : Parses the configuration file passed and assigns
7172
the parsed configuration
73+
@Output : SUCCESS or FAILED
7274
'''
7375
try:
74-
if self.__configFile is None:
75-
return FAILED
76-
self.__parsedConfig = configGenerator.\
77-
getSetupConfig(self.__configFile)
76+
self.__parsedConfig = getSetupConfig(self.__configFile)
77+
7878
return SUCCESS
7979
except Exception, e:
8080
print "\nException Occurred Under __parseConfig : " \
@@ -94,6 +94,11 @@ def getLogger(self):
9494
return self.__tcRunLogger
9595

9696
def getDebugFile(self):
97+
'''
98+
@Name : getDebugFile
99+
@Desc : Returns the Result file to be used for writing
100+
test outputs
101+
'''
97102
if self.__logFolderPath is not None:
98103
self.__tcResultFile = open(self.__logFolderPath +
99104
"/results.txt", "w")
@@ -108,6 +113,7 @@ def init(self):
108113
2. Creates a timestamped log folder and provides all logs
109114
to be dumped there
110115
3. Creates the DataCenter based upon configuration provided
116+
@Output : SUCCESS or FAILED
111117
'''
112118
try:
113119
if ((self.__parseConfig() != FAILED) and
@@ -125,28 +131,31 @@ def init(self):
125131
return FAILED
126132

127133
def __initLogging(self):
128-
try:
129-
'''
130-
@Desc : 1. Initializes the logging for marvin and so provides
134+
'''
135+
@Name : __initLogging
136+
@Desc : 1. Initializes the logging for marvin and so provides
131137
various log features for automation run.
132138
2. Initializes all logs to be available under
133139
given Folder Path,where all test run logs
134140
are available for a given run.
135141
3. All logging like exception log,results, run info etc
136142
for a given test run are available under a given
137143
timestamped folder
138-
'''
144+
@Output : SUCCESS or FAILED
145+
'''
146+
try:
139147
log_obj = MarvinLog("CSLog")
140148
if log_obj is None:
141149
return FAILED
142150
else:
143151
ret = log_obj.\
144-
getLogs(self.__testModuleName,
152+
createLogs(self.__testModuleName,
145153
self.__parsedConfig.logger)
146154
if ret != FAILED:
147155
self.__logFolderPath = log_obj.getLogFolderPath()
148156
self.__tcRunLogger = log_obj.getLogger()
149-
return SUCCESS
157+
return SUCCESS
158+
return FAILED
150159
except Exception, e:
151160
print "\n Exception Occurred Under __initLogging " \
152161
":%s" % GetDetailExceptionInfo(e)
@@ -157,6 +166,7 @@ def __createTestClient(self):
157166
@Name : __createTestClient
158167
@Desc : Creates the TestClient during init
159168
based upon the parameters provided
169+
@Output: Returns SUCCESS or FAILED
160170
'''
161171
try:
162172
mgt_details = self.__parsedConfig.mgtSvr[0]
@@ -176,7 +186,12 @@ def __createTestClient(self):
176186
return FAILED
177187

178188
def __loadNewApiFromXml(self):
189+
'''
190+
@Desc: Kept for future usage
191+
Will enhance later.
192+
'''
179193
try:
194+
return SUCCESS
180195
if self.__loadApiFlag:
181196
apiLoadCfg = self.__parsedConfig.apiLoadCfg
182197
api_dst_dir = apiLoadCfg.ParsedApiDestFolder + "/cloudstackAPI"
@@ -189,7 +204,7 @@ def __loadNewApiFromXml(self):
189204
print "Failed to create folder %s, " \
190205
"due to %s" % (api_dst_dir,
191206
GetDetailExceptionInfo(e))
192-
exit(1)
207+
return FAILED
193208
mgt_details = self.__parsedConfig.mgtSvr[0]
194209
cg = CodeGenerator(api_dst_dir)
195210
if os.path.exists(api_spec_file):
@@ -206,6 +221,11 @@ def __loadNewApiFromXml(self):
206221
return FAILED
207222

208223
def __setTestDataPath(self):
224+
'''
225+
@Name : __setTestDataPath
226+
@Desc: Sets the TestData Path for tests to run
227+
@Output: Returns SUCCESS or FAILED
228+
'''
209229
try:
210230
if ((self.__parsedConfig.TestData is not None) and
211231
(self.__parsedConfig.TestData.Path is not None)):
@@ -217,14 +237,23 @@ def __setTestDataPath(self):
217237
return FAILED
218238

219239
def __deployDC(self):
240+
'''
241+
@Name : __deployDC
242+
@Desc : Deploy the DataCenter and returns accordingly.
243+
@Output : SUCCESS or FAILED
244+
'''
220245
try:
221-
'''
222-
Deploy the DataCenter and retrieves test client.
223-
'''
224-
deploy_obj = DeployDataCenters(self.__testClient,
246+
ret = SUCCESS
247+
if self.__deployFlag:
248+
deploy_obj = DeployDataCenters(self.__testClient,
225249
self.__parsedConfig,
226250
self.__tcRunLogger)
227-
return deploy_obj.deploy() if self.__deployFlag else FAILED
251+
ret = deploy_obj.deploy()
252+
if ret == SUCCESS:
253+
print "Deploy DC Successful"
254+
else:
255+
print "Deploy DC Failed"
256+
return ret
228257
except Exception, e:
229258
print "\n Exception Occurred Under __deployDC : %s" % \
230259
GetDetailExceptionInfo(e)

tools/marvin/marvin/marvinLog.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __setLogger(self):
6868
def __setLogHandler(self, log_file_path, log_format=None,
6969
log_level=logging.DEBUG):
7070
'''
71+
@Name : __setLogHandler
7172
@Desc: Adds the given Log handler to the current logger
7273
@Input: log_file_path: Log File Path as where to store the logs
7374
log_format : Format of log messages to be dumped
@@ -100,7 +101,8 @@ def __cleanPreviousLogs(self, logfolder_to_remove):
100101
@Input: logfolder_to_remove: Path of Log to remove
101102
'''
102103
try:
103-
os.rmdir(logfolder_to_remove)
104+
if os.path.isdir(logfolder_to_remove):
105+
os.rmdir(logfolder_to_remove)
104106
except Exception, e:
105107
print "\n Exception Occurred Under __cleanPreviousLogs :%s" % \
106108
GetDetailExceptionInfo(e)
@@ -131,21 +133,15 @@ def createLogs(self, test_module_name=None, log_cfg=None):
131133
@Output : SUCCESS\FAILED
132134
'''
133135
try:
134-
if log_cfg is None:
135-
print "\nInvalid Log Folder Configuration." \
136-
"Please Check Config File"
137-
return FAILED
138-
if test_module_name is None:
139-
temp_path = time.strftime("%b_%d_%Y_%H_%M_%S",
136+
temp_ts = time.strftime("%b_%d_%Y_%H_%M_%S",
140137
time.localtime())
138+
if test_module_name is None:
139+
temp_path = temp_ts
141140
else:
142-
temp_path = str(test_module_name.split(".py")[0])
141+
temp_path = str(test_module_name) + "__" + str(temp_ts)
143142

144-
if (('LogFolderPath' in log_cfg.__dict__.keys()) and
143+
if ((log_cfg is not None) and ('LogFolderPath' in log_cfg.__dict__.keys()) and
145144
(log_cfg.__dict__.get('LogFolderPath') is not None)):
146-
self.__cleanPreviousLogs(log_cfg.
147-
__dict__.
148-
get('LogFolderPath') + "/MarvinLogs")
149145
temp_dir = \
150146
log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
151147
else:

0 commit comments

Comments
 (0)