This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #543 from Kitware/settings
Server settings in configuration file
- Loading branch information
Showing
7 changed files
with
85 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import fixture | ||
import json | ||
import nose | ||
import requests | ||
|
||
|
||
def start_tangelo(): | ||
"""Start tangelo with a some settings.""" | ||
config = {"server_settings": {"server.thread_pool": 1000}} | ||
return fixture.start_tangelo("-c", json.dumps(config)) | ||
|
||
|
||
@nose.with_setup(start_tangelo, fixture.stop_tangelo) | ||
def test_config_settings(): | ||
response = requests.get(fixture.url('settings')) | ||
print response | ||
assert 'pool="1000"' in response | ||
|
||
|
||
@nose.with_setup(start_tangelo, fixture.stop_tangelo) | ||
def test_config_settings_change(): | ||
response = requests.get(fixture.url('settings', pool='500')) | ||
print response | ||
assert 'pool="500"' in response | ||
|
||
|
||
@nose.with_setup(fixture.start_tangelo, fixture.stop_tangelo) | ||
def test_config_no_settings(): | ||
response = requests.get(fixture.url('settings')) | ||
print response | ||
assert 'pool="None"' in response | ||
|
||
|
||
def test_config_wrong_type_settings(): | ||
config = {"server_settings": "Angosian"} | ||
(_, _, stderr) = fixture.run_tangelo( | ||
"-c", json.dumps(config), terminate=True) | ||
stderr = "\n".join(stderr) | ||
|
||
print stderr | ||
|
||
assert "option server_settings must be of type dict" in stderr |
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,10 @@ | ||
import cherrypy | ||
import tangelo | ||
|
||
|
||
# This service reports the value of cherrypy's thread pool setting | ||
def run(**kwargs): | ||
if kwargs.get('pool'): | ||
tangelo.util.set_server_setting('server.thread_pool', int(kwargs['pool'])) | ||
response = 'pool="%r"' % cherrypy.config.get('server.thread_pool') | ||
return response |