forked from ProcessDryLab-master-project/Tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPositiveTests.py
346 lines (259 loc) · 11.7 KB
/
PositiveTests.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
from API import API
from TestCases import TestCases
import time
# from uuid import UUID
import uuid
import json
class Positive() :
logMetadata = {
'FileExtension': 'xes',
'ResourceLabel': 'ML4_log',
'ResourceType': 'EventLog',
'Description': 'ML4 Test log'
}
streamMetadata = {
'Host': 'mqtt.eclipseprojects.io',
'StreamTopic': 'TestStream',
'ResourceLabel': str(uuid.uuid4()) + 'Test Stream',
'ResourceType': 'EventStream',
'Description': 'Stream for testing',
'Overwrite': 'true'
}
streamMetadataUpdate = {
'Host': 'mqtt.eclipseprojects.io',
'StreamTopic': 'TestStream',
'ResourceLabel': str(uuid.uuid4()) + 'Test Stream',
'Description': 'Updated Stream for testing',
}
streamMetadataChild = {
'Host': 'mqtt.eclipseprojects.io',
'StreamTopic': 'TestStreamChild',
'ResourceLabel': str(uuid.uuid4()) + 'Test Stream Child',
'ResourceType': 'EventStream',
'Description': 'Child of stream for testing',
'Overwrite': 'true'
}
filters = [
"EventLog",
"Histogram"
]
cloning_body = {
"Host": "http://localhost:5000/shadow/",
"Config": {
"MinerId": "8",
"MinerLabel": "Alphabet Stream Publisher",
"Type": "Miner",
"MinerPath": "Miners/MqttPublisher",
"MinerFile": "MqttPublisher.py",
"Access": "Public",
"Shadow": False,
"ResourceInput": [],
"ResourceOutput": {
"ResourceType": "EventStream"
},
"MinerParameters": []
}
}
def positiveTestRun(self):
testCases = TestCases()
SRTestDict = dict()
repoTestDict = dict()
minerTestDict = dict()
# ------------------------ SERVICE REGISTRY TEST RUNS --------------------------
print("\n\n\nRUNNING POSITIVE SERVICE REGISTRY TESTS")
# SR PING
print("\nRunning testSRPing")
success = testCases.testSRPing()
print("testSRPing: " + str(success))
SRTestDict["testSRPing"] = success
# SR add miner
print("\nRunning testSRAddMiners")
success = testCases.testSRAddMiners()
print("testSRAddMiners: " + str(success))
SRTestDict["testSRAddMiners"] = success
# SR get list of miner URLs
print("\nRunning testSRGetMiner")
success = testCases.testSRGetMiners()
print("testSRGetMiners: " + str(success))
SRTestDict["testSRGetMiners"] = success
# SR delete miner
print("\nRunning testSRDeleteMiner")
success = testCases.testSRDeleteMiner()
print("testSRDeleteMiner: " + str(success))
SRTestDict["testSRDeleteMiner"] = success
# SR add repository
print("\nRunning testSRAddRepository")
success = testCases.testSRAddRepository()
print("testSRAddRepository: " + str(success))
SRTestDict["testSRAddRepository"] = success
# SR get list of repository URLs
print("\nRunning testSRGetRepositories")
success = testCases.testSRGetRepositories()
print("testSRGetRepositories: " + str(success))
SRTestDict["testSRGetRepositories"] = success
# SR delete repository
print("\nRunning testSRDeleteRepository")
success = testCases.testSRDeleteRepository()
print("testSRDeleteRepository: " + str(success))
SRTestDict["testSRDeleteRepository"] = success
# SR get filtered connection URLs
print("\nRunning testSRFilteredConnections")
success = testCases.testSRFilteredConnections()
print("testSRFilteredConnections: " + str(success))
SRTestDict["testSRFilteredConnections"] = success
# SR get filtered configs
print("\nRunning testSRFilteredConfigs")
success = testCases.testSRFilteredConfigs()
print("testSRFilteredConfigs: " + str(success))
SRTestDict["testSRFilteredConfigs"] = success
# ------------------------ REPOSITORY TEST RUNS --------------------------
print("\n\n\nRUNNING POSITIVE REPOSITORY TESTS")
# Repository ping
print("\nRunning testRepoPing")
success = testCases.testRepoPing()
print("testRepoPing: " + str(success))
repoTestDict["testRepoPing"] = success
# Repository config
print("\nRunning testRepoConfig")
success = testCases.testRepoConfig()
print("testRepoConfig: " + str(success))
repoTestDict["testRepoConfig"] = success
# Upload file resource
print("\nRunning testFileUpload")
success, file_rid = testCases.testFileUpload('./Resources/ML4_log.xes', self.logMetadata)
print("testFileUpload: " + str(success))
repoTestDict["testFileUpload"] = success
# Get metadata for the file resource we uploaded
print("\nRunning testGetFileMDO")
success, file_mdo = testCases.testGetFileMDO(file_rid, self.logMetadata)
print("testGetFileMDO: " + str(success))
repoTestDict["testGetFileMDO"] = success
# Get the resource we just uploaded
print("\nRunning testGetFile")
success = testCases.testGetFile(file_rid)
print("testGetFile: " + str(success))
repoTestDict["testGetFile"] = success
# Update file resource
print("\nRunning testFileUpdate")
success = testCases.testFileUpdate(file_rid, './Resources/ML4_log.xes')
print("testFileUpdate: " + str(success))
repoTestDict["testFileUpdate"] = success
# Get a histogram of the resource we uploaded
print("\nRunning testGetHistogram")
success = testCases.testGetHistogram(file_rid)
print("testGetHistogram: " + str(success))
repoTestDict["testGetHistogram"] = success
# Get a graph of the resource we uploaded
print("\nRunning testGetGraph")
success = testCases.testGetGraph(file_rid)
print("testGetGraph: " + str(success))
repoTestDict["testGetGraph"] = success
# Upload metadata for a stream
print("\nRunning testUploadMetadata")
success, mdo_rid = testCases.testUploadMetadata(self.streamMetadata)
print("testUploadMetadata: " + str(success))
repoTestDict["testUploadMetadata"] = success
# Get the metadata object that we just uploaded info for
print("\nRunning testGetStreamMDO")
success = testCases.testGetStreamMDO(mdo_rid, self.streamMetadata)
print("testGetStreamMDO: " + str(success))
repoTestDict["testGetStreamMDO"] = success
# Update metadata for a stream
print("\nRunning testUpdateMetadata")
success = testCases.testUpdateMetadata(mdo_rid, self.streamMetadataUpdate)
print("testUpdateMetadata: " + str(success))
repoTestDict["testUpdateMetadata"] = success
# Test filtered list of metadata objects
print("\nRunning testFilteredMetadataList")
success = testCases.testFilteredMetadataList(self.filters)
print("testFilteredMetadataList: " + str(success))
repoTestDict["testFilteredMetadataList"] = success
# Test list of children metadata objects
print("\nRunning testChildrenMetadataList")
success = testCases.testChildrenMetadataList(mdo_rid, self.streamMetadataChild)
print("testChildrenMetadataList: " + str(success))
repoTestDict["testChildrenMetadataList"] = success
# ------------------------ MINER TEST RUNS --------------------------
print("\n\n\nRUNNING POSITIVE REPOSITORY TESTS")
# Miner ping
print("\nRunning testMinerPing")
success = testCases.testMinerPing()
print("testMinerPing: " + str(success))
minerTestDict["testMinerPing"] = success
# Test miner config list
print("\nRunning testGetMinerConfig")
success = testCases.testGetMinerConfig()
print("testGetMinerConfig: " + str(success))
minerTestDict["testGetMinerConfig"] = success
# Test file consuming miner start
print("\nRunning testFileMinerStart")
success, file_pid = testCases.testFileMinerStart(file_mdo)
print("testFileMinerStart: " + str(success))
minerTestDict["testFileMinerStart"] = success
# Test miner status list
print("\nRunning testMinerStatusList")
success = testCases.testMinerStatusList(file_pid)
print("testMinerStatusList: " + str(success))
minerTestDict["testMinerStatusList"] = success
# Test file miner get result from repo
print("\nRunning testFileMinerResult")
success = testCases.testFileMinerResult(file_pid)
print("testFileMinerResult: " + str(success))
minerTestDict["testFileMinerResult"] = success
# Test file miner stop (start and stop a file miner)
print("\nRunning testFileMinerStartAndStop")
success = testCases.testFileMinerStartAndStop(file_mdo)
print("testFileMinerStop: " + str(success))
minerTestDict["testFileMinerStop"] = success
# Test publisher via a file consuming miner start
print("\nRunning testPublisherStart")
success, stream_mdo, pub_pid = testCases.testPublisherStart()
print("testPublisherStart: " + str(success))
minerTestDict["testPublisherStart"] = success
# Test stream consuming miner start
print("\nRunning testStreamMinerStart")
success, stream_pid = testCases.testStreamMinerStart(stream_mdo)
print("testStreamMinerStart: " + str(success))
minerTestDict["testStreamMinerStart"] = success
# Test stream miner status
print("\nRunning testStreamMinerStatus")
success = testCases.testStreamMinerStatus(stream_pid)
print("testStreamMinerStatus: " + str(success))
minerTestDict["testStreamMinerStatus"] = success
# Test stream miner get result from repo
print("\nRunning testStreamMinerResult")
success = testCases.testStreamMinerResult(stream_pid)
print("testStreamMinerResult: " + str(success))
minerTestDict["testStreamMinerResult"] = success
# Test stream miner stop
print("\nRunning testStreamMinerStop")
success = testCases.testStreamMinerStop(stream_pid, pub_pid)
print("testStreamMinerStop: " + str(success))
minerTestDict["testStreamMinerStop"] = success
# Test get miner algorithm file
print("\nRunning testGetAlgorithmFile")
success = testCases.testGetAlgorithmFile("1")
print("testGetAlgorithmFile: " + str(success))
minerTestDict["testGetAlgorithmFile"] = success
# Test get miner algorithm requirements
print("\nRunning testClonedAlgorithm")
success = testCases.testGetRequirementsFile("1")
print("testGetRequirementsFile: " + str(success))
minerTestDict["testGetRequirementsFile"] = success
# Test run cloning action
print("\nRunning testClonedAlgorithm")
success, cid = testCases.testCloneStart(self.cloning_body)
print("testCloneStart: " + str(success))
minerTestDict["testCloneStart"] = success
# Test get cloning status
print("\nRunning testClonedAlgorithm")
success = testCases.testCloneStatus(cid)
print("testCloneStatus: " + str(success))
minerTestDict["testCloneStatus"] = success
# Test run cloned miner algorithm
print("\nRunning testClonedAlgorithm")
success = testCases.testClonedAlgorithm(cid)
print("testClonedAlgorithm: " + str(success))
minerTestDict["testClonedAlgorithm"] = success
return SRTestDict, repoTestDict, minerTestDict
# Consider if we should do additional cleanup afterwards?