Merge "Allow running validation against different plans"
This commit is contained in:
commit
6c39473ce5
@ -5,6 +5,7 @@ set -o pipefail
|
||||
|
||||
VALIDATION_FILE=$1
|
||||
IDENTITY_FILE=$2
|
||||
PLAN_NAME=$3
|
||||
|
||||
if [[ -z "$VALIDATION_FILE" ]]; then
|
||||
echo "Missing required validation file"
|
||||
@ -31,4 +32,8 @@ export ANSIBLE_PRIVATE_KEY_FILE=$IDENTITY_FILE
|
||||
|
||||
export ANSIBLE_INVENTORY=$(which tripleo-ansible-inventory)
|
||||
|
||||
# Environment variable is the easiest way to pass variables to an Ansible
|
||||
# dynamic inventory script
|
||||
export TRIPLEO_PLAN_NAME=${PLAN_NAME}
|
||||
|
||||
ansible-playbook $VALIDATION_FILE
|
||||
|
@ -20,6 +20,7 @@ from mistral.workflow import utils as mistral_workflow_utils
|
||||
from oslo_concurrency.processutils import ProcessExecutionError
|
||||
|
||||
from tripleo_common.actions import base
|
||||
from tripleo_common import constants
|
||||
from tripleo_common.utils import validations as utils
|
||||
|
||||
|
||||
@ -83,9 +84,10 @@ class ListGroupsAction(base.TripleOAction):
|
||||
|
||||
class RunValidationAction(base.TripleOAction):
|
||||
"""Run the given validation"""
|
||||
def __init__(self, validation):
|
||||
def __init__(self, validation, plan=constants.DEFAULT_CONTAINER_NAME):
|
||||
super(RunValidationAction, self).__init__()
|
||||
self.validation = validation
|
||||
self.plan = plan
|
||||
|
||||
def run(self):
|
||||
mc = self._get_workflow_client()
|
||||
@ -95,7 +97,8 @@ class RunValidationAction(base.TripleOAction):
|
||||
identity_file = utils.write_identity_file(private_key)
|
||||
|
||||
stdout, stderr = utils.run_validation(self.validation,
|
||||
identity_file)
|
||||
identity_file,
|
||||
self.plan)
|
||||
return_value = {'stdout': stdout, 'stderr': stderr}
|
||||
mistral_result = (return_value, None)
|
||||
except ProcessExecutionError as e:
|
||||
|
@ -19,6 +19,7 @@ from mistral.workflow import utils as mistral_workflow_utils
|
||||
from oslo_concurrency.processutils import ProcessExecutionError
|
||||
|
||||
from tripleo_common.actions import validations
|
||||
from tripleo_common import constants
|
||||
from tripleo_common.tests import base
|
||||
from tripleo_common.tests.utils import test_validations
|
||||
|
||||
@ -119,8 +120,10 @@ class RunValidationActionTest(base.TestCase):
|
||||
error=None)
|
||||
self.assertEqual(expected, action.run())
|
||||
mock_write_identity_file.assert_called_once_with('shhhh')
|
||||
mock_run_validation.assert_called_once_with('validation',
|
||||
'identity_file_path')
|
||||
mock_run_validation.assert_called_once_with(
|
||||
'validation',
|
||||
'identity_file_path',
|
||||
constants.DEFAULT_CONTAINER_NAME)
|
||||
mock_cleanup_identity_file.assert_called_once_with(
|
||||
'identity_file_path')
|
||||
|
||||
@ -149,7 +152,9 @@ class RunValidationActionTest(base.TestCase):
|
||||
})
|
||||
self.assertEqual(expected, action.run())
|
||||
mock_write_identity_file.assert_called_once_with('shhhh')
|
||||
mock_run_validation.assert_called_once_with('validation',
|
||||
'identity_file_path')
|
||||
mock_run_validation.assert_called_once_with(
|
||||
'validation',
|
||||
'identity_file_path',
|
||||
constants.DEFAULT_CONTAINER_NAME)
|
||||
mock_cleanup_identity_file.assert_called_once_with(
|
||||
'identity_file_path')
|
||||
|
@ -193,7 +193,8 @@ class RunValidationTest(base.TestCase):
|
||||
mock_execute.return_value = 'output'
|
||||
mock_find_validation.return_value = 'validation_path'
|
||||
|
||||
result = validations.run_validation('validation', 'identity_file')
|
||||
result = validations.run_validation('validation', 'identity_file',
|
||||
'plan')
|
||||
self.assertEqual('output', result)
|
||||
mock_execute.assert_called_once_with(
|
||||
'/usr/bin/sudo', '-u', 'validations',
|
||||
@ -203,6 +204,7 @@ class RunValidationTest(base.TestCase):
|
||||
'OS_TENANT_NAME=project_name',
|
||||
'/usr/bin/run-validation',
|
||||
'validation_path',
|
||||
'identity_file'
|
||||
'identity_file',
|
||||
'plan'
|
||||
)
|
||||
mock_find_validation.assert_called_once_with('validation')
|
||||
|
@ -77,7 +77,7 @@ def find_validation(validation):
|
||||
return '{}/{}.yaml'.format(constants.DEFAULT_VALIDATIONS_PATH, validation)
|
||||
|
||||
|
||||
def run_validation(validation, identity_file):
|
||||
def run_validation(validation, identity_file, plan):
|
||||
ctx = context.ctx()
|
||||
return processutils.execute(
|
||||
'/usr/bin/sudo', '-u', 'validations',
|
||||
@ -87,7 +87,8 @@ def run_validation(validation, identity_file):
|
||||
'OS_TENANT_NAME={}'.format(ctx.project_name),
|
||||
'/usr/bin/run-validation',
|
||||
find_validation(validation),
|
||||
identity_file
|
||||
identity_file,
|
||||
plan
|
||||
)
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ workflows:
|
||||
type: direct
|
||||
input:
|
||||
- validation_name
|
||||
- plan: overcloud
|
||||
- queue_name: tripleo
|
||||
|
||||
tasks:
|
||||
@ -23,13 +24,14 @@ workflows:
|
||||
type: tripleo.validations.v1.run_validation
|
||||
payload:
|
||||
validation_name: <% $.validation_name %>
|
||||
plan: <% $.plan %>
|
||||
status: RUNNING
|
||||
execution: <% execution() %>
|
||||
|
||||
run_validation:
|
||||
on-success: send_message
|
||||
on-error: set_status_failed
|
||||
action: tripleo.validations.run_validation validation=<% $.validation_name %>
|
||||
action: tripleo.validations.run_validation validation=<% $.validation_name %> plan=<% $.plan %>
|
||||
publish:
|
||||
status: SUCCESS
|
||||
stdout: <% task(run_validation).result.stdout %>
|
||||
@ -51,6 +53,7 @@ workflows:
|
||||
type: tripleo.validations.v1.run_validation
|
||||
payload:
|
||||
validation_name: <% $.validation_name %>
|
||||
plan: <% $.plan %>
|
||||
status: <% $.get('status', 'SUCCESS') %>
|
||||
stdout: <% $.stdout %>
|
||||
stderr: <% $.stderr %>
|
||||
@ -60,6 +63,7 @@ workflows:
|
||||
type: direct
|
||||
input:
|
||||
- validation_names: []
|
||||
- plan: overcloud
|
||||
- queue_name: tripleo
|
||||
|
||||
tasks:
|
||||
@ -74,13 +78,14 @@ workflows:
|
||||
type: tripleo.validations.v1.run_validations
|
||||
payload:
|
||||
validation_names: <% $.validation_names %>
|
||||
plan: <% $.plan %>
|
||||
status: RUNNING
|
||||
execution: <% execution() %>
|
||||
|
||||
run_validations:
|
||||
on-success: send_message
|
||||
on-error: set_status_failed
|
||||
workflow: tripleo.validations.v1.run_validation validation_name=<% $.validation %> queue_name=<% $.queue_name %>
|
||||
workflow: tripleo.validations.v1.run_validation validation_name=<% $.validation %> plan=<% $.plan %> queue_name=<% $.queue_name %>
|
||||
with-items: validation in <% $.validation_names %>
|
||||
publish:
|
||||
status: SUCCESS
|
||||
@ -99,6 +104,7 @@ workflows:
|
||||
type: tripleo.validations.v1.run_validations
|
||||
payload:
|
||||
validation_names: <% $.validation_names %>
|
||||
plan: <% $.plan %>
|
||||
status: <% $.get('status', 'SUCCESS') %>
|
||||
execution: <% execution() %>
|
||||
|
||||
@ -106,6 +112,7 @@ workflows:
|
||||
type: direct
|
||||
input:
|
||||
- group_names: []
|
||||
- plan: overcloud
|
||||
- queue_name: tripleo
|
||||
|
||||
tasks:
|
||||
@ -127,13 +134,14 @@ workflows:
|
||||
payload:
|
||||
group_names: <% $.group_names %>
|
||||
validation_names: <% $.validations.id %>
|
||||
plan: <% $.plan %>
|
||||
status: RUNNING
|
||||
execution: <% execution() %>
|
||||
|
||||
run_validation_group:
|
||||
on-success: send_message
|
||||
on-error: set_status_failed
|
||||
workflow: tripleo.validations.v1.run_validation validation_name=<% $.validation %> queue_name=<% $.queue_name %>
|
||||
workflow: tripleo.validations.v1.run_validation validation_name=<% $.validation %> plan=<% $.plan %> queue_name=<% $.queue_name %>
|
||||
with-items: validation in <% $.validations.id %>
|
||||
publish:
|
||||
status: SUCCESS
|
||||
@ -153,6 +161,7 @@ workflows:
|
||||
payload:
|
||||
group_names: <% $.group_names %>
|
||||
validation_names: <% $.validations.id %>
|
||||
plan: <% $.plan %>
|
||||
status: <% $.get('status', 'SUCCESS') %>
|
||||
execution: <% execution() %>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user