Prepare for orchestrated run
We've using orchestrated steps via regular state.apply which regulary
failes with "Minion didn't respond" error.
At the same time we don't have any troubles with orchestrated runs
in keystone.orchestrated deploy for fernet tokens.
This patch prepares runtest to be running by salt orchestrate:
salt-run state.orchestrate runtest.orchestrate.tempest
Tempest config generation is moved to own sls: runtest.generate_tempest_config
put_local_image task is replaced to wget based cmd.run
Pass only small amount of pillar to put_local_image file,
as it was discovered this actually leads to failure.
Change-Id: Ie9838f025efc6800ea4b0a292c939cda657e560c
Related-Prod: PROD-25048
diff --git a/runtest/generate_tempest_config.sls b/runtest/generate_tempest_config.sls
new file mode 100644
index 0000000..691edde
--- /dev/null
+++ b/runtest/generate_tempest_config.sls
@@ -0,0 +1,14 @@
+{%- from "runtest/map.jinja" import tempest with context %}
+
+tempest_config_dir:
+ file.directory:
+ - name: {{ tempest.cfg_dir }}
+ - makedirs: true
+ - mode: 755
+
+tempest_config_file:
+ runtest.tempestconf_present:
+ - name: {{ tempest.cfg_dir }}/{{ tempest.cfg_name }}
+ - regenerate: {{ tempest.regenerate_conf }}
+ - require:
+ - file: tempest_config_dir
diff --git a/runtest/orchestrate/tempest.sls b/runtest/orchestrate/tempest.sls
new file mode 100644
index 0000000..c0f1b07
--- /dev/null
+++ b/runtest/orchestrate/tempest.sls
@@ -0,0 +1,58 @@
+{%- from "runtest/map.jinja" import tempest with context %}
+{%- if tempest.get('enabled', False) -%}
+
+generate_config:
+ salt.state:
+ - tgt: 'I@salt:master:enabled:true'
+ - tgt_type: compound
+ - sls: runtest.generate_tempest_config
+
+ {%- if tempest.test_target is defined %}
+create_on_target:
+ salt.function:
+ - tgt: {{ tempest.test_target }}
+ - tgt_type: compound
+ - name: file.mkdir
+ - arg:
+ - {{ tempest.cfg_dir }}
+
+copy_to_target:
+ cmd.run:
+ - name: salt-cp {{ tempest.test_target }} {{ tempest.cfg_dir }}/{{ tempest.cfg_name }} {{ tempest.cfg_dir }}/{{ tempest.cfg_name }}
+ - require:
+ - salt: create_on_target
+
+mine_send_keystonerc_file:
+ salt.function:
+ - tgt: 'I@keystone:server and *01*'
+ - tgt_type: compound
+ - name: mine.send
+ - arg:
+ - 'keystonerc_file'
+ - 'mine_function=cmd.shell'
+ - 'cat {{ tempest.keystonerc }}'
+
+ {%- if tempest.put_keystone_rc_enabled %}
+put_keystone_rc_file:
+ salt.state:
+ - tgt: {{ tempest.test_target }}
+ - tgt_type: compound
+ - sls: runtest.put_keystone_file
+ - require:
+ - salt: mine_send_keystonerc_file
+ {%- endif %}
+
+ {%- if tempest.put_local_image_file_enabled %}
+put_local_image_file:
+ salt.state:
+ - tgt: {{ tempest.test_target }}
+ - tgt_type: compound
+ - sls: runtest.put_local_image_file
+ - pillar: {'runtest': {{ pillar.get('runtest',{}) }} }
+ - require:
+ - generate_config
+ {%- endif %}
+
+ {%- endif %}
+
+{%- endif -%}
diff --git a/runtest/put_local_image_file.sls b/runtest/put_local_image_file.sls
index d6c3579..ebd863f 100644
--- a/runtest/put_local_image_file.sls
+++ b/runtest/put_local_image_file.sls
@@ -3,8 +3,13 @@
{%- set img_dir = tempest.get('scenario', {}).get('img_dir', '/tmp') %}
{%- set img_file = tempest.get('scenario', {}).get('img_file', 'cirros.img') %}
+test_image_dir_present:
+ file.directory:
+ - name: {{ img_dir }}
+
test_image_file:
- file.managed:
- - source: {{ tempest.local_image_url }}
- - name: {{ img_dir }}/{{ img_file }}
- - skip_verify: true
\ No newline at end of file
+ cmd.run:
+ - name: wget --tries=5 -O {{ img_dir }}/{{ img_file }} {{ tempest.local_image_url }} -q
+ - unless: test -f {{ img_dir }}/{{ img_file }}
+ - require:
+ - file: {{ img_dir }}
diff --git a/runtest/tempest.sls b/runtest/tempest.sls
index fbd60f5..2822b1b 100644
--- a/runtest/tempest.sls
+++ b/runtest/tempest.sls
@@ -1,18 +1,10 @@
+{# Calling this file is deprecated in favor of runtest.orchestrate.tempest #}
+{# which should be called via salt-run state.orchestrate runtest.orchestrate.tempest #}
{%- from "runtest/map.jinja" import tempest with context %}
{%- if tempest.get('enabled', False) -%}
-tempest_config_dir:
- file.directory:
- - name: {{ tempest.cfg_dir }}
- - makedirs: true
- - mode: 755
-
-tempest_config_file:
- runtest.tempestconf_present:
- - name: {{ tempest.cfg_dir }}/{{ tempest.cfg_name }}
- - regenerate: {{ tempest.regenerate_conf }}
- - require:
- - file: tempest_config_dir
+include:
+ - runtest.generate_tempest_config
{%- if tempest.test_target is defined %}
create_on_target:
@@ -57,16 +49,9 @@
- tgt_type: compound
- sls: runtest.put_local_image_file
- concurrent: true
- - pillar: {{ pillar }}
+ - pillar: {'runtest': {{ pillar.get('runtest', {}) }} }
- require:
- - tempest_config_file
- {# Sometimes this task hangs infinitely when using salt 2017.7.0 #}
- {%- if salt['grains.get']('saltversion') >= '2017.7.0' %}
- - retry:
- attempts: 3
- until: True
- interval: 10
- {%- endif %}
+ - sls: runtest.generate_tempest_config
{%- endif %}
{%- endif %}