File tree Expand file tree Collapse file tree 4 files changed +68
-10
lines changed Expand file tree Collapse file tree 4 files changed +68
-10
lines changed Original file line number Diff line number Diff line change
1
+ # Environment variables for the local development environment
2
+
3
+ # Jira API Secrets
4
+ JIRA_USERNAME = " fake_jira_username"
5
+ JIRA_PASSWORD = " fake_jira_password"
6
+
7
+ # Bugzilla API Secrets
8
+ BUGZILLA_API_KEY = " fake_bugzilla_api_key"
Original file line number Diff line number Diff line change 5
5
6
6
settings = environment .get_settings ()
7
7
8
- jira = Jira (
9
- url = settings .jira_base_url ,
10
- username = settings .jira_username ,
11
- password = settings .jira_password ,
12
- )
13
8
14
- bugzilla = rh_bugzilla .Bugzilla (
15
- settings .bugzilla_base_url , api_key = settings .bugzilla_api_key
16
- )
9
+ def get_jira ():
10
+ return Jira (
11
+ url = settings .jira_base_url ,
12
+ username = settings .jira_username ,
13
+ password = settings .jira_password ,
14
+ )
15
+
16
+
17
+ def get_bugzilla ():
18
+ return rh_bugzilla .Bugzilla (
19
+ settings .bugzilla_base_url , api_key = settings .bugzilla_api_key
20
+ )
17
21
18
22
19
23
def bugzilla_check_health ():
24
+ bugzilla = get_bugzilla ()
20
25
health = {"up" : bugzilla .logged_in }
21
26
return health
22
27
23
28
24
29
def jira_check_health ():
30
+ jira = get_jira ()
25
31
server_info = jira .get_server_info (True )
26
32
print (server_info )
27
33
health = {"up" : False }
Original file line number Diff line number Diff line change @@ -12,3 +12,5 @@ services:
12
12
# Let the init system handle signals for us.
13
13
# among other things this helps shutdown be fast
14
14
init : true
15
+ env_file :
16
+ - infra/config/local_dev.env
Original file line number Diff line number Diff line change @@ -18,10 +18,52 @@ def test_read_version(anon_client):
18
18
19
19
def test_read_heartbeat_no_services_fails (anon_client ):
20
20
"""/__heartbeat__ returns 503 when the services are unavailable."""
21
- resp = anon_client .get ("/__heartbeat__" )
21
+ expected = {
22
+ "jira" : {
23
+ "up" : False ,
24
+ },
25
+ "bugzilla" : {
26
+ "up" : False ,
27
+ },
28
+ }
29
+ with patch ("src.app.monitor.jbi_service_health_map" , return_value = expected ):
30
+ resp = anon_client .get ("/__heartbeat__" )
31
+ assert resp .status_code == 503
32
+ data = resp .json ()
33
+ assert data == expected
34
+
35
+
36
+ def test_read_heartbeat_jira_services_fails (anon_client ):
37
+ """/__heartbeat__ returns 503 when the services are unavailable."""
38
+ expected = {
39
+ "jira" : {
40
+ "up" : False ,
41
+ },
42
+ "bugzilla" : {
43
+ "up" : True ,
44
+ },
45
+ }
46
+ with patch ("src.app.monitor.jbi_service_health_map" , return_value = expected ):
47
+ resp = anon_client .get ("/__heartbeat__" )
48
+ assert resp .status_code == 503
49
+ data = resp .json ()
50
+ assert data == expected
51
+
52
+
53
+ def test_read_heartbeat_bugzilla_services_fails (anon_client ):
54
+ """/__heartbeat__ returns 503 when the services are unavailable."""
55
+ expected = {
56
+ "jira" : {
57
+ "up" : True ,
58
+ },
59
+ "bugzilla" : {
60
+ "up" : False ,
61
+ },
62
+ }
63
+ with patch ("src.app.monitor.jbi_service_health_map" , return_value = expected ):
64
+ resp = anon_client .get ("/__heartbeat__" )
22
65
assert resp .status_code == 503
23
66
data = resp .json ()
24
- expected = {"bugzilla" : {"up" : False }, "jira" : {"up" : False }}
25
67
assert data == expected
26
68
27
69
You can’t perform that action at this time.
0 commit comments