Commit 16e5846b authored by André Anjos's avatar André Anjos 💬

Merge branch 'update_db_container_creation' into 'master'

Update db container creation

See merge request !97
parents b38536e6 5dacbc19
Pipeline #41073 passed with stages
in 5 minutes and 44 seconds
[settings]
multi_line_output=3
include_trailing_comma=true
force_grid_wrap=0
use_parentheses=true
ensure_newline_before_comments=true
line_length=88
order_by_type=true
lines_between_types=1
force_single_line=true
......@@ -2,16 +2,16 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21-2
rev: 5.0.5
hooks:
- id: isort
args: [-sl]
- repo: https://github.com/psf/black
rev: stable
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.1
rev: v3.1.0
hooks:
- id: check-ast
- id: check-case-conflict
......@@ -21,11 +21,14 @@ repos:
exclude: beat/cmdline/test/utils.py
- id: check-added-large-files
- id: check-docstring-first
- id: flake8
- id: check-yaml
exclude: conda/meta.yaml
- repo: https://github.com/PyCQA/flake8/
rev: 3.8.3
hooks:
- id: flake8
- repo: https://github.com/PyCQA/bandit
rev: master
rev: 1.6.2
hooks:
- id: bandit
args: [-c, .bandit.yml]
......
......@@ -221,14 +221,29 @@ def start_db_container(
with open(json_path, "w") as f:
simplejson.dump(db_data, f, indent=4)
try:
db_envkey = host.db2docker([db_name])
except Exception:
raise RuntimeError(
"No environment found for the database `%s' "
"- available environments are %s"
% (db_name, ", ".join(host.db_environments.keys()))
)
environment = database.environment
if environment:
environment_name = utils.build_env_name(environment)
try:
db_envkey = host.dbenv2docker(environment_name)
except KeyError:
raise RuntimeError(
"Environment {} not found for the database '{}' "
"- available environments are {}".format(
environment_name, db_name, ", ".join(host.db_environments.keys())
)
)
else:
try:
db_envkey = host.db2docker([db_name])
except Exception:
raise RuntimeError(
"No environment found for the database `%s' "
"- available environments are %s"
% (db_name, ", ".join(host.db_environments.keys()))
)
logger.info("Indexing using {}".format(db_envkey))
# Creation of the container
# Note: we only support one databases image loaded at the same time
......
......@@ -209,3 +209,13 @@ class TestIndex(core.AssetBaseTest):
% (expected_errors, existing_errors)
),
)
def test_index_error_invalid_env(self):
db_name = "integers_db_invalid_env/1"
with nose.tools.assert_raises(RuntimeError) as context:
self.call("index", "--docker", db_name)
print(context.exception)
nose.tools.assert_true(
"Environment Does not exist (1.4.0) not found for the database"
in context.exception.args[0]
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment