[ci] Generate a real raw and qcow2 image sfor tests

Also, this reduces payloadin neutron-trunk job. There is no indent to
test neutron as a part of Rally CI. And adds basic linting for ansible

Change-Id: I8129ae939d24d59688a535cdbbeff5d5f89f45c7
This commit is contained in:
Andriy Kurilin 2025-03-01 14:19:40 +01:00
parent a1e29cdebe
commit 4a9a54864f
25 changed files with 190 additions and 108 deletions

View File

@ -134,7 +134,7 @@
roles:
- admin
images:
image_url: "~/.rally/extra/fake-image.img"
image_url: "~/.rally/extra/dummy_image.raw"
disk_format: "raw"
container_format: "bare"
images_per_tenant: 1

View File

@ -456,7 +456,7 @@
tenants: 2
users_per_tenant: 1
images:
image_url: "~/.rally/extra/fake-image.img"
image_url: "~/.rally/extra/dummy_image.qcow2"
disk_format: "qcow2"
container_format: "bare"
images_per_tenant: 2
@ -467,7 +467,7 @@
GlanceImages.create_and_list_image:
-
args:
image_location: "~/.rally/extra/fake-image.img"
image_location: "~/.rally/extra/dummy_image.qcow2"
container_format: "bare"
disk_format: "qcow2"
runner:
@ -484,6 +484,25 @@
sla:
failure_rate:
max: 100
-
args:
image_location: "~/.rally/extra/dummy_image.raw"
container_format: "bare"
disk_format: "raw"
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
api_versions:
glance:
version: 2
sla:
failure_rate:
max: 100
SwiftObjects.create_container_and_object_then_list_objects:
-

View File

@ -6,11 +6,11 @@
-
args:
network_create_args: {}
subport_count: 10
subport_count: 5
runner:
type: "constant"
times: 100
concurrency: 10
times: 10
concurrency: 5
context:
users:
tenants: 3

View File

@ -0,0 +1,39 @@
# NOTE(andreykurilin): ansible-lint expects playbooks to be in a separate
# directory called 'playbooks'. There is no real reason for such structure
# and it also requires specific ansible config option to be specified so
# playbooks can find roles.
# https://docs.ansible.com/ansible/latest/user_guide/sample_setup.html#sample-directory-layout
# Despite the fact, ansible-lint has 'kinds' configuration option for
# specifying 'custom' structure, it doesn't support relative paths, so the
# name of repository is hardcoded here. Not the best solution, but should
# work as soon as nobody renames it locally :)
kinds:
- playbook: "**/rally_openstack/tests/ci/playbooks/*.{yml,yaml}"
mock_roles:
# zuul specific roles
- copy-build-sshkey
- multi-node-hosts-file
- multi-node-known-hosts
- bindep
- fetch-tox-output
- run-devstack
mock_modules:
- synchronize
- zuul_return
skip_list:
- no-changed-when # Commands should not change things if nothing needs doing
- unnamed-task # All tasks should be named
- fqcn[action-core] # Use FQCN for builtin module actions (shell)
- name[template] # Jinja templates should only be at the end of 'name'
- command-instead-of-shell # Use shell only when shell functionality is required.
- no-jinja-when # No Jinja2 in when.
# FIXME(andreykurilin): all the rules from the list bellow should be fixed
- key-order[play]
- name[play]
- risky-file-permissions
- risky-shell-pipe
- var-naming[pattern]
- command-instead-of-module

View File

@ -5,22 +5,22 @@
tasks:
- shell: "ls {{ rally_results_dir }}"
register: results_dir_stat
ignore_errors: True
ignore_errors: true
- name: Save results
become: yes
become: true
when: results_dir_stat.rc == 0
synchronize:
src: "{{ rally_results_dir }}{% if not rally_results_dir.endswith('/')%}/{% endif %}"
src: "{{ rally_results_dir }}{% if not rally_results_dir.endswith('/') %}/{% endif %}"
dest: '{{ zuul.executor.log_root }}/'
mode: pull
copy_links: true
verify_host: true
rsync_opts:
- --include=/**
- --include=*/
- --exclude=*
- --prune-empty-dirs
- --include=/**
- --include=*/
- --exclude=*
- --prune-empty-dirs
- name: "Return artifact to Zuul - {{ html_report }}"
zuul_return:
@ -31,7 +31,7 @@
url: "{{ html_report }}"
when: html_report in results_dir_stat.stdout
- name: "Return artifact to Zuul - {{ json_report}}"
- name: "Return artifact to Zuul - {{ json_report }}"
zuul_return:
data:
zuul:

View File

@ -24,4 +24,4 @@
- --include=/**
- --include=*/
- --exclude=*
- --prune-empty-dirs
- --prune-empty-dirs

View File

@ -1,4 +1,4 @@
- name: Check SLA of the last task
become: True
become: true
become_user: stack
shell: "rally task sla-check > {{ rally_results_dir }}/sla.txt"

View File

@ -3,4 +3,4 @@ docker_image_version: "{{ zuul.tag }}"
docker_image_tag: "{{ docker_repository }}:{{ docker_image_version }}"
rally_project_path: "{{ zuul.projects['opendev.org/openstack/rally'].src_dir }}"
rally_plugin_name: "Dummy.dummy"
rally_package_name: ""
rally_package_name: ""

View File

@ -25,8 +25,8 @@
fail:
msg: "{{ rally_package_name }} is not discoverable."
when:
- '"{{ rally_package_name }}" != ""'
- '"{{ rally_package_name }}" not in rally_version_info.stdout'
- '"{{ rally_package_name }}" != ""'
- '"{{ rally_package_name }}" not in rally_version_info.stdout'
- name: "Check availability of {{ rally_plugin_name }} plugin"
shell: docker run {{ docker_image_tag }} plugin show {{ rally_plugin_name }}

View File

@ -1,5 +1,7 @@
- name: Change the status message
become: yes
become: true
vars:
os_rally_src: "{{ zuul.projects['opendev.org/openstack/rally-openstack'].src_dir }}"
shell:
cmd: |
set -e
@ -10,7 +12,7 @@
fi
if [ "$MSG" != "OK" ]; then
sed -i -- "s/var errorMessage = null\;/var errorMessage = \'$MSG\';/g" {{ zuul.projects['opendev.org/openstack/rally-openstack'].src_dir }}/tests/ci/pages/task-index.html
sed -i -- "s/var errorMessage = null\;/var errorMessage = \'$MSG\';/g" {{ os_rally_src }}/tests/ci/pages/task-index.html
fi
- name: Check the existence of results dir
@ -19,15 +21,15 @@
register: results_dir_stat
- name: Gzip custom plugins
become: yes
become: true
become_user: stack
shell: "tar -czf {{ rally_results_dir }}/plugins.tar.gz ./plugins"
args:
chdir: '{{ rally_home_dir }}'
when: results_dir_stat.stat.exists == True
when: results_dir_stat.stat.exists
- name: Copy Rally results
become: yes
become: true
synchronize:
src: '{{ rally_results_dir }}'
dest: '{{ zuul.executor.log_root }}'
@ -39,10 +41,10 @@
- --include=*/
- --exclude=*
- --prune-empty-dirs
when: results_dir_stat.stat.exists == True
when: results_dir_stat.stat.exists
- name: Put index.html in the right place
become: yes
become: true
synchronize:
src: "{{ zuul.projects['opendev.org/openstack/rally-openstack'].src_dir }}/tests/ci/pages/task-index.html"
dest: '{{ zuul.executor.log_root }}/index.html'

View File

@ -1,9 +1,9 @@
- name: Import a current JSON report
become: True
become: true
become_user: stack
command: rally task import --file {{ rally_results_dir }}/report.json
- name: Import an old JSON report
become: True
become: true
become_user: stack
command: rally task import --file {{ rally_results_dir }}/results.json

View File

@ -1,3 +1,3 @@
compare: False
compare: false
resources_at_start_dest: '{{ rally_results_dir }}/resources_at_start.txt'
cleanup_error_msg: "OSResources check found resources which appeared after Rally Task execution. Check cleanup logs for errors."
cleanup_error_msg: "OSResources check found resources which appeared after Rally Task execution. Check cleanup logs for errors."

View File

@ -1,9 +1,9 @@
- name: Check OpenStack resources after Rally launch
become: yes
become: true
become_user: stack
osresources:
compare_with: "{{ resources_at_start_dest }}"
ignore_errors: yes
ignore_errors: true
register: command_result
- name: Check the existence of status.txt
@ -14,7 +14,7 @@
- name: Update status.txt
shell: echo "{{ cleanup_error_msg }}" > "{{ rally_results_dir }}/status.txt"
when: command_result.rc != 0 and custom_plugins_stat.stat.exists == False
when: command_result.rc != 0 and not custom_plugins_stat.stat.exists
- name: Fail if there are some resources left after Rally execution (for rally-openstack project)
fail:

View File

@ -1,9 +1,9 @@
- name: Save available OpenStack resources before Rally launch
become: yes
become: true
become_user: stack
osresources:
json_output: "{{ resources_at_start_dest }}"
ignore_errors: yes
ignore_errors: true
register: command_result
- name: Fail if there is an error while executing previos command (for rally-openstack project)

View File

@ -1,5 +1,7 @@
- include_tasks: list_resources.yaml
when: "{%- if compare|bool %}{% else %}True{% endif -%}"
when:
- not compare
- include_tasks: list_and_compare_resources.yaml
when: "{%- if compare|bool %}True{% endif -%}"
when:
- compare

View File

@ -1,4 +1,6 @@
rally_use_existing_users: False
rally_dummy_qcow2_image: ""
rally_dummy_raw_image: ""
rally_use_existing_users: false
existing_users_env_spec: '{{ rally_home_dir }}/env-with-existing-users-config'
projects_count: 2
users_per_project: 1

View File

@ -0,0 +1,13 @@
- name: Check the existence of dummy image
stat:
path: '{{ path_to_dummy_image }}'
register: dummy_image_stat
when: path_to_dummy_image
- name: Create a dummy image
become: true
become_user: stack
shell: "qemu-img create -f {{ dummy_image_type }} {{ path_to_dummy_image }} 100M"
when:
- path_to_dummy_image
- not dummy_image_stat.stat.exists

View File

@ -1,5 +1,5 @@
- name: Create Rally home directory
become: True
become: true
become_user: stack
file:
path: '{{ rally_home_dir }}'
@ -8,7 +8,7 @@
group: stack
- name: Create directory for Rally results
become: True
become: true
become_user: stack
file:
path: '{{ rally_results_dir }}'
@ -17,7 +17,7 @@
group: stack
- name: Create directory for OSProfiler reports
become: True
become: true
become_user: stack
file:
path: '{{ rally_results_dir }}/{{ RALLY_OSPROFILER_CHART }}'
@ -26,7 +26,7 @@
group: stack
- name: Extend Rally config with
become: True
become: true
become_user: stack
shell:
executable: /bin/bash
@ -35,7 +35,7 @@
echo "osprofiler_chart_mode={{ RALLY_OSPROFILER_CHART }}" >> /etc/rally/rally.conf
- name: Create a directory for custom plugins
become: True
become: true
become_user: stack
file:
path: '{{ rally_home_dir }}/plugins'
@ -49,13 +49,13 @@
register: custom_plugins_stat
- name: Copy custom plugins, if they are presented
become: True
become: true
become_user: stack
command: cp -r {{ custom_plugins_stat.stat.path }} {{ rally_home_dir }}/
when: custom_plugins_stat.stat.exists == True
when: custom_plugins_stat.stat.exists
- name: Create a directory for extra files
become: True
become: true
become_user: stack
file:
path: '{{ rally_home_dir }}/extra'
@ -69,26 +69,25 @@
register: extra_files_stat
- name: Copy extra files, if they are presented
become: True
become: true
become_user: stack
command: cp -r {{ extra_files_stat.stat.path }} {{ rally_home_dir }}/
when: extra_files_stat.stat.exists == True
when: extra_files_stat.stat.exists
- name: Check the existence of fake image
stat:
path: '{{ rally_fake_image_path }}'
register: fake_image_stat
- name: Create dummy raw image
include_tasks: "create_dummy_image.yaml"
vars:
dummy_image_type: "raw"
path_to_dummy_image: "{{ rally_dummy_raw_image }}"
- name: Create a fake image
become: True
become_user: stack
file:
path: '{{ rally_fake_image_path }}'
state: touch
when: fake_image_stat.stat.exists == False
- name: Create dummy qcow2 image
include_tasks: "create_dummy_image.yaml"
vars:
dummy_image_type: "qcow2"
path_to_dummy_image: "{{ rally_dummy_qcow2_image }}"
- name: List glance, cinder, neutron resources
become: True
become: true
become_user: stack
shell:
executable: /bin/bash
@ -111,25 +110,25 @@
fi
- name: Print Rally environment config
become: True
become: true
become_user: stack
command: "rally env show --only-spec"
- include_tasks: prepare-env-with-existing-users.yaml
when: rally_use_existing_users == True
when: rally_use_existing_users
- name: Check Environment works
become: True
become: true
become_user: stack
command: "rally --debug env check"
- name: Print Environment info
become: True
become: true
become_user: stack
command: "rally env info"
- name: Create nova flavor
become: True
become: true
become_user: stack
shell:
executable: /bin/sh
@ -151,13 +150,13 @@
- name: Fail if Rally task file is missed.
fail:
msg: "'{{ rally_task }}' Rally task file is missed."
when: rally_task_file_stat.stat.exists != True
when: not rally_task_file_stat.stat.exists
- name: Copy task file
become: True
become: true
become_user: stack
command: cp "{{ rally_task_file_stat.stat.path }}" "{{ rally_home_dir }}/task.yaml"
when: rally_task_file_stat.stat.exists == True
when: rally_task_file_stat.stat.exists
- name: Check the existence of task_args_file
stat:
@ -165,13 +164,13 @@
register: task_args_file_stat
- name: Copy task_args_file
become: True
become: true
become_user: stack
command: cp "{{ task_args_file_stat.stat.path }}" "{{ rally_home_dir }}/task_args_file.yaml"
when: task_args_file_stat.stat.exists == True
when: task_args_file_stat.stat.exists
- name: Create an empty task_args_file
become: True
become: true
become_user: stack
command: echo "{}" > "{{ rally_home_dir }}/task_args_file.yaml"
when: task_args_file_stat.stat.exists == False
when: not task_args_file_stat.stat.exists

View File

@ -1,5 +1,5 @@
- name: Create keystone projects & users for a new rally environment
become: yes
become: true
become_user: stack
make_env_spec_with_existing_users:
projects_count: "{{ projects_count }}"
@ -8,11 +8,11 @@
path_for_new_spec: "{{ existing_users_env_spec }}"
- name: Create a new Rally environment
become: True
become: true
become_user: stack
shell: rally env create --name devstask-with-users --spec "{{ existing_users_env_spec }}"
- name: Print new Rally env spec
become: True
become: true
become_user: stack
command: "rally env show --only-spec"

View File

@ -1,5 +1,5 @@
- name: Generate a HTML report
become: True
become: true
become_user: stack
shell:
executable: /bin/bash
@ -9,31 +9,31 @@
rally task report --html-static --out report.html
- name: Show detailed info about task
become: True
become: true
become_user: stack
shell: "rally task detailed > {{ rally_results_dir }}/detailed.txt"
- name: Show detailed info (with per-iteration data) about task
become: True
become: true
become_user: stack
shell: "rally task detailed --iterations-data > {{ rally_results_dir }}/detailed_with_iterations.txt"
- name: Generate a JSON report
become: True
become: true
become_user: stack
command: rally task report --json --out {{ rally_results_dir }}/report.json
- name: Produce an old results file
become: True
become: true
become_user: stack
shell: "rally task results > {{ rally_results_dir }}/results.json"
- name: Make a JUnit report
become: True
become: true
become_user: stack
command: rally task export --type junit-xml --to {{ rally_results_dir }}/junit.xml
- name: Make an ElasticSearch file
become: True
become: true
become_user: stack
command: rally task export --type elastic --to {{ rally_results_dir }}/elasticsearch.txt

View File

@ -1,5 +1,5 @@
- name: Run Rally task
become: True
become: true
become_user: stack
shell:
cmd: |
@ -10,10 +10,10 @@
rally --rally-debug 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
ignore_errors: true
- name: Check rally task exit code
become: True
become: true
become_user: stack
shell:
cmd: |

View File

@ -5,18 +5,19 @@
- hosts: controller
vars:
rally_home_dir: '/opt/stack/.rally'
rally_fake_image_path: '{{ rally_home_dir }}/extra/fake-image.img'
rally_dummy_qcow2_image: "{{ rally_home_dir }}/extra/dummy_image.qcow2"
rally_dummy_raw_image: "{{ rally_home_dir }}/extra/dummy_image.raw"
rally_results_dir: '{{ rally_home_dir }}/results'
rally_task_args_file: "100-percent-not-exist-file"
roles:
- prepare-for-rally-task
#- role: list-os-resources
# vars:
# compare: False
# - role: list-os-resources
# vars:
# compare: False
- run-rally-task
- process-task-results
- import-task-results
#- role: list-os-resources
# vars:
# compare: True
# - role: list-os-resources
# vars:
# compare: True
- check-task-sla

View File

@ -1,21 +1,21 @@
- hosts: all
roles:
- run-devstack
- run-devstack
- hosts: controller
tasks:
- name: Prepare env deployment for tempest
shell:
cmd: |
. /opt/stack/.rally/openrc admin admin
export OS_CACERT=/opt/stack/data/ca-bundle.pem
rally env create --from-sysenv --name tempest
rally env check
executable: /bin/bash
- name: Prepare env deployment for tempest
shell:
cmd: |
. /opt/stack/.rally/openrc admin admin
export OS_CACERT=/opt/stack/data/ca-bundle.pem
rally env create --from-sysenv --name tempest
rally env check
executable: /bin/bash
- name: Run Rally verify
shell: |
. /opt/stack/data/venv/bin/activate
python3 tests/ci/rally_verify.py
args:
chdir: "{{ zuul.project.src_dir }}"
- name: Run Rally verify
shell: |
. /opt/stack/data/venv/bin/activate
python3 tests/ci/rally_verify.py
args:
chdir: "{{ zuul.project.src_dir }}"

View File

@ -4,7 +4,6 @@
- hosts: controller
vars:
rally_fake_image_path: '{{ rally_home_dir }}/extra/fake-image.img'
rally_task_args_file: "100-percent-not-exist-file"
# this task will not be launched, but we need to specify something real to
# pass a check at 'prepare-for-rally-task' role.

View File

@ -36,6 +36,12 @@ passenv =
REPORTS_ROOT
PYTEST_REPORT
[testenv:zuul-ansible-lint]
setenv = VIRTUAL_ENV={envdir}
skip_install = true
deps = ansible-lint
commands = ansible-lint --strict --config-file tests/ci/playbooks/.ansible-lint tests/ci/playbooks
[testenv:pep8]
deps = -r{toxinidir}/test-requirements.txt
skip_install = true