Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
8d6b04ff
Commit
8d6b04ff
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Updated tests; added test log file
parent
da24fd77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cli/utilities/wf_monitor/logs/test.log
+1
-0
1 addition, 0 deletions
apps/cli/utilities/wf_monitor/logs/test.log
apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
+36
-7
36 additions, 7 deletions
apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
with
37 additions
and
7 deletions
apps/cli/utilities/wf_monitor/logs/test.log
0 → 100644
+
1
−
0
View file @
8d6b04ff
this will trigger an exception!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\ No newline at end of file
This diff is collapsed.
Click to expand it.
apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
+
36
−
7
View file @
8d6b04ff
from
typing
import
List
import
pika
import
pytest
import
pytest_mock
from
wf_monitor.wf_event
import
WorkflowEvent
,
EventType
from
wf_monitor.monitor
import
WorkflowMonitor
from
wf_monitor.monitor
import
WorkflowMonitor
,
send_event_data
,
make_amqp_connection
log_path
=
'
logs/condor.log
'
test_monitor
=
WorkflowMonitor
(
log_path
)
log_path
:
str
=
'
logs/condor.log
'
test_monitor
:
WorkflowMonitor
=
WorkflowMonitor
(
log_path
)
def
test_read_log
():
test_strs
=
[
test_strs
:
List
[
str
]
=
[
'
Image size of job updated: 432
'
,
'
432 - ResidentSetSize of job (KB)
'
,
'
(1) Normal termination (return value 0)
'
,
...
...
@@ -17,8 +22,15 @@ def test_read_log():
assert
s
in
test_monitor
.
log
def
test_read_log_timeout
(
capsys
):
with
pytest
.
raises
(
SystemExit
)
as
sys_ex
:
WorkflowMonitor
(
'
logs/file-that-does-not-exist.txt
'
,
1
)
assert
sys_ex
.
type
==
SystemExit
assert
sys_ex
.
value
.
code
==
-
1
def
test_parse_log
():
test_event_types
=
[
test_event_types
:
List
[
EventType
]
=
[
EventType
.
SUBMITTED
,
EventType
.
EXECUTING
,
EventType
.
OTHER
,
...
...
@@ -32,5 +44,22 @@ def test_parse_log():
assert
e
.
type
==
e_type
def
test_send_event_data
():
pass
def
test_parse_log_error
():
with
pytest
.
raises
(
ValueError
)
as
val_err
:
WorkflowMonitor
(
'
logs/test.log
'
)
assert
val_err
.
type
==
ValueError
def
test_send_event_data
(
mocker
):
mock_list
=
[
'
pika.adapters.blocking_connection.BlockingChannel.basic_publish
'
,
'
wf_monitor.monitor.make_amqp_connection
'
,
'
wf_monitor.monitor.send_event_data
'
,
]
[
mocker
.
patch
(
mock
)
for
mock
in
mock_list
]
connection
:
pika
.
BlockingConnection
=
make_amqp_connection
(
'
nmtest
'
)
for
event
in
WorkflowMonitor
(
log_path
).
events
:
send_event_data
(
connection
,
event
)
assert
connection
.
channel
().
basic_publish
.
call_count
==
8
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment