You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2016/11/30 17:51:41 UTC
incubator-ariatosca git commit: removed Flask,
and entered in memory thread sharing
Repository: incubator-ariatosca
Updated Branches:
refs/heads/SQLAlchemy-based-models 749f37555 -> 56af6c537
removed Flask, and entered in memory thread sharing
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/56af6c53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/56af6c53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/56af6c53
Branch: refs/heads/SQLAlchemy-based-models
Commit: 56af6c53709dc798c592aa2b7d1e210c4912188f
Parents: 749f375
Author: mxmrlv <mx...@gmail.com>
Authored: Wed Nov 30 19:51:33 2016 +0200
Committer: mxmrlv <mx...@gmail.com>
Committed: Wed Nov 30 19:51:33 2016 +0200
----------------------------------------------------------------------
aria/__init__.py | 3 +--
aria/storage/mapi/sql.py | 8 +-------
tests/mock/context.py | 14 +++++---------
tests/orchestrator/context/test_toolbelt.py | 1 +
tests/orchestrator/context/test_workflow.py | 3 ++-
tests/storage/__init__.py | 14 +++++++++++++-
tests/storage/test_model_storage.py | 7 ++-----
7 files changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index 7e7feee..1fd46c7 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -79,11 +79,10 @@ def application_model_storage(api, api_params=None):
storage.models.Task,
]
# if api not in _model_storage:
- _model_storage[api] = storage.ModelStorage(api, api_params=api_params or {}, items=models)
+ _model_storage[api] = storage.ModelStorage(api, items=models, api_params=api_params or {})
return _model_storage[api]
-
def application_resource_storage(driver):
"""
Initiate resource storage for the supplied storage driver
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/aria/storage/mapi/sql.py
----------------------------------------------------------------------
diff --git a/aria/storage/mapi/sql.py b/aria/storage/mapi/sql.py
index f91d614..1e60f87 100644
--- a/aria/storage/mapi/sql.py
+++ b/aria/storage/mapi/sql.py
@@ -18,9 +18,7 @@ SQLalchemy based MAPI
from collections import OrderedDict
from sqlite3 import DatabaseError as SQLiteDBError
-from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
-from sqlalchemy.orm import scoped_session
from sqlalchemy.sql.elements import Label
@@ -45,13 +43,9 @@ class SQLAlchemyModelAPI(storage.api.ModelAPI):
def __init__(self,
engine,
session,
- # sql_dialect=DEFAULT_SQL_DIALECT,
- # username='',
- # password='',
- # host='localhost',
- # db_name='',
**kwargs):
super(SQLAlchemyModelAPI, self).__init__(**kwargs)
+ self._engine = engine
self._session = session
def get(self, entry_id, include=None, filters=None, locking=False):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/tests/mock/context.py
----------------------------------------------------------------------
diff --git a/tests/mock/context.py b/tests/mock/context.py
index 7f09b75..0d09bb1 100644
--- a/tests/mock/context.py
+++ b/tests/mock/context.py
@@ -14,25 +14,21 @@
# limitations under the License.
import pytest
-from sqlalchemy import create_engine, orm
+
from aria import application_model_storage
from aria.orchestrator import context
from aria.storage.mapi import SQLAlchemyModelAPI
+from tests.storage import get_sqlite_api_params
+
from . import models
@pytest.fixture
def simple(**kwargs):
- engine = create_engine('sqlite:///:memory:')
- model_storage = application_model_storage(
- SQLAlchemyModelAPI,
- api_params={
- 'engine': engine,
- 'session': orm.sessionmaker(bind=engine)()
- }
- )
+ api_params = get_sqlite_api_params()
+ model_storage = application_model_storage(SQLAlchemyModelAPI, api_params=api_params)
model_storage.blueprint.store(models.get_blueprint())
blueprint = model_storage.blueprint.get(models.BLUEPRINT_ID)
deployment = models.get_deployment(blueprint)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/tests/orchestrator/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py
index d5297ce..480f289 100644
--- a/tests/orchestrator/context/test_toolbelt.py
+++ b/tests/orchestrator/context/test_toolbelt.py
@@ -37,6 +37,7 @@ def workflow_context():
yield context
context.model.drop()
+
@pytest.fixture
def executor():
result = thread.ThreadExecutor()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/tests/orchestrator/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_workflow.py b/tests/orchestrator/context/test_workflow.py
index 03648f1..443bdf4 100644
--- a/tests/orchestrator/context/test_workflow.py
+++ b/tests/orchestrator/context/test_workflow.py
@@ -59,7 +59,8 @@ class TestWorkflowContext(object):
@pytest.fixture(scope='function')
def storage():
- result = application_model_storage(SQLAlchemyModelAPI)
+ api_params = test_storage.get_sqlite_api_params()
+ result = application_model_storage(SQLAlchemyModelAPI, api_params=api_params)
result.blueprint.store(models.get_blueprint())
blueprint = result.blueprint.get(models.BLUEPRINT_ID)
result.deployment.store(models.get_deployment(blueprint))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/tests/storage/__init__.py
----------------------------------------------------------------------
diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py
index f5939da..e5f183d 100644
--- a/tests/storage/__init__.py
+++ b/tests/storage/__init__.py
@@ -12,10 +12,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
from shutil import rmtree
from tempfile import mkdtemp
+from sqlalchemy import (
+ create_engine,
+ orm)
+from sqlalchemy.pool import StaticPool
+
class TestFileSystem(object):
@@ -24,3 +28,11 @@ class TestFileSystem(object):
def teardown_method(self):
rmtree(self.path)
+
+
+def get_sqlite_api_params():
+ engine = create_engine('sqlite:///:memory:',
+ connect_args={'check_same_thread': False},
+ poolclass=StaticPool)
+ session = orm.sessionmaker(bind=engine)()
+ return dict(engine=engine, session=session)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56af6c53/tests/storage/test_model_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py
index 6e36f84..8fdf870 100644
--- a/tests/storage/test_model_storage.py
+++ b/tests/storage/test_model_storage.py
@@ -18,7 +18,6 @@ import shutil
import pytest
-from aria import application_model_storage
from aria.storage import (
ModelStorage,
@@ -27,13 +26,12 @@ from aria.storage import (
mapi as storage_api,
)
-from . import drop_tables
-
+from tests import storage
temp_dir = tempfile.mkdtemp()
APIs = [
- ModelStorage(storage_api.SQLAlchemyModelAPI),
+ ModelStorage(storage_api.SQLAlchemyModelAPI, api_params=storage.get_sqlite_api_params()),
# ModelStorage(storage_api.FileSystemModelAPI, api_params=dict(directory=temp_dir)),
]
@@ -42,7 +40,6 @@ APIs = [
def cleanup():
yield
try:
- drop_tables()
shutil.rmtree(temp_dir, ignore_errors=True)
except BaseException:
pass