Merge "Be configuration driven when referencing document names/schemas"
This commit is contained in:
commit
e2a87a1830
@ -415,6 +415,16 @@ conf:
|
|||||||
# If non-existent rule is used, the request should be denied. The
|
# If non-existent rule is used, the request should be denied. The
|
||||||
# deny_all rule is hard coded in the policy.py code to allow no access.
|
# deny_all rule is hard coded in the policy.py code to allow no access.
|
||||||
policy_default_rule: deny_all
|
policy_default_rule: deny_all
|
||||||
|
document_info:
|
||||||
|
# The name of the deployment configuration document that Shipyard expects
|
||||||
|
# and validates
|
||||||
|
deployment_configuration_name: deployment-configuration
|
||||||
|
# The schema of the deployment configuration document that Shipyard
|
||||||
|
# expects and validates
|
||||||
|
deployment_configuration_schema: shipyard/DeploymentConfiguration/v1
|
||||||
|
# The schema of the deployment strategy document that Shipyard expects
|
||||||
|
# and validates.
|
||||||
|
deployment_strategy_schema: shipyard/DeploymentStrategy/v1
|
||||||
airflow_config_file:
|
airflow_config_file:
|
||||||
path: /usr/local/airflow/airflow.cfg
|
path: /usr/local/airflow/airflow.cfg
|
||||||
airflow:
|
airflow:
|
||||||
|
@ -84,6 +84,27 @@
|
|||||||
#service_type = deckhand
|
#service_type = deckhand
|
||||||
|
|
||||||
|
|
||||||
|
[document_info]
|
||||||
|
|
||||||
|
#
|
||||||
|
# From shipyard_api
|
||||||
|
#
|
||||||
|
|
||||||
|
# The name of the deployment-configuration document that Shipyard expects and
|
||||||
|
# validates (string value)
|
||||||
|
#deployment_configuration_name = deployment-configuration
|
||||||
|
|
||||||
|
# The schema of the deployment-configuration document that Shipyard expects and
|
||||||
|
# validates (string value)
|
||||||
|
#deployment_configuration_schema = shipyard/DeploymentConfiguration/v1
|
||||||
|
|
||||||
|
# The schema of the deployment strategy document that Shipyard expects and
|
||||||
|
# validates. Note that the name of this document is not configurable, because
|
||||||
|
# it is controlled by a field in the deployment configuration document. (string
|
||||||
|
# value)
|
||||||
|
#deployment_strategy_schema = shipyard/DeploymentStrategy/v1
|
||||||
|
|
||||||
|
|
||||||
[drydock]
|
[drydock]
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
.. _sample-configuration:
|
||||||
|
|
||||||
Sample Configuration File
|
Sample Configuration File
|
||||||
==========================
|
==========================
|
||||||
|
@ -37,6 +37,11 @@ of the Armada manifest that will be used during the deployment/update.
|
|||||||
|
|
||||||
A `sample deployment-configuration`_ shows a completely specified example.
|
A `sample deployment-configuration`_ shows a completely specified example.
|
||||||
|
|
||||||
|
Note that the name and schema Shipyard expects the deployment configuration
|
||||||
|
document to have is conifgurable via the document_info section in the
|
||||||
|
:ref:`Shipyard configuration <sample-configuration>`, but should be left
|
||||||
|
defaulted in most cases.
|
||||||
|
|
||||||
`Default configuration values`_ are provided for most values.
|
`Default configuration values`_ are provided for most values.
|
||||||
|
|
||||||
Supported values
|
Supported values
|
||||||
@ -179,6 +184,11 @@ document for the site. Example::
|
|||||||
- The success criteria indicates that all nodes must be succssful to consider
|
- The success criteria indicates that all nodes must be succssful to consider
|
||||||
the group a success.
|
the group a success.
|
||||||
|
|
||||||
|
Note that the schema Shipyard expects the deployment strategy document to have
|
||||||
|
is conifgurable via the document_info section in the
|
||||||
|
:ref:`Shipyard configuration <sample-configuration>`, but should be left
|
||||||
|
defaulted in most cases.
|
||||||
|
|
||||||
In short, the default behavior is to deploy everything all at once, and halt
|
In short, the default behavior is to deploy everything all at once, and halt
|
||||||
if there are any failures.
|
if there are any failures.
|
||||||
|
|
||||||
|
@ -84,6 +84,27 @@
|
|||||||
#service_type = deckhand
|
#service_type = deckhand
|
||||||
|
|
||||||
|
|
||||||
|
[document_info]
|
||||||
|
|
||||||
|
#
|
||||||
|
# From shipyard_api
|
||||||
|
#
|
||||||
|
|
||||||
|
# The name of the deployment-configuration document that Shipyard expects and
|
||||||
|
# validates (string value)
|
||||||
|
#deployment_configuration_name = deployment-configuration
|
||||||
|
|
||||||
|
# The schema of the deployment-configuration document that Shipyard expects and
|
||||||
|
# validates (string value)
|
||||||
|
#deployment_configuration_schema = shipyard/DeploymentConfiguration/v1
|
||||||
|
|
||||||
|
# The schema of the deployment strategy document that Shipyard expects and
|
||||||
|
# validates. Note that the name of this document is not configurable, because
|
||||||
|
# it is controlled by a field in the deployment configuration document. (string
|
||||||
|
# value)
|
||||||
|
#deployment_strategy_schema = shipyard/DeploymentStrategy/v1
|
||||||
|
|
||||||
|
|
||||||
[drydock]
|
[drydock]
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -286,6 +286,34 @@ SECTIONS = [
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
ConfigSection(
|
||||||
|
name='document_info',
|
||||||
|
title=('Information about some of the documents Shipyard needs to '
|
||||||
|
'handle'),
|
||||||
|
options=[
|
||||||
|
cfg.StrOpt(
|
||||||
|
'deployment_configuration_name',
|
||||||
|
default='deployment-configuration',
|
||||||
|
help=('The name of the deployment-configuration document that '
|
||||||
|
'Shipyard expects and validates')
|
||||||
|
),
|
||||||
|
cfg.StrOpt(
|
||||||
|
'deployment_configuration_schema',
|
||||||
|
default='shipyard/DeploymentConfiguration/v1',
|
||||||
|
help=('The schema of the deployment-configuration document '
|
||||||
|
'that Shipyard expects and validates')
|
||||||
|
),
|
||||||
|
cfg.StrOpt(
|
||||||
|
'deployment_strategy_schema',
|
||||||
|
default='shipyard/DeploymentStrategy/v1',
|
||||||
|
help=('The schema of the deployment strategy document that '
|
||||||
|
'Shipyard expects and validates. Note that the name of '
|
||||||
|
'this document is not configurable, because it is '
|
||||||
|
'controlled by a field in the deployment configuration '
|
||||||
|
'document.')
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ class ConfigdocsHelper(object):
|
|||||||
service_clients.deckhand_client(),
|
service_clients.deckhand_client(),
|
||||||
revision_id,
|
revision_id,
|
||||||
[(ValidateDeploymentConfigurationFull,
|
[(ValidateDeploymentConfigurationFull,
|
||||||
'deployment-configuration')]
|
CONF.document_info.deployment_configuration_name)]
|
||||||
)
|
)
|
||||||
return sy_val_mgr.validate()
|
return sy_val_mgr.validate()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import falcon
|
import falcon
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from .validate_deployment_configuration \
|
from .validate_deployment_configuration \
|
||||||
import ValidateDeploymentConfigurationBasic
|
import ValidateDeploymentConfigurationBasic
|
||||||
@ -24,6 +25,7 @@ from shipyard_airflow.common.document_validators.document_validator_manager \
|
|||||||
from shipyard_airflow.errors import ApiError
|
from shipyard_airflow.errors import ApiError
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ValidateDeploymentAction:
|
class ValidateDeploymentAction:
|
||||||
@ -40,7 +42,7 @@ class ValidateDeploymentAction:
|
|||||||
dh_client,
|
dh_client,
|
||||||
self.doc_revision,
|
self.doc_revision,
|
||||||
[(ValidateDeploymentConfigurationFull,
|
[(ValidateDeploymentConfigurationFull,
|
||||||
'deployment-configuration')]
|
CONF.document_info.deployment_configuration_name)]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Perform a basic validation only
|
# Perform a basic validation only
|
||||||
@ -48,7 +50,7 @@ class ValidateDeploymentAction:
|
|||||||
dh_client,
|
dh_client,
|
||||||
self.doc_revision,
|
self.doc_revision,
|
||||||
[(ValidateDeploymentConfigurationBasic,
|
[(ValidateDeploymentConfigurationBasic,
|
||||||
'deployment-configuration')]
|
CONF.document_info.deployment_configuration_name)]
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
@ -18,11 +18,14 @@ is performed by Deckhand on Shipyard's behalf.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from shipyard_airflow.common.document_validators.document_validator import (
|
from shipyard_airflow.common.document_validators.document_validator import (
|
||||||
DocumentValidator
|
DocumentValidator
|
||||||
)
|
)
|
||||||
from .validate_deployment_strategy import ValidateDeploymentStrategy
|
from .validate_deployment_strategy import ValidateDeploymentStrategy
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +39,7 @@ class ValidateDeploymentConfigurationBasic(DocumentValidator):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
schema = "shipyard/DeploymentConfiguration/v1"
|
schema = CONF.document_info.deployment_configuration_schema
|
||||||
missing_severity = "Error"
|
missing_severity = "Error"
|
||||||
|
|
||||||
def do_validate(self):
|
def do_validate(self):
|
||||||
|
@ -18,6 +18,8 @@ is performed by Deckhand on Shipyard's behalf.
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from shipyard_airflow.common.deployment_group.deployment_group_manager import (
|
from shipyard_airflow.common.deployment_group.deployment_group_manager import (
|
||||||
DeploymentGroupManager
|
DeploymentGroupManager
|
||||||
)
|
)
|
||||||
@ -35,6 +37,7 @@ from shipyard_airflow.control.helpers.design_reference_helper import (
|
|||||||
DesignRefHelper
|
DesignRefHelper
|
||||||
)
|
)
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def _get_node_lookup(revision_id):
|
def _get_node_lookup(revision_id):
|
||||||
@ -56,7 +59,7 @@ class ValidateDeploymentStrategy(DocumentValidator):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
schema = "shipyard/DeploymentStrategy/v1"
|
schema = CONF.document_info.deployment_strategy_schema
|
||||||
missing_severity = "Error"
|
missing_severity = "Error"
|
||||||
|
|
||||||
def do_validate(self):
|
def do_validate(self):
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""Deployment Configuration
|
"""Deployment Configuration
|
||||||
|
|
||||||
Retrieves the deployment configuration from Deckhand and places the values
|
Retrieves the deployment-configuration from Deckhand and places the values
|
||||||
retrieved into a dictionary
|
retrieved into a dictionary
|
||||||
"""
|
"""
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from airflow.exceptions import AirflowException
|
from airflow.exceptions import AirflowException
|
||||||
@ -34,12 +35,13 @@ except ImportError:
|
|||||||
from shipyard_airflow.shipyard_const import CustomHeaders
|
from shipyard_airflow.shipyard_const import CustomHeaders
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
DOCUMENT_INFO = 'document_info'
|
||||||
|
|
||||||
|
|
||||||
class DeploymentConfigurationOperator(BaseOperator):
|
class DeploymentConfigurationOperator(BaseOperator):
|
||||||
"""Deployment Configuration Operator
|
"""Deployment Configuration Operator
|
||||||
|
|
||||||
Retrieve the deployment configuration from Deckhand for use throughout
|
Retrieve the deployment-configuration from Deckhand for use throughout
|
||||||
the workflow. Put the configuration into a dictionary.
|
the workflow. Put the configuration into a dictionary.
|
||||||
|
|
||||||
Failures are raised:
|
Failures are raised:
|
||||||
@ -89,18 +91,23 @@ class DeploymentConfigurationOperator(BaseOperator):
|
|||||||
:param main_dag_name: Parent Dag
|
:param main_dag_name: Parent Dag
|
||||||
:param shipyard_conf: Location of shipyard.conf
|
:param shipyard_conf: Location of shipyard.conf
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super(DeploymentConfigurationOperator, self).__init__(*args, **kwargs)
|
super(DeploymentConfigurationOperator, self).__init__(*args, **kwargs)
|
||||||
self.main_dag_name = main_dag_name
|
self.main_dag_name = main_dag_name
|
||||||
self.shipyard_conf = shipyard_conf
|
self.shipyard_conf = shipyard_conf
|
||||||
self.action_info = {}
|
self.action_info = {}
|
||||||
|
|
||||||
|
def _read_config(self):
|
||||||
|
"""Read in and parse the shipyard config"""
|
||||||
|
self.config = configparser.ConfigParser()
|
||||||
|
self.config.read(self.shipyard_conf)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
"""Perform Deployment Configuration extraction"""
|
"""Perform Deployment Configuration extraction"""
|
||||||
|
self._read_config()
|
||||||
revision_id = self.get_revision_id(context.get('task_instance'))
|
revision_id = self.get_revision_id(context.get('task_instance'))
|
||||||
doc = self.get_doc(revision_id)
|
doc = self.get_doc(revision_id)
|
||||||
converted = self.map_config_keys(doc)
|
converted = self.map_config_keys(doc)
|
||||||
|
|
||||||
# return the mapped configuration so that it can be placed on xcom
|
# return the mapped configuration so that it can be placed on xcom
|
||||||
return converted
|
return converted
|
||||||
|
|
||||||
@ -116,7 +123,7 @@ class DeploymentConfigurationOperator(BaseOperator):
|
|||||||
revision_id = self.action_info['committed_rev_id']
|
revision_id = self.action_info['committed_rev_id']
|
||||||
|
|
||||||
if revision_id:
|
if revision_id:
|
||||||
LOG.info("Revision is set to: %s for deployment configuration",
|
LOG.info("Revision is set to: %s for deployment-configuration",
|
||||||
revision_id)
|
revision_id)
|
||||||
return revision_id
|
return revision_id
|
||||||
# either revision id was not on xcom, or the task_instance is messed
|
# either revision id was not on xcom, or the task_instance is messed
|
||||||
@ -127,14 +134,16 @@ class DeploymentConfigurationOperator(BaseOperator):
|
|||||||
|
|
||||||
def get_doc(self, revision_id):
|
def get_doc(self, revision_id):
|
||||||
"""Get the DeploymentConfiguration document dictionary from Deckhand"""
|
"""Get the DeploymentConfiguration document dictionary from Deckhand"""
|
||||||
LOG.info(
|
schema_fallback = 'shipyard/DeploymentConfiguration/v1'
|
||||||
"Attempting to retrieve shipyard/DeploymentConfiguration/v1, "
|
schema = self.config.get(DOCUMENT_INFO,
|
||||||
"deployment-configuration from Deckhand"
|
'deployment_configuration_schema',
|
||||||
)
|
fallback=schema_fallback)
|
||||||
filters = {
|
name = self.config.get(DOCUMENT_INFO,
|
||||||
"schema": "shipyard/DeploymentConfiguration/v1",
|
'deployment_configuration_name',
|
||||||
"metadata.name": "deployment-configuration"
|
fallback='deployment-configuration')
|
||||||
}
|
LOG.info("Attempting to retrieve {}, {} from Deckhand".format(schema,
|
||||||
|
name))
|
||||||
|
filters = {"schema": schema, "metadata.name": name}
|
||||||
|
|
||||||
# Create additional headers dict to pass context marker
|
# Create additional headers dict to pass context marker
|
||||||
# and end user
|
# and end user
|
||||||
@ -160,7 +169,7 @@ class DeploymentConfigurationOperator(BaseOperator):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
failed_url = "No URL generated"
|
failed_url = "No URL generated"
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
raise AirflowException("Failed to retrieve deployment "
|
raise AirflowException("Failed to retrieve deployment-"
|
||||||
"configuration yaml using url: "
|
"configuration yaml using url: "
|
||||||
"{}".format(failed_url))
|
"{}".format(failed_url))
|
||||||
|
|
||||||
@ -178,7 +187,7 @@ class DeploymentConfigurationOperator(BaseOperator):
|
|||||||
|
|
||||||
Converts to a more simple map of key-value pairs
|
Converts to a more simple map of key-value pairs
|
||||||
"""
|
"""
|
||||||
LOG.info("Mapping keys from deployment configuration")
|
LOG.info("Mapping keys from deployment-configuration")
|
||||||
return {
|
return {
|
||||||
cfg_key: self.get_cfg_value(cfg_data, cfg_key, cfg_default)
|
cfg_key: self.get_cfg_value(cfg_data, cfg_key, cfg_default)
|
||||||
for cfg_key, cfg_default in
|
for cfg_key, cfg_default in
|
||||||
|
@ -53,6 +53,7 @@ except ImportError:
|
|||||||
)
|
)
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
DOCUMENT_INFO = 'document_info'
|
||||||
|
|
||||||
|
|
||||||
class DrydockNodesOperator(DrydockBaseOperator):
|
class DrydockNodesOperator(DrydockBaseOperator):
|
||||||
@ -287,10 +288,12 @@ class DrydockNodesOperator(DrydockBaseOperator):
|
|||||||
strat_name = self.dc['physical_provisioner.deployment_strategy']
|
strat_name = self.dc['physical_provisioner.deployment_strategy']
|
||||||
if strat_name:
|
if strat_name:
|
||||||
# if there is a deployment strategy specified, use it
|
# if there is a deployment strategy specified, use it
|
||||||
strategy = self.get_unique_doc(
|
schema_fallback = 'shipyard/DeploymentStrategy/v1'
|
||||||
name=strat_name,
|
schema = self.config.get(DOCUMENT_INFO,
|
||||||
schema="shipyard/DeploymentStrategy/v1"
|
'deployment_strategy_schema',
|
||||||
)
|
fallback=schema_fallback)
|
||||||
|
|
||||||
|
strategy = self.get_unique_doc(name=strat_name, schema=schema)
|
||||||
else:
|
else:
|
||||||
# The default behavior is to deploy all nodes, and fail if
|
# The default behavior is to deploy all nodes, and fail if
|
||||||
# any nodes fail to deploy.
|
# any nodes fail to deploy.
|
||||||
|
@ -253,10 +253,7 @@ class UcpBaseOperator(BaseOperator):
|
|||||||
if revision_id is None:
|
if revision_id is None:
|
||||||
revision_id = self.revision_id
|
revision_id = self.revision_id
|
||||||
|
|
||||||
LOG.info(
|
LOG.info("Retrieve {}, {} from Deckhand".format(schema, name))
|
||||||
"Retrieve shipyard/DeploymentConfiguration/v1, "
|
|
||||||
"deployment-configuration from Deckhand"
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
return self.doc_utils.get_unique_doc(revision_id=revision_id,
|
return self.doc_utils.get_unique_doc(revision_id=revision_id,
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
from configparser import ConfigParser
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -40,11 +41,13 @@ ACTION_INFO_NO_COMMIT = {
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from deployment_configuration_operator import (
|
from deployment_configuration_operator import (
|
||||||
DeploymentConfigurationOperator
|
DeploymentConfigurationOperator,
|
||||||
|
DOCUMENT_INFO
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from shipyard_airflow.plugins.deployment_configuration_operator import (
|
from shipyard_airflow.plugins.deployment_configuration_operator import (
|
||||||
DeploymentConfigurationOperator
|
DeploymentConfigurationOperator,
|
||||||
|
DOCUMENT_INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -55,6 +58,21 @@ except ImportError:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def make_fake_config():
|
||||||
|
"""Make/return a fake config using configparser that we can use for testing
|
||||||
|
|
||||||
|
:returns: A fake configuration object
|
||||||
|
:rtype: ConfigParser
|
||||||
|
"""
|
||||||
|
cfg = ConfigParser()
|
||||||
|
cfg.add_section(DOCUMENT_INFO)
|
||||||
|
cfg.set(DOCUMENT_INFO, 'deployment_configuration_name',
|
||||||
|
'deployment-configuration')
|
||||||
|
cfg.set(DOCUMENT_INFO, 'deployment_configuration_schema',
|
||||||
|
'shipyard/DeploymentConfiguration/v1')
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
def test_execute_exception():
|
def test_execute_exception():
|
||||||
"""Test that execute results in a failure with bad context"""
|
"""Test that execute results in a failure with bad context"""
|
||||||
|
|
||||||
@ -67,18 +85,21 @@ def test_execute_exception():
|
|||||||
assert ("Design_revision is not set. Cannot proceed with retrieval"
|
assert ("Design_revision is not set. Cannot proceed with retrieval"
|
||||||
" of the design configuration") in str(expected_exc)
|
" of the design configuration") in str(expected_exc)
|
||||||
|
|
||||||
|
@mock.patch.object(DeploymentConfigurationOperator, '_read_config')
|
||||||
@mock.patch.object(DeploymentConfigurationOperator, 'get_revision_id',
|
@mock.patch.object(DeploymentConfigurationOperator, 'get_revision_id',
|
||||||
return_value=99)
|
return_value=99)
|
||||||
def test_execute_no_client(*args):
|
def test_execute_no_client(get_revision_id, read_config):
|
||||||
# no keystone authtoken present in configuration
|
# no keystone authtoken present in configuration
|
||||||
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
||||||
shipyard_conf="shipyard.conf",
|
shipyard_conf="shipyard.conf",
|
||||||
task_id="t1")
|
task_id="t1")
|
||||||
|
dco.config = make_fake_config()
|
||||||
with pytest.raises(AirflowException) as expected_exc:
|
with pytest.raises(AirflowException) as expected_exc:
|
||||||
dco.execute(context={})
|
dco.execute(context={'task_instance': 'asdf'})
|
||||||
assert ("Failed to retrieve deployment configuration yaml") in str(
|
assert ("Failed to retrieve deployment-configuration yaml") in str(
|
||||||
expected_exc)
|
expected_exc)
|
||||||
|
get_revision_id.assert_called_once_with('asdf')
|
||||||
|
read_config.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(airflow.models.TaskInstance, 'xcom_pull',
|
@mock.patch.object(airflow.models.TaskInstance, 'xcom_pull',
|
||||||
@ -113,6 +134,7 @@ def test_get_doc_no_deckhand():
|
|||||||
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
||||||
shipyard_conf="shipyard.conf",
|
shipyard_conf="shipyard.conf",
|
||||||
task_id="t1")
|
task_id="t1")
|
||||||
|
dco.config = make_fake_config()
|
||||||
with pytest.raises(AirflowException) as expected_exc:
|
with pytest.raises(AirflowException) as expected_exc:
|
||||||
dco.get_doc(99)
|
dco.get_doc(99)
|
||||||
assert "Failed to retrieve deployment" in str(expected_exc)
|
assert "Failed to retrieve deployment" in str(expected_exc)
|
||||||
@ -134,7 +156,7 @@ def test_get_doc_mock_deckhand(*args):
|
|||||||
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
||||||
shipyard_conf="shipyard.conf",
|
shipyard_conf="shipyard.conf",
|
||||||
task_id="t1")
|
task_id="t1")
|
||||||
|
dco.config = make_fake_config()
|
||||||
doc = dco.get_doc(99)
|
doc = dco.get_doc(99)
|
||||||
assert doc == 'abcdefg'
|
assert doc == 'abcdefg'
|
||||||
|
|
||||||
@ -146,6 +168,7 @@ def test_get_doc_mock_deckhand_invalid(*args):
|
|||||||
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
dco = DeploymentConfigurationOperator(main_dag_name="main",
|
||||||
shipyard_conf="shipyard.conf",
|
shipyard_conf="shipyard.conf",
|
||||||
task_id="t1")
|
task_id="t1")
|
||||||
|
dco.config = make_fake_config()
|
||||||
|
|
||||||
with pytest.raises(AirflowException) as airflow_ex:
|
with pytest.raises(AirflowException) as airflow_ex:
|
||||||
dco.get_doc(99)
|
dco.get_doc(99)
|
||||||
|
@ -45,3 +45,7 @@ service_type = shipyard
|
|||||||
[oslo_policy]
|
[oslo_policy]
|
||||||
policy_file = /etc/shipyard/policy.yaml
|
policy_file = /etc/shipyard/policy.yaml
|
||||||
policy_default_rule = deny_all
|
policy_default_rule = deny_all
|
||||||
|
[document_info]
|
||||||
|
deployment_configuration_name = deployment-configuration
|
||||||
|
deployment_configuration_schema = shipyard/DeploymentConfiguration/v1
|
||||||
|
deployment_strategy_schema = shipyard/DeploymentStrategy/v1
|
Loading…
Reference in New Issue
Block a user