Andrey Kurilin 859924eeb4 Various improvements for rally-task-at-devstack job
* Move zuul configuration to .zuul.d directory. It allows to place job
  definitions into separate files (we have a lot of jobs).
* Copy `extra` files to the right folder
* Add check for rally results directory existance before fetching it
* Stop play if `rally task start` fails with unexpected error code
* Export RALLY_PLUGINS_DIR and RALLY_EXTRA_DIR environment variables
  before launching rally task, to provide backward compatibility.
  (see https://github.com/openstack/mistral/blob/master/rally-jobs/task-mistral.yaml#L1 )
* Save one line message about happened error
* Load custom plugins

Change-Id: I1004afb29b9c173e414c59ef54bf58458b5d9422
2018-03-05 16:29:10 +02:00

41 lines
1.4 KiB
YAML

- name: Run Rally task
become: True
become_user: stack
shell:
cmd: |
export RALLY_PLUGINS_DIR="{{ rally_home_dir }}/plugins"
export RALLY_EXTRA_DIR="{{ rally_home_dir }}/extra"
rally --rally-debug --plugin-paths "{{ rally_home_dir }}/plugins" task start --task {{ rally_home_dir }}/task.yaml #--task-args-file {{ rally_home_dir }}/task_args_file.yaml
executable: /bin/bash
register: command_result
ignore_errors: True
- name: Check rally task exit code
become: True
become_user: stack
shell:
cmd: |
STATUS="OK"
EXIT_CODE=0
if [ "{{ command_result.rc }}" -eq "2" ]; then
STATUS="At least one workload did not pass SLA criteria."
EXIT_CODE=0
# actually, InvalidTaskException has 457 error code, but exit codes are
# limited by the range 0-255 . So 457 means 201... need to fix exit
# codes
elif [ "{{ command_result.rc }} " -eq "201" ]; then
STATUS="Task config is invalid. Check logs for validation errors."
# no results can be produced. stop play
EXIT_CODE=1
elif [ "{{ command_result.rc }}" -ne "0" ]; then
STATUS="Unexpected error had happened while launching Rally task. Check logs for more details."
EXIT_CODE=1
fi
# dump status, so it can be parsed in post script
echo "$STATUS" > "{{ rally_results_dir }}/status.txt"
exit $EXIT_CODE