-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #2
- Loading branch information
Showing
11 changed files
with
191 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
###################################################################### | ||
# Listen on all interfaces by default. You might also enjoy: 127.0.0.1 | ||
# to just listen locally | ||
INTERFACE=0.0.0.0 | ||
|
||
###################################################################### | ||
# Port to listen on | ||
PORT=8008 | ||
|
||
# See 'man 1 jsonstatsd' or 'jsonstatsd --help' for descriptions of | ||
# all the available options | ||
###################################################################### | ||
# Customize the logging directory | ||
LOGDIR=/var/log/jsonstatsd | ||
|
||
###################################################################### | ||
# Single line with all options for the SysV init script | ||
OPTIONS="--listen $INTERFACE --port $PORT --logdir $LOGDIR" | ||
OPTIONS="--listen 0.0.0.0 --port 8008 --logdir /var/log/jsonstatsd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Dummy plugin used for the extra_plugins test | ||
""" | ||
|
||
from JsonStats.FetchStats import Fetcher | ||
class ExtraPlugin(Fetcher): | ||
def __init__(self): | ||
self.context = 'extraplugin' | ||
self._load_data() | ||
def _load_data(self): | ||
self._loaded(True) | ||
def dump(self): | ||
return {} | ||
def dump_json(self): | ||
return self.json.dumps(self.dump()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Dummy plugin #2 used for the extra_plugins compound-path test | ||
""" | ||
|
||
from JsonStats.FetchStats import Fetcher | ||
class ExtraPlugin2(Fetcher): | ||
def __init__(self): | ||
self.context = 'extraplugin2' | ||
self._load_data() | ||
def _load_data(self): | ||
self._loaded(True) | ||
def dump(self): | ||
return {} | ||
def dump_json(self): | ||
return self.json.dumps(self.dump()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Test for user-defined plugin locations | ||
""" | ||
|
||
|
||
from . import TestCase | ||
import tempfile | ||
from JsonStats.FetchStats import Fetcher | ||
from JsonStats.Utils import load_extra_plugins | ||
import shutil | ||
|
||
class TestLoadExtraPlugins(TestCase): | ||
import os | ||
import os.path | ||
|
||
def setUp(self): | ||
# We create a directory to put our 'extra' plugin file into | ||
self._extra_dir = tempfile.mkdtemp('extra_plugin') | ||
self._extra_plugin = self.os.path.join(self._extra_dir, 'ExtraPlugin.py') | ||
|
||
# And again so we can test compound pathspec's | ||
self._extra_dir2 = tempfile.mkdtemp('extra_plugin2') | ||
self._extra_plugin2 = self.os.path.join(self._extra_dir2, 'ExtraPlugin2.py') | ||
|
||
self._extra_plugin_dirs = (self._extra_dir, self._extra_dir2) | ||
|
||
# Put the extra plugin2 into the temp dirs | ||
shutil.copy('test/files/ExtraPlugin.py', self._extra_plugin) | ||
shutil.copy('test/files/ExtraPlugin2.py', self._extra_plugin2) | ||
|
||
def test_load_extra_plugins(self): | ||
""" | ||
Verify that we can load plugins from user-defined locations | ||
""" | ||
loaded = load_extra_plugins(self._extra_dir) | ||
total_loaded = len(loaded) | ||
self.assertEqual(total_loaded, 1, msg="Loaded %d plugins (%s), expected 1" % (total_loaded, ', '.join(loaded))) | ||
|
||
def test_load_compound_path(self): | ||
""" | ||
Verify that we can load plugins from a compound pathspec | ||
""" | ||
compound_pathspec = "%s:%s" % self._extra_plugin_dirs | ||
loaded = load_extra_plugins(compound_pathspec) | ||
total_loaded = len(loaded) | ||
self.assertEqual(total_loaded, 2, msg="Loaded %d plugins (%s), expected 2" % (total_loaded, ', '.join(loaded))) | ||
|
||
def tearDown(self): | ||
# Cleanup all of our temporary files | ||
for d in self._extra_plugin_dirs: | ||
for f in self.os.listdir(d): | ||
ff = self.os.path.join(d, f) | ||
self.os.remove(ff) | ||
self.os.rmdir(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters