forked from VKCOM/kphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[runtime] add runtime configuration support (VKCOM#667)
Add the ability to specify a json-config as a server argument to be used inside the script with 'kphp_get_runtime_config()'.
- Loading branch information
1 parent
0980a31
commit f58fe56
Showing
7 changed files
with
71 additions
and
0 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
4 changes: 4 additions & 0 deletions
4
tests/python/tests/http_server/php/data/runtime_configuration.json
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,4 @@ | ||
{ | ||
"name": "simple configuration", | ||
"version": "1.0.0" | ||
} |
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,22 @@ | ||
from python.lib.testcase import KphpServerAutoTestCase | ||
|
||
class TestRuntimeConfig(KphpServerAutoTestCase): | ||
|
||
@classmethod | ||
def extra_class_setup(cls): | ||
cls.kphp_server.update_options({ | ||
"--runtime-config": "./data/runtime_configuration.json" | ||
}) | ||
|
||
|
||
def test_read_only(self): | ||
response = self.kphp_server.http_request(uri="/test_runtime_config?mode=read_only") | ||
self.assertEqual(200, response.status_code) | ||
self.assertEqual(response.reason, "OK") | ||
self.assertEqual(response.content, b'name : simple configuration version : 1.0.0 OK') | ||
|
||
def test_modifying(self): | ||
response = self.kphp_server.http_request(uri="/test_runtime_config?mode=modify") | ||
self.assertEqual(200, response.status_code) | ||
self.assertEqual(response.reason, "OK") | ||
self.assertEqual(response.content, b'modified version : 1.0.1 old version : 1.0.0 OK') |