-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput.txt
More file actions
530 lines (490 loc) · 21.5 KB
/
output.txt
File metadata and controls
530 lines (490 loc) · 21.5 KB
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
Lab 11 - Queryable Job History API with Tests
Outputs captured during setup, execution, testing, verification, and troubleshooting.
================================================================================
Update package manager
================================================================================
Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:3 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:4 http://us-east-1.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:5 http://us-east-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [812 kB]
Get:6 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [621 kB]
Get:7 http://us-east-1.ec2.archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [514 kB]
Fetched 2,325 kB in 3s (774 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
19 packages can be upgraded. Run 'apt list --upgradable' to see them.
================================================================================
Install Python and pip
================================================================================
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.12.3-0ubuntu2).
The following additional packages will be installed:
python3-dev python3-pkg-resources python3-setuptools python3-wheel
python3.12-venv
Suggested packages:
python-setuptools-doc
The following NEW packages will be installed:
python3-dev python3-pip python3-setuptools python3-venv python3-wheel
python3.12-venv
The following packages will be upgraded:
python3-pkg-resources
1 upgraded, 6 newly installed, 0 to remove and 19 not upgraded.
Need to get 9,412 kB of archives.
After this operation, 41.3 MB of additional disk space will be used.
Fetched 9,412 kB in 2s (4,731 kB/s)
Setting up python3-pkg-resources (68.1.2-2ubuntu1.1) ...
Setting up python3-setuptools (68.1.2-2ubuntu1.1) ...
Setting up python3-wheel (0.42.0-2) ...
Setting up python3-pip (24.0+dfsg-1ubuntu1) ...
Setting up python3.12-venv (3.12.3-1ubuntu0.3) ...
Setting up python3-venv (3.12.3-0ubuntu2) ...
Setting up python3-dev (3.12.3-0ubuntu2) ...
Processing triggers for man-db (2.12.0-4build2) ...
================================================================================
Create project directory
================================================================================
/home/toor/job-history-api
================================================================================
Create virtual environment
================================================================================
(venv) toor@ip-172-31-10-198:~/job-history-api$
================================================================================
Install dependencies
================================================================================
Collecting flask
Downloading flask-3.1.0-py3-none-any.whl.metadata (2.7 kB)
Collecting flask-sqlalchemy
Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl.metadata (3.4 kB)
Collecting pytest
Downloading pytest-8.3.5-py3-none-any.whl.metadata (7.6 kB)
Collecting pytest-flask
Downloading pytest_flask-1.3.0-py3-none-any.whl.metadata (14 kB)
Collecting requests
Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting pytest-cov
Downloading pytest_cov-6.0.0-py3-none-any.whl.metadata (27 kB)
Collecting blinker>=1.9.0
Collecting click>=8.1.3
Collecting itsdangerous>=2.2.0
Collecting jinja2>=3.1.2
Collecting markupsafe>=2.1.1
Collecting werkzeug>=3.1
Collecting sqlalchemy>=2.0.16
Collecting iniconfig
Collecting packaging
Collecting pluggy<2,>=1.5
Collecting charset-normalizer<4,>=2
Collecting idna<4,>=2.5
Collecting urllib3<3,>=1.21.1
Collecting certifi>=2017.4.17
Collecting coverage>=7.5
Collecting greenlet>=1
Downloading flask-3.1.0-py3-none-any.whl (102 kB)
Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl (25 kB)
Downloading pytest-8.3.5-py3-none-any.whl (343 kB)
Downloading pytest_flask-1.3.0-py3-none-any.whl (13 kB)
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
Downloading pytest_cov-6.0.0-py3-none-any.whl (22 kB)
Downloading sqlalchemy-2.0.38-cp312-cp312-manylinux_2_17_x86_64.whl (3.3 MB)
Downloading coverage-7.6.10-cp312-cp312-manylinux1_x86_64.whl (239 kB)
Downloading greenlet-3.1.1-cp312-cp312-manylinux_2_24_x86_64.whl (597 kB)
Installing collected packages: urllib3, pluggy, packaging, markupsafe, itsdangerous, iniconfig, idna, greenlet, coverage, click, charset-normalizer, certifi, blinker, werkzeug, sqlalchemy, requests, pytest, jinja2, pytest-cov, flask, flask-sqlalchemy, pytest-flask
Successfully installed blinker-1.9.0 certifi-2025.1.31 charset-normalizer-3.4.1 click-8.1.8 coverage-7.6.10 flask-3.1.0 flask-sqlalchemy-3.1.1 greenlet-3.1.1 idna-3.10 iniconfig-2.1.0 itsdangerous-2.2.0 jinja2-3.1.5 markupsafe-3.0.2 packaging-24.2 pluggy-1.5.0 pytest-8.3.5 pytest-cov-6.0.0 pytest-flask-1.3.0 requests-2.32.3 sqlalchemy-2.0.38 urllib3-2.3.0 werkzeug-3.1.3
================================================================================
Project Structure
================================================================================
.:
app populate_data.py requirements.txt run.py tests venv
./app:
__init__.py config.py models.py routes.py
./tests:
__init__.py test_api.py
================================================================================
Step 4: Run Tests
================================================================================
=================================================== test session starts ===================================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0 -- /home/toor/job-history-api/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/toor/job-history-api
plugins: cov-6.0.0, flask-1.3.0
collected 13 items
tests/test_api.py::test_create_job PASSED [ 7%]
tests/test_api.py::test_get_all_jobs PASSED [ 15%]
tests/test_api.py::test_get_job_by_id PASSED [ 23%]
tests/test_api.py::test_get_nonexistent_job PASSED [ 30%]
tests/test_api.py::test_update_job PASSED [ 38%]
tests/test_api.py::test_filter_by_status PASSED [ 46%]
tests/test_api.py::test_filter_by_environment PASSED [ 53%]
tests/test_api.py::test_filter_by_user PASSED [ 61%]
tests/test_api.py::test_filter_by_job_name PASSED [ 69%]
tests/test_api.py::test_multiple_filters PASSED [ 76%]
tests/test_api.py::test_get_statistics PASSED [ 84%]
tests/test_api.py::test_filter_by_start_date PASSED [ 92%]
tests/test_api.py::test_filter_by_end_date PASSED [100%]
==================================================== 13 passed in 1.84s ====================================================
================================================================================
Step 4: Run Tests
================================================================================
=================================================== test session starts ===================================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0
rootdir: /home/toor/job-history-api
plugins: cov-6.0.0, flask-1.3.0
collected 13 items
tests/test_api.py ............. [100%]
---------- coverage: platform linux, python 3.12.3-final-0 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------
app/__init__.py 12 0 100%
app/config.py 9 0 100%
app/models.py 18 0 100%
app/routes.py 77 8 90% 28, 35, 42, 82-83, 109, 114, 130
-----------------------------------------------
TOTAL 116 8 93%
==================================================== 13 passed in 2.11s ====================================================
================================================================================
Step 4: Run Tests
================================================================================
=================================================== test session starts ===================================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0 -- /home/toor/job-history-api/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/toor/job-history-api
plugins: cov-6.0.0, flask-1.3.0
collected 1 item
tests/test_api.py::test_filter_by_status PASSED [100%]
==================================================== 1 passed in 0.43s =====================================================
================================================================================
Step 1: Start the Application
================================================================================
Created sample job history entries
================================================================================
Step 1: Start the Application
================================================================================
* Serving Flask app 'app'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5000
* Running on http://172.31.10.198:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 482-119-763
================================================================================
Create a new job
================================================================================
{
"duration": null,
"end_time": null,
"environment": "dev",
"error_message": null,
"id": 28,
"job_name": "test-job",
"start_time": "2026-04-12T18:26:41.214903",
"status": "running",
"user": "testuser"
}
================================================================================
Get all jobs
================================================================================
[
{
"duration": null,
"end_time": null,
"environment": "dev",
"error_message": null,
"id": 28,
"job_name": "test-job",
"start_time": "2026-04-12T18:26:41.214903",
"status": "running",
"user": "testuser"
},
{
"duration": 541,
"end_time": "2026-04-12T15:21:59.940318",
"environment": "prod",
"error_message": null,
"id": 11,
"job_name": "backup-database",
"start_time": "2026-04-12T15:12:58.940318",
"status": "success",
"user": "admin"
},
{
"duration": null,
"end_time": null,
"environment": "staging",
"error_message": null,
"id": 7,
"job_name": "run-tests",
"start_time": "2026-04-12T12:46:31.940318",
"status": "running",
"user": "jenkins"
},
{
"duration": 118,
"end_time": "2026-04-12T10:35:07.940318",
"environment": "prod",
"error_message": "Connection timeout",
"id": 18,
"job_name": "deploy-app",
"start_time": "2026-04-12T10:33:09.940318",
"status": "failed",
"user": "devops"
},
{
"duration": 924,
"end_time": "2026-04-11T22:11:30.940318",
"environment": "dev",
"error_message": null,
"id": 5,
"job_name": "cleanup-logs",
"start_time": "2026-04-11T21:56:06.940318",
"status": "success",
"user": "admin"
}
]
================================================================================
Filter by status
================================================================================
[
{
"duration": 541,
"end_time": "2026-04-12T15:21:59.940318",
"environment": "prod",
"error_message": null,
"id": 11,
"job_name": "backup-database",
"start_time": "2026-04-12T15:12:58.940318",
"status": "success",
"user": "admin"
},
{
"duration": 924,
"end_time": "2026-04-11T22:11:30.940318",
"environment": "dev",
"error_message": null,
"id": 5,
"job_name": "cleanup-logs",
"start_time": "2026-04-11T21:56:06.940318",
"status": "success",
"user": "admin"
},
{
"duration": 681,
"end_time": "2026-04-10T09:17:33.940318",
"environment": "staging",
"error_message": null,
"id": 22,
"job_name": "run-tests",
"start_time": "2026-04-10T09:06:12.940318",
"status": "success",
"user": "jenkins"
}
]
================================================================================
Filter by environment
================================================================================
[
{
"duration": 541,
"end_time": "2026-04-12T15:21:59.940318",
"environment": "prod",
"error_message": null,
"id": 11,
"job_name": "backup-database",
"start_time": "2026-04-12T15:12:58.940318",
"status": "success",
"user": "admin"
},
{
"duration": 118,
"end_time": "2026-04-12T10:35:07.940318",
"environment": "prod",
"error_message": "Connection timeout",
"id": 18,
"job_name": "deploy-app",
"start_time": "2026-04-12T10:33:09.940318",
"status": "failed",
"user": "devops"
},
{
"duration": null,
"end_time": null,
"environment": "prod",
"error_message": null,
"id": 14,
"job_name": "cleanup-logs",
"start_time": "2026-04-09T19:55:28.940318",
"status": "running",
"user": "admin"
}
]
================================================================================
Get statistics
================================================================================
{
"environment_counts": {
"dev": 10,
"prod": 9,
"staging": 9
},
"status_counts": {
"failed": 8,
"running": 9,
"success": 11
}
}
================================================================================
Update job status
================================================================================
{
"duration": -39373031,
"end_time": "2024-01-15T10:30:00",
"environment": "staging",
"error_message": null,
"id": 1,
"job_name": "deploy-app",
"start_time": "2025-04-12T17:57:11.940318",
"status": "success",
"user": "jenkins"
}
================================================================================
Filter by user
================================================================================
[
{
"duration": 541,
"end_time": "2026-04-12T15:21:59.940318",
"environment": "prod",
"error_message": null,
"id": 11,
"job_name": "backup-database",
"start_time": "2026-04-12T15:12:58.940318",
"status": "success",
"user": "admin"
},
{
"duration": 924,
"end_time": "2026-04-11T22:11:30.940318",
"environment": "dev",
"error_message": null,
"id": 5,
"job_name": "cleanup-logs",
"start_time": "2026-04-11T21:56:06.940318",
"status": "success",
"user": "admin"
},
{
"duration": null,
"end_time": null,
"environment": "prod",
"error_message": null,
"id": 14,
"job_name": "cleanup-logs",
"start_time": "2026-04-09T19:55:28.940318",
"status": "running",
"user": "admin"
}
]
================================================================================
Filter by job name
================================================================================
[
{
"duration": 541,
"end_time": "2026-04-12T15:21:59.940318",
"environment": "prod",
"error_message": null,
"id": 11,
"job_name": "backup-database",
"start_time": "2026-04-12T15:12:58.940318",
"status": "success",
"user": "admin"
},
{
"duration": 456,
"end_time": "2026-04-09T07:33:18.940318",
"environment": "dev",
"error_message": "Permission denied",
"id": 9,
"job_name": "backup-database",
"start_time": "2026-04-09T07:25:42.940318",
"status": "failed",
"user": "devops"
}
]
================================================================================
Filter by date range
================================================================================
[]
================================================================================
Step 3: Verify Test Coverage
================================================================================
=================================================== test session starts ===================================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0 -- /home/toor/job-history-api/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/toor/job-history-api
plugins: cov-6.0.0, flask-1.3.0
collected 13 items
tests/test_api.py::test_create_job PASSED [ 7%]
tests/test_api.py::test_get_all_jobs PASSED [ 15%]
tests/test_api.py::test_get_job_by_id PASSED [ 23%]
tests/test_api.py::test_get_nonexistent_job PASSED [ 30%]
tests/test_api.py::test_update_job PASSED [ 38%]
tests/test_api.py::test_filter_by_status PASSED [ 46%]
tests/test_api.py::test_filter_by_environment PASSED [ 53%]
tests/test_api.py::test_filter_by_user PASSED [ 61%]
tests/test_api.py::test_filter_by_job_name PASSED [ 69%]
tests/test_api.py::test_multiple_filters PASSED [ 76%]
tests/test_api.py::test_get_statistics PASSED [ 84%]
tests/test_api.py::test_filter_by_start_date PASSED [ 92%]
tests/test_api.py::test_filter_by_end_date PASSED [100%]
---------- coverage: platform linux, python 3.12.3-final-0 -----------
Coverage HTML written to dir htmlcov
==================================================== 13 passed in 2.20s ====================================================
================================================================================
Step 3: Verify Test Coverage
================================================================================
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
================================================================================
Check database file creation
================================================================================
-rw-rw-r-- 1 toor toor 12K Apr 12 18:26 job_history.db
================================================================================
Check project files
================================================================================
./app/__init__.py
./app/config.py
./app/models.py
./app/routes.py
./job_history.db
./populate_data.py
./requirements.txt
./run.py
./tests/__init__.py
./tests/test_api.py
================================================================================
Import errors
================================================================================
Requirement already satisfied: Flask in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 1)) (3.1.0)
Requirement already satisfied: Flask-SQLAlchemy in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 2)) (3.1.1)
Requirement already satisfied: pytest in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 3)) (8.3.5)
Requirement already satisfied: pytest-flask in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 4)) (1.3.0)
Requirement already satisfied: requests in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 5)) (2.32.3)
Requirement already satisfied: pytest-cov in ./venv/lib/python3.12/site-packages (from -r requirements.txt (line 6)) (6.0.0)
================================================================================
Tests fail with 404
================================================================================
18: app.register_blueprint(api)
================================================================================
Filter returns no results
================================================================================
28
================================================================================
Flask app not starting
================================================================================
tcp LISTEN 0 128 0.0.0.0:5000 0.0.0.0:* users:(("python3",pid=6124,fd=6),("python3",pid=6122,fd=6))