Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
c93ab2db
Commit
c93ab2db
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
pep8
parent
ce6dcfce
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
inventory_provider/tasks/monitor.py
+5
-2
5 additions, 2 deletions
inventory_provider/tasks/monitor.py
test/test_job_routes.py
+21
-14
21 additions, 14 deletions
test/test_job_routes.py
with
26 additions
and
16 deletions
inventory_provider/tasks/monitor.py
+
5
−
2
View file @
c93ab2db
...
...
@@ -10,9 +10,12 @@ import logging
import
os
import
queue
import
threading
from
redis.exceptions
import
RedisError
from
inventory_provider
import
config
,
environment
from
inventory_provider.tasks.worker
import
app
from
inventory_provider.tasks.common
import
get_current_redis
,
_get_redis
from
inventory_provider.tasks.common
import
_get_redis
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -35,7 +38,7 @@ def _save_proc(db_queue, params, dbid):
while
True
:
try
:
_save_events
(
_get_redis
(
config
=
params
,
dbid
=
dbid
),
db_queue
)
except
:
except
RedisError
:
logger
.
exception
(
'
redis i/o exception, reconnecting
'
)
# TODO: do something to terminate the process ...?
...
...
This diff is collapsed.
Click to expand it.
test/test_job_routes.py
+
21
−
14
View file @
c93ab2db
...
...
@@ -256,22 +256,29 @@ def test_latchdb(client, mocked_redis):
jsonschema
.
validate
(
latch
,
DB_LATCH_SCHEMA
)
TEST_EVENTS
=
{
'
joblog:AAAA:task-aaa
'
:
{
'
type
'
:
'
task-aaaa
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
999
},
'
joblog:AAAB:task-infox
'
:
{
'
type
'
:
'
task-infox
'
,
'
uuid
'
:
'
AAAB
'
,
'
clock
'
:
999
},
'
joblog:BBBB:task-info:99
'
:
{
'
type
'
:
'
task-info
'
,
'
uuid
'
:
'
BBBB
'
,
'
clock
'
:
99
},
'
joblog:BBBB:task-info:999
'
:
{
'
type
'
:
'
task-info
'
,
'
uuid
'
:
'
BBBB
'
,
'
clock
'
:
999
},
'
joblog:AAAA:task-warning:88
'
:
{
'
type
'
:
'
task-warning
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
88
},
'
joblog:AAAA:task-warning:888
'
:
{
'
type
'
:
'
task-warning
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
888
},
'
joblog:AAAA:task-error:77
'
:
{
'
type
'
:
'
task-error
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
77
},
'
joblog:AAAA:task-error:777
'
:
{
'
type
'
:
'
task-error
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
777
}
}
def
test_job_log
(
client
):
test_events
=
{
'
joblog:AAAA:task-aaa
'
:
{
'
type
'
:
'
task-aaaa
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
999
},
'
joblog:AAAB:task-infox
'
:
{
'
type
'
:
'
task-infox
'
,
'
uuid
'
:
'
AAAB
'
,
'
clock
'
:
999
},
'
joblog:BBBB:task-info:99
'
:
{
'
type
'
:
'
task-info
'
,
'
uuid
'
:
'
BBBB
'
,
'
clock
'
:
99
},
'
joblog:BBBB:task-info:999
'
:
{
'
type
'
:
'
task-info
'
,
'
uuid
'
:
'
BBBB
'
,
'
clock
'
:
999
},
'
joblog:AAAA:task-warning:88
'
:
{
'
type
'
:
'
task-warning
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
88
},
'
joblog:AAAA:task-warning:888
'
:
{
'
type
'
:
'
task-warning
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
888
},
'
joblog:AAAA:task-error:77
'
:
{
'
type
'
:
'
task-error
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
77
},
'
joblog:AAAA:task-error:777
'
:
{
'
type
'
:
'
task-error
'
,
'
uuid
'
:
'
AAAA
'
,
'
clock
'
:
777
}
}
db
=
backend_db
()
for
k
,
v
in
TEST_EVENTS
.
items
():
for
k
,
v
in
test_events
.
items
():
db
[
k
]
=
json
.
dumps
(
v
)
rv
=
client
.
post
(
...
...
@@ -279,4 +286,4 @@ def test_job_log(client):
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
result
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
assert
len
(
result
.
keys
())
==
3
# TODO: make a proper test
\ No newline at end of file
assert
len
(
result
.
keys
())
==
3
# TODO: make a proper test
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