summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/controller/database/tables.py
blob: a7658f493519a8cd092524e05d7e004427a0ba82 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/usr/bin/python
# -*- coding: utf8 -*-
# author: wly
# date: 2015-07-29
# see license for license details
__version__ = ''' '''
from sqlalchemy import Column, Integer, String, Float, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from vstf.controller.database import constants as const

Base = declarative_base()


class TblScenarioInfo(Base):
    __tablename__ = "TblScenarioInfo"
    ScenarioID = Column(Integer, primary_key=True)
    ScenarioName = Column(String(const.SCENARIO_NAME_LEN), unique=True)
    FigurePath = Column(String(const.FIGURE_PATH_LEN))
    Description = Column(String(const.DESC_LEN))

    def __init__(self, ScenarioName, FigurePath, Description, **kwargs):
        """
        :param ScenarioName: name of the scenario, like Tn
        :param FigurePath: ??
        :param Description: desc of scenario table
        """
        self.ScenarioName = ScenarioName
        self.FigurePath = FigurePath
        self.Description = Description

    def __repr__(self):
        return "<User(ScenarioName='%s', FigurePath='%s', Description='%s')>" % (
            self.ScenarioName, self.FigurePath, self.Description)


class TblCaseInfo(Base):
    __tablename__ = "TblCaseInfo"
    CaseID = Column(Integer, primary_key=True)
    CaseTag = Column(String(const.CASE_TAG_LEN), unique=True)
    CaseName = Column(String(const.CASE_NAME_LEN), unique=True)
    ScenarioName = Column(String(const.SCENARIO_NAME_LEN))
    FigurePath = Column(String(const.FIGURE_PATH_LEN))
    Direction = Column(String(const.DIRECTION_LEN))
    Directiontag = Column(String(const.DIRECTION_LEN))
    Configure = Column(String(const.CONF_LEN))
    Description = Column(String(const.DESC_LEN))

    def __init__(self, CaseTag, CaseName,
                 ScenarioName, FigurePath, Direction, Directiontag,
                 Configure, Description, **kwargs):
        """
        :param CaseID: 
        :param CaseTag: ??
        :param CaseName: name of case, like tester-vm
        :param ScenarioName: name of scenario, like Tn
        :param FigurePath:
        :param Direction: the test direction, Tx or Rx
        :param Configure:
        :param Description: desc of table case info
        """
        # CaseID will auto builded by db
        self.CaseTag = CaseTag
        self.CaseName = CaseName
        self.ScenarioName = ScenarioName
        self.FigurePath = FigurePath
        self.Direction = Direction
        self.Directiontag = Directiontag
        self.Configure = Configure
        self.Description = Description

    def __repr__(self):
        return "<User(CaseTag='%s', CaseName='%s',ScenarioName='%s',FigurePath='%s', Direction='%s', \
            Directiontag='%s', Configure='%s', Description='%s')>" % (self.CaseTag, self.CaseName,
                                                                      self.ScenarioName, self.FigurePath,
                                                                      self.Direction, self.Directiontag, self.Configure,
                                                                      self.Description)


class TblHostInfo(Base):
    __tablename__ = "TblHostInfo"
    Index = Column(Integer, primary_key=True)
    TaskID = Column(Integer, ForeignKey('TblTaskList.TaskID'))
    HostName = Column(String(const.HOST_NAME_LEN))
    Server = Column(String(const.NORMAL_VAR_LEN1))
    CPU = Column(String(const.CPU_INFO_LEN))
    MEM = Column(String(const.NORMAL_VAR_LEN))
    NIC = Column(String(const.NORMAL_VAR_LEN))
    OS = Column(String(const.NORMAL_VAR_LEN))

    def __init__(self, TaskID, HostName, Server, CPU, MEM, NIC, OS, **kwargs):
        """table of host info
        """
        self.TaskID = TaskID
        self.HostName = HostName
        self.Server = Server
        self.CPU = CPU
        self.MEM = MEM
        self.NIC = NIC
        self.OS = OS

    def __repr__(self):
        return "<User(HostName='%s',  Server='%s', CPU='%s', MEM='%s', NIC='%s',\
         OS='%s')>" % (self.HostName, self.Server, self.CPU, self.MEM, self.NIC, self.OS)


class TblTaskList(Base):
    __tablename__ = "TblTaskList"
    TaskID = Column(Integer, primary_key=True)
    TaskName = Column(String(const.NORMAL_VAR_LEN1))
    Date = Column(String(const.NORMAL_VAR_LEN1))
    EXTInfo = Column(String(const.EXT_INFO_LEN))

    def __init__(self, TaskName, Date, EXTInfo="", **kwargs):
        """Table of task"""
        self.TaskName = TaskName
        self.Date = Date
        self.EXTInfo = EXTInfo

    def __repr__(self):
        return "<User(TaskID='%s', TaskName='%s', Date='%s', EXTInfo='%s')>" % (
            self.TaskID, self.TaskName, self.Date, self.EXTInfo)


class TblTestList(Base):
    __tablename__ = "TblTestList"
    TestID = Column(Integer, primary_key=True)
    TaskID = Column(Integer, ForeignKey('TblTaskList.TaskID'))
    CaseTag = Column(String(const.CASE_TAG_LEN))
    Protocol = Column(String(const.PROTOCOL_LEN))
    Provider = Column(String(const.PROVIDER_LEN))
    Type = Column(String(const.TYPE_LEN))
    Tools = Column(String(const.TOOLS_LEN))

    def __init__(self, taskid, casetag, protocol, provider, typ, tools, **kwargs):
        """Table of test"""
        self.TaskID = taskid
        self.CaseTag = casetag
        self.Protocol = protocol
        self.Provider = provider
        self.Type = typ
        self.Tools = tools

    def __repr__(self):
        return "<User(TaskID='%d', CaseTag='%s', Protocol='%s', Provider=%s, Type='%s', Tools='%s')>" % (
            self.TaskID, self.CaseTag, self.Protocol, self.Provider, self.Type, self.Tools)


class TblThroughput(Base):
    __tablename__ = "TblThroughput"
    Index = Column(Integer, primary_key=True)
    TestID = Column(Integer, ForeignKey('TblTestList.TestID'))
    AvgFrameSize = Column(Integer)
    OfferedLoad = Column(Float)
    PercentLoss = Column(Float)
    Bandwidth = Column(Float)
    MinimumLatency = Column(Float)
    MaximumLatency = Column(Float)
    AverageLatency = Column(Float)
    TxFrameCount = Column(Float)
    RxFrameCount = Column(Float)
    Duration = Column(Float)
    CPU = Column(Float)
    MppspGhz = Column(Float)

    def __init__(self, TestID, AvgFrameSize,
                 OfferedLoad, PercentLoss, Bandwidth,
                 MinimumLatency, MaximumLatency, AverageLatency,
                 TxFrameCount, RxFrameCount, Duration,
                 CPU, MppspGhz, **kwargs):
        """table of throughput"""
        self.TestID = TestID
        self.AvgFrameSize = AvgFrameSize
        self.OfferedLoad = OfferedLoad
        self.PercentLoss = PercentLoss
        self.Bandwidth = Bandwidth
        self.MinimumLatency = MinimumLatency
        self.MaximumLatency = MaximumLatency
        self.AverageLatency = AverageLatency
        self.TxFrameCount = TxFrameCount
        self.RxFrameCount = RxFrameCount
        self.Duration = Duration
        self.CPU = CPU
        self.MppspGhz = MppspGhz

    def __repr__(self):
        return "<User(TestID='%d', AvgFrameSize='%d', OfferedLoad='%f', \
                      PercentLoss='%f', MinimumLatency='%f', AverageLatency='%f', MaximumLatency='%f',\
                      TxFrameCount='%f', RxFrameCount='%f', Duration='%f', CPU='%f', MppspGhz='%f', \
                      Bandwidth='%f')>" % (self.TestID,
                                           self.AvgFrameSize, self.OfferedLoad, self.PercentLoss,
                                           self.MinimumLatency, self.AverageLatency, self.MaximumLatency,
                                           self.TxFrameCount,
                                           self.RxFrameCount, self.Duration, self.CPU, self.MppspGhz, self.Bandwidth)


class TblFrameloss(Base):
    __tablename__ = "TblFrameloss"
    Index = Column(Integer, primary_key=True)
    TestID = Column(Integer, ForeignKey('TblTestList.TestID'))
    AvgFrameSize = Column(Integer)
    OfferedLoad = Column(Float)
    PercentLoss = Column(Float)
    Bandwidth = Column(Float)
    MinimumLatency = Column(Float)
    MaximumLatency = Column(Float)
    AverageLatency = Column(Float)
    TxFrameCount = Column(Float)
    RxFrameCount = Column(Float)
    Duration = Column(Float)
    CPU = Column(Float)
    MppspGhz = Column(Float)

    def __init__(self, TestID, AvgFrameSize,
                 OfferedLoad, PercentLoss, Bandwidth,
                 MinimumLatency, MaximumLatency, AverageLatency,
                 TxFrameCount, RxFrameCount, Duration,
                 CPU, MppspGhz, **kwargs):
        """table of frameloss"""
        self.TestID = TestID
        self.AvgFrameSize = AvgFrameSize
        self.OfferedLoad = OfferedLoad
        self.PercentLoss = PercentLoss
        self.Bandwidth = Bandwidth
        self.MinimumLatency = MinimumLatency
        self.MaximumLatency = MaximumLatency
        self.AverageLatency = AverageLatency
        self.TxFrameCount = TxFrameCount
        self.RxFrameCount = RxFrameCount
        self.Duration = Duration
        self.CPU = CPU
        self.MppspGhz = MppspGhz

    def __repr__(self):
        return "<User(TestID='%d', AvgFrameSize='%d', OfferedLoad='%f', \
                      PercentLoss='%f', MinimumLatency='%f', AverageLatency='%f', MaximumLatency='%f',\
                      TxFrameCount='%f', RxFrameCount='%f', Duration='%f', CPU='%f', MppspGhz='%f', \
                      Bandwidth='%f')>" % (self.TestID,
                                           self.AvgFrameSize, self.OfferedLoad, self.PercentLoss,
                                           self.MinimumLatency, self.AverageLatency, self.MaximumLatency,
                                           self.TxFrameCount,
                                           self.RxFrameCount, self.Duration, self.CPU, self.MppspGhz, self.Bandwidth)


class TblLatency(Base):
    __tablename__ = "TblLatency"
    Index = Column(Integer, primary_key=True)
    TestID = Column(Integer, ForeignKey('TblTestList.TestID'))
    AvgFrameSize = Column(Integer)
    OfferedLoad = Column(Float)
    MinimumLatency = Column(Float)
    MaximumLatency = Column(Float)
    AverageLatency = Column(Float)

    def __init__(self, TestID, AvgFrameSize, OfferedLoad,
                 MinimumLatency, MaximumLatency, AverageLatency, **kwargs):
        """table of latency"""
        self.TestID = TestID
        self.AvgFrameSize = AvgFrameSize
        self.OfferedLoad = OfferedLoad
        self.MinimumLatency = MinimumLatency
        self.MaximumLatency = MaximumLatency
        self.AverageLatency = AverageLatency

    def __repr__(self):
        return "<User(TestID='%d', AvgFrameSize='%d', OfferedLoad='%f', \
                      MinimumLatency='%f', AverageLatency='%f', MaximumLatency='%f')>" % (self.TestID,
                                                                                          self.AvgFrameSize,
                                                                                          self.OfferedLoad,
                                                                                          self.MinimumLatency,
                                                                                          self.AverageLatency,
                                                                                          self.MaximumLatency)


class TblEXTInfo(Base):
    __tablename__ = "TblEXTInfo"
    Index = Column(Integer, primary_key=True)
    TaskID = Column(Integer)
    EXTName = Column(String(const.NORMAL_VAR_LEN))
    EXTContent = Column(String(const.DESC_LEN))
    Description = Column(String(const.NORMAL_VAR_LEN1))

    def __init__(self, TaskID, EXTName, EXTContent, Description, **kwargs):
        """table extern info"""
        self.TaskID = TaskID
        self.EXTName = EXTName
        self.EXTContent = EXTContent
        self.Description = Description

    def __repr__(self):
        return "<User(TaskID='%d', CodeType='%s', EXTContent='%s',Version='%s')>" % (
            self.TaskID, self.EXTName, self.EXTContent, self.Version)