Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Aug 3, 2022
2 parents 29841c4 + 432e4d1 commit 98a902b
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 96 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
schema==0.7.5
pyyaml==5.4
configcrunch==1.0.0
configcrunch==1.0.3
appdirs==1.4.4
janus==0.7.0
psutil==5.8.0
Expand Down
3 changes: 2 additions & 1 deletion riptide/config/command/in_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def convert_in_service_to_normal(app: App, command_name: str) -> Command:
'command': old_cmd['command'],
'additional_volumes': service['additional_volumes'] if 'additional_volumes' in service else {},
'environment': env,
'config_from_roles': [old_cmd['in_service_with_role']]
'config_from_roles': [old_cmd['in_service_with_role']],
'use_host_network': old_cmd['use_host_network'] if 'use_host_network' in old_cmd else False
})
new_cmd.parent_doc = app
new_cmd.freeze()
Expand Down
12 changes: 11 additions & 1 deletion riptide/config/document/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def schema_normal(cls):
If enabled, read the environment variables in the env-files defined in the project (``env_files``).
Default: True
[use_host_network]: bool
If enabled, the container uses network mode `host`. Overrides network and port settings
Default: False
**Example Document:**
.. code-block:: yaml
Expand All @@ -121,7 +125,8 @@ def schema_normal(cls):
},
Optional('environment'): {str: str},
Optional('config_from_roles'): [str],
Optional('read_env_file'): bool
Optional('read_env_file'): bool,
Optional('use_host_network'): bool,
})

@classmethod
Expand Down Expand Up @@ -160,6 +165,10 @@ def schema_in_service(cls):
If enabled, read the environment variables in the env-files defined in the project (``env_files``).
Default: True
[use_host_network]: bool
If enabled, the container uses network mode `host`. Overrides network and port settings
Default: False
**Example Document:**
.. code-block:: yaml
Expand All @@ -176,6 +185,7 @@ def schema_in_service(cls):
'command': str,
Optional('environment'): {str: str},
Optional('read_env_file'): bool,
Optional('use_host_network'): bool,
})

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions riptide/engine/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class ResultQueue(Generic[T]):
Asynchronously (asyncio).
Can be read by (async.) iterating over it or by using get().
All ResultQueues can be poisoned by calling position(). After calling this
class mehtod reading and writing for all existing and future queues will cause
All ResultQueues can be poisoned by calling poison(). After calling this
class method reading and writing for all existing and future queues will cause
an ResultPoisoned to be raised.
This is meant for system shutdowns operations.
Expand Down
35 changes: 35 additions & 0 deletions riptide/tests/configcrunch_test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from schema import Schema
from typing import List

from configcrunch import YamlConfigDocument


class YamlConfigDocumentStub(YamlConfigDocument):
@classmethod
def make(cls,
document: dict,
path: str = None,
parent: 'YamlConfigDocument' = None,
set_parent_to_self=False,
absolute_paths=None
):
slf = cls.from_dict(document)
slf.path = path
slf.parent_doc = parent
if absolute_paths is not None:
slf.absolute_paths = absolute_paths
if set_parent_to_self:
slf.parent_doc = slf
return slf

@classmethod
def header(cls) -> str:
raise NotImplementedError("not available for stub")

@classmethod
def schema(cls) -> Schema:
raise NotImplementedError("not available for stub")

@classmethod
def subdocuments(cls) -> Schema:
raise NotImplementedError("not available for stub")
2 changes: 1 addition & 1 deletion riptide/tests/docker_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tag this as riptide_integration_test
# Simple flexible docker http server image for basic intergation tests

FROM node:10
FROM node:12
RUN yarn global add http-server
RUN mkdir -p /default_workdir && \
echo "hello riptide" > /default_workdir/index.html && \
Expand Down
2 changes: 1 addition & 1 deletion riptide/tests/fixtures/project/integration_all.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
name: integration_all
name: integration-all
src: . # is also replace by src in tests
app:
$ref: app/integration_app
2 changes: 1 addition & 1 deletion riptide/tests/fixtures/project/integration_no_command.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
name: integration_no_command
name: integration-no-command
src: . # is also replace by src in tests
app:
$ref: app/integration_app
Expand Down
2 changes: 1 addition & 1 deletion riptide/tests/fixtures/project/integration_no_service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
name: integration_no_service
name: integration-no-service
src: . # is also replace by src in tests
app:
$ref: app/integration_app
Expand Down
2 changes: 1 addition & 1 deletion riptide/tests/fixtures/project/integration_some.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
name: integration_some
name: integration-some
src: . # is also replace by src in tests
app:
name: some
Expand Down
4 changes: 2 additions & 2 deletions riptide/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from unittest.mock import Mock

from configcrunch.tests.test_utils import YamlConfigDocumentStub
from riptide.tests.configcrunch_test_utils import YamlConfigDocumentStub
from riptide.db.driver.abstract import AbstractDbDriver


Expand Down Expand Up @@ -50,7 +50,7 @@ def side_effect_for_load_subdocument():
Used for testing calls to load_subdocument.
"""
def func(value, *args, **kwargs):
return YamlConfigDocumentStub(value)
return YamlConfigDocumentStub.make(value)
return func


Expand Down
6 changes: 4 additions & 2 deletions riptide/tests/integration/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def test_load(self):
def test_service_initialize_data_correct_config_file_exists_in_both(self):
"""Tests that Services load the correct config file for a document based on merging hierarchy"""
base_path = get_fixture_path(os.path.join('service', 'test_config_paths'))
doc = Service({
doc = Service.from_dict({
'$ref': 'one/config'
})
doc.resolve_and_merge_references([base_path])
doc.freeze()

self.assertEqual({
"test": {
Expand All @@ -41,10 +42,11 @@ def test_service_initialize_data_correct_config_file_exists_in_both(self):
def test_service_initialize_data_correct_config_file_exists_in_referenced_only(self):
"""Tests that Services load the correct config file for a document based on merging hierarchy"""
base_path = get_fixture_path(os.path.join('service', 'test_config_paths'))
doc = Service({
doc = Service.from_dict({
'$ref': 'not_exist_one/config'
})
doc.resolve_and_merge_references([base_path])
doc.freeze()

self.assertEqual(os.path.realpath(os.path.join(base_path, 'two', 'config.txt')),
os.path.realpath(doc['config']["test"]["$source"]))
13 changes: 8 additions & 5 deletions riptide/tests/integration/engine_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def test_with_working_directory(self):
elif service_name == 'working_directory_absolute':
# We didn't put an index.html at /a_folder, so we expect
# a directory listing of the three files we put in the image
self.assert_response_matches_regex(re.compile('<title>Index of /</title>.*'
'<a href="/file1">file1</a>.*'
'<a href="/file2">file2</a>.*'
'<a href="/file3">file3</a>'
self.assert_response_matches_regex(re.compile(r'.*<title>Index of /</title>.*'
r'<a href="\./file1">file1</a>.*'
r'<a href="\./file2">file2</a>.*'
r'<a href="\./file3">file3</a>.*'
, re.MULTILINE | re.DOTALL),
loaded.engine, project, service_name)
else:
Expand Down Expand Up @@ -402,6 +402,9 @@ def test_logging(self):
self.run_stop_test(loaded.engine, project, services, loaded.engine_tester)

def test_additional_ports(self):
self.skipTest("Currently broken on Py3.9+, probably a race condition.")
return

for project_ctx in load(self,
['integration_all.yml'],
['.']):
Expand Down Expand Up @@ -461,7 +464,7 @@ def test_additional_ports(self):

@unittest.skipIf(platform.system().lower().startswith('win'),
"Skipped on Windows. "
"This tets does work on Windows, because of cpuser, but since with root and "
"This test does work on Windows, because of cpuser, but since with root and "
"without root makes no difference, it's pointless.")
def test_run_as_current_user_false(self):
for project_ctx in load(self,
Expand Down
2 changes: 1 addition & 1 deletion riptide/tests/stubs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from configcrunch.tests.test_utils import YamlConfigDocumentStub
from riptide.tests.configcrunch_test_utils import YamlConfigDocumentStub


class ProjectStub(YamlConfigDocumentStub):
Expand Down
5 changes: 2 additions & 3 deletions riptide/tests/unit/config/document/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

import riptide.config.document.app as module
from configcrunch import ConfigcrunchError
from configcrunch.tests.test_utils import YamlConfigDocumentStub
from riptide.tests.helpers import side_effect_for_load_subdocument, get_fixture_path
from riptide.tests.helpers import get_fixture_path

FIXTURE_BASE_PATH = 'app' + os.sep


class AppTestCase(unittest.TestCase):

def test_header(self):
app = module.App({})
app = module.App.from_dict({})
self.assertEqual(module.HEADER, app.header())

def test_validate_valids(self):
Expand Down
Loading

0 comments on commit 98a902b

Please sign in to comment.