summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Hesketh <josh@nitrotech.org>2014-01-18 16:09:54 +1100
committerJoshua Hesketh <josh@nitrotech.org>2014-01-20 11:28:52 +1100
commitc73328c444a29803ca7e268ec72ab0447cd9307e (patch)
tree63d60682d5f55e8faf00d9188a6429868eadf4c6
parent2be429485ed3c41b509e3337867952cfb7af0bb0 (diff)
downloadturbo-hipster-c73328c444a29803ca7e268ec72ab0447cd9307e.tar.gz
Continue prepping generic shell execution
Change-Id: Ie4c8b849f9ed2d80c09104a8b2e0a30f143b2cbb
-rw-r--r--turbo_hipster/lib/models.py43
-rw-r--r--turbo_hipster/task_plugins/gate_real_db_upgrade/task.py2
-rw-r--r--turbo_hipster/task_plugins/shell_script/__init__.py0
-rw-r--r--turbo_hipster/task_plugins/shell_script/task.py27
4 files changed, 66 insertions, 6 deletions
diff --git a/turbo_hipster/lib/models.py b/turbo_hipster/lib/models.py
index 66f26c8..d4a2738 100644
--- a/turbo_hipster/lib/models.py
+++ b/turbo_hipster/lib/models.py
@@ -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
@@ -167,9 +172,37 @@ class ShellTask(Task):
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):
diff --git a/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py b/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py
index 24313c0..d02bed0 100644
--- a/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py
+++ b/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py
@@ -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
diff --git a/turbo_hipster/task_plugins/shell_script/__init__.py b/turbo_hipster/task_plugins/shell_script/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/turbo_hipster/task_plugins/shell_script/__init__.py
diff --git a/turbo_hipster/task_plugins/shell_script/task.py b/turbo_hipster/task_plugins/shell_script/task.py
new file mode 100644
index 0000000..6deef4e
--- /dev/null
+++ b/turbo_hipster/task_plugins/shell_script/task.py
@@ -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")