Skip to content

Commit

Permalink
test: test for missing graphite in config (#73)
Browse files Browse the repository at this point in the history
fix for #72

Signed-off-by: Ricky Moorhouse <[email protected]>
  • Loading branch information
rickymoorhouse authored Dec 5, 2023
1 parent f845c7d commit c1689c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 11 additions & 0 deletions test-assets/no-graphite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example configuration file
prometheus:
port: 63512
enabled: true
nets:
datapower:
enabled: true
manager:
enabled: true
trawler:
use_kubeconfig: true
6 changes: 6 additions & 0 deletions test_trawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def test_check_nosettings():
assert result.exit_code == 2


def test_check_config_load_nographite():
boaty2 = trawler.Trawler('test-assets/no-graphite.yaml')
assert 'prometheus' in boaty2.config
assert 'graphite' not in boaty2.config


def test_check_config_load():
boaty.load_config('test-assets/config.yaml')
assert 'prometheus' in boaty.config
Expand Down
5 changes: 3 additions & 2 deletions trawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ def __init__(self, config_file=None):
port = self.config['prometheus'].get('port')
logger.info('Starting prometheus http port at http://0.0.0.0:{}'.format(port))
start_http_server(port)
if self.config['graphite']['enabled']:
self.graphite = metrics_graphite.instance(self.config['graphite'])
if 'graphite' in self.config:
if self.config['graphite']['enabled']:
self.graphite = metrics_graphite.instance(self.config['graphite'])

use_kubeconfig = False
if 'trawler' in self.config:
Expand Down

0 comments on commit c1689c6

Please sign in to comment.