forked from Kumar-Patil/AutomationTool
/
TestCaseLibrary.py
74 lines (67 loc) · 3.56 KB
/
TestCaseLibrary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
import sys
from robot.api import logger
import os
from Util import Util
from array import array
from sys import getsizeof
class TestCaseLibrary:
def __init__(self):
self._result = "success"
def checkBoundaryMeterIsRunning(self):
util = Util()
return util.checkBoundaryMeterIsRunning()
def isPluginStarted(self):
bmcUtil = Util()
isPluginStarted = ""
bmcPluginName = bmcUtil.readPluginName()
bmcIsRpcORStdout = bmcUtil.readLocalAppVariableFile("BMC_TYPE_OF_OUTPUT")
bmcIsRpcORStdout = bmcUtil.removeDoubleQuotas(bmcIsRpcORStdout)
if bmcIsRpcORStdout == "stdout":
bmcFileData = bmcUtil.readVagrantStdoutFile(bmcPluginName)
bmcMsg = bmcUtil.readLocalAppVariableFile("BMC_PLUGIN_STARTED_MSG")
bmcMsg = bmcUtil.removeDoubleQuotas(bmcMsg)
isPluginStarted = bmcUtil.serchSubstring(bmcFileData, bmcMsg)
else:
bmcFileData = bmcUtil.readVagrantRPCLogFile(bmcPluginName)
bmcMsg = bmcUtil.readLocalAppVariableFile("BMC_PLUGIN_STARTED_MSG")
bmcMsg = bmcUtil.removeDoubleQuotas(bmcMsg)
isPluginStarted = bmcUtil.serchSubstring(bmcFileData, bmcMsg)
return isPluginStarted
def isConnectionEstablished(self):
bmcUtil = Util()
bmcPluginName = bmcUtil.readPluginName()
bmcIsRpcORStdout = bmcUtil.readLocalAppVariableFile("BMC_TYPE_OF_OUTPUT")
bmcIsRpcORStdout = bmcUtil.removeDoubleQuotas(bmcIsRpcORStdout)
if bmcIsRpcORStdout == "stdout":
bmcfileData = bmcUtil.readVagrantStdoutFile(bmcPluginName)
bmcMsg = bmcUtil.readLocalAppVariableFile("BMC_ERROR_MSG")
bmcMsg = bmcUtil.removeDoubleQuotas(bmcMsg)
bmcIsConnectionEstablished = bmcUtil.serchSubstring(bmcfileData, bmcMsg)
else:
bmcfileData = bmcUtil.readVagrantRPCLogFile(bmcPluginName)
bmcMsg = bmcUtil.readLocalAppVariableFile("BMC_ERROR_MSG")
bmcMsg = bmcUtil.removeDoubleQuotas(bmcMsg)
bmcIsConnectionEstablished = bmcUtil.serchSubstring(bmcfileData, bmcMsg)
return bmcIsConnectionEstablished
def totalNumberOfMetrics(self,bmcListOfMetrics):
bmcUtil = Util()
bmcPluginName = bmcUtil.readPluginName()
bmcIsRpcORStdout = bmcUtil.readLocalAppVariableFile("BMC_TYPE_OF_OUTPUT")
bmcIsRpcORStdout = bmcUtil.removeDoubleQuotas(bmcIsRpcORStdout)
bmcListOfMetricsArray = []
bmcMetricsCount = []
bmcListOfMetricsArray = bmcListOfMetrics.split(",")
if bmcIsRpcORStdout == "stdout":
bmcfileData = bmcUtil.readVagrantStdoutFile(bmcPluginName)
for name in bmcListOfMetricsArray:
bmcIsFound = bmcUtil.serchSubstring(bmcfileData, name)
if bmcIsFound == "yes":
bmcMetricsCount.append(bmcIsFound)
else:
bmcfileData = bmcUtil.readVagrantRPCLogFile(bmcPluginName)
for name in bmcListOfMetricsArray:
bmcIsFound = bmcUtil.serchSubstring(bmcfileData, name)
if bmcIsFound == "yes":
bmcMetricsCount.append(bmcIsFound)
return len(bmcMetricsCount)