Skip to content

Commit c1689c6

Browse files
test: test for missing graphite in config (#73)
fix for #72 Signed-off-by: Ricky Moorhouse <[email protected]>
1 parent f845c7d commit c1689c6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

test-assets/no-graphite.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Example configuration file
2+
prometheus:
3+
port: 63512
4+
enabled: true
5+
nets:
6+
datapower:
7+
enabled: true
8+
manager:
9+
enabled: true
10+
trawler:
11+
use_kubeconfig: true

test_trawler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def test_check_nosettings():
7474
assert result.exit_code == 2
7575

7676

77+
def test_check_config_load_nographite():
78+
boaty2 = trawler.Trawler('test-assets/no-graphite.yaml')
79+
assert 'prometheus' in boaty2.config
80+
assert 'graphite' not in boaty2.config
81+
82+
7783
def test_check_config_load():
7884
boaty.load_config('test-assets/config.yaml')
7985
assert 'prometheus' in boaty.config

trawler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def __init__(self, config_file=None):
5252
port = self.config['prometheus'].get('port')
5353
logger.info('Starting prometheus http port at http://0.0.0.0:{}'.format(port))
5454
start_http_server(port)
55-
if self.config['graphite']['enabled']:
56-
self.graphite = metrics_graphite.instance(self.config['graphite'])
55+
if 'graphite' in self.config:
56+
if self.config['graphite']['enabled']:
57+
self.graphite = metrics_graphite.instance(self.config['graphite'])
5758

5859
use_kubeconfig = False
5960
if 'trawler' in self.config:

0 commit comments

Comments
 (0)