Continue prepping generic shell execution
Change-Id: Ie4c8b849f9ed2d80c09104a8b2e0a30f143b2cbb
This commit is contained in:
parent
2be429485e
commit
c73328c444
@ -124,24 +124,29 @@ class ShellTask(Task):
|
||||
def __init__(self, global_config, plugin_config, job_name):
|
||||
super(ShellTask, self).__init__(global_config, plugin_config, job_name)
|
||||
# Define the number of steps we will do to determine our progress.
|
||||
self.total_steps = 4
|
||||
self.total_steps = 5
|
||||
|
||||
def _reset(self):
|
||||
super(ShellTask, self)._reset()
|
||||
self.git_path = None
|
||||
self.job_working_dir = None
|
||||
self.shell_output_log = None
|
||||
|
||||
def do_job_steps(self, job):
|
||||
# Step 1: Checkout updates from git
|
||||
self._grab_patchset(self.job_arguments,
|
||||
self.job_datasets[0]['job_log_file_path'])
|
||||
|
||||
# Step 2: Run shell script
|
||||
# Step 2: Prep job working dir
|
||||
self._prep_working_dir()
|
||||
|
||||
# Step 3: Run shell script
|
||||
self._execute_script()
|
||||
|
||||
# Step 3: Analyse logs for errors
|
||||
# Step 4: Analyse logs for errors
|
||||
self._parse_and_check_results()
|
||||
|
||||
# Step 4: handle the results (and upload etc)
|
||||
# Step 5: handle the results (and upload etc)
|
||||
self._handle_results()
|
||||
|
||||
@common.task_step
|
||||
@ -166,10 +171,38 @@ class ShellTask(Task):
|
||||
self.git_path = local_path
|
||||
return local_path
|
||||
|
||||
@common.task_step
|
||||
def _prep_working_dir(self):
|
||||
self.job_working_dir = os.path.join(
|
||||
self.global_config['jobs_working_dir'],
|
||||
utils.determine_job_identifier(self.job_arguments,
|
||||
self.plugin_config['function'],
|
||||
self.job.unique)
|
||||
)
|
||||
self.shell_output_log = os.path.join(
|
||||
self.job_working_dir,
|
||||
'shell_output.log'
|
||||
)
|
||||
|
||||
if not os.path.isdir(os.path.dirname(self.shell_output_log)):
|
||||
os.makedirs(os.path.dirname(self.shell_output_log))
|
||||
|
||||
@common.task_step
|
||||
def _execute_script(self):
|
||||
# Run script
|
||||
self.script_return_code = 0
|
||||
cmd = self.plugin_config['shell_script']
|
||||
cmd += (
|
||||
(' %(git_path)s %(job_working_dir)s %(unique_id)s')
|
||||
% {
|
||||
'git_path': self.git_path,
|
||||
'job_working_dir': self.job_working_dir,
|
||||
'unique_id': self.job.unique
|
||||
}
|
||||
)
|
||||
self.script_return_code = utils.execute_to_log(
|
||||
cmd,
|
||||
self.shell_output_log
|
||||
)
|
||||
|
||||
@common.task_step
|
||||
def _parse_and_check_results(self):
|
||||
|
@ -48,7 +48,7 @@ class Runner(models.ShellTask):
|
||||
self.job_datasets = []
|
||||
|
||||
# Define the number of steps we will do to determine our progress.
|
||||
self.total_steps = 5
|
||||
self.total_steps = 6
|
||||
|
||||
def do_job_steps(self):
|
||||
# Step 1: Figure out which datasets to run
|
||||
|
0
turbo_hipster/task_plugins/shell_script/__init__.py
Normal file
0
turbo_hipster/task_plugins/shell_script/__init__.py
Normal file
27
turbo_hipster/task_plugins/shell_script/task.py
Normal file
27
turbo_hipster/task_plugins/shell_script/task.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2013 Rackspace Australia
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, 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.
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
from turbo_hipster.lib import models
|
||||
|
||||
|
||||
class Runner(models.ShellTask):
|
||||
|
||||
""" This thread handles the actual sql-migration tests.
|
||||
It pulls in a gearman job from the build:gate-real-db-upgrade
|
||||
queue and runs it through _handle_patchset"""
|
||||
|
||||
log = logging.getLogger("task_plugins.gate_real_db_upgrade.task.Runner")
|
Loading…
x
Reference in New Issue
Block a user