openstack-ansible-repo_build/tests/test-repo-build.yml
Jesse Pretorius 98fcbb28eb Update repo_build test-vars data
This updates the repo_build data to the current
package list output from the py_pkgs lookup.

It also changes the implementation of how the
test data is stored and consumed to make it easier
to maintain in the future.

Some line spacing is also added to the test playbook
to make the tasks easier to distinguish.

Depends-On: https://review.openstack.org/568621
Change-Id: Icf102a78fd0cf9aae3c09378235f2d91f7db8cdd
2018-05-15 16:35:14 +01:00

179 lines
7.3 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# 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.
- name: Build repo
hosts: repo_all
user: root
vars:
test_data_file_path: "{{ lookup('env', 'WORKING_DIR') }}/tests/test-data.yml"
vars_files:
- test-vars.yml
pre_tasks:
# Test data output from the py_pkgs lookup
# To produce a fresh version of this, execute:
# /opt/ansible-runtime/bin/python /etc/ansible/roles/plugins/lookup/py_pkgs.py \
# /opt/openstack-ansible /etc/ansible/roles /etc/openstack_deploy | \
# /opt/ansible-runtime/bin/python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)'
# then perform the final minor adjustment of the top-end structure to fit the current structure
- name: Import the test data
set_fact:
local_packages:
results:
-
item:
"{{ (lookup('file', test_data_file_path) | from_yaml)[0] }}"
- name: Check if this is an OpenStack-CI nodepool instance
stat:
path: /etc/nodepool/provider
register: nodepool
delegate_to: localhost
- name: Determine the existing Ubuntu repo URL (only on OpenStack-CI)
shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list'
register: ubuntu_repo_url
changed_when: false
when:
- ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool
delegate_to: localhost
- name: Set Ubuntu Cloud Archive repo URL based on discovered information
set_fact:
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
when:
- ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool
roles:
- "repo_build"
post_tasks:
- name: List the files in the venv folder
command: ls -1 {{ repo_build_venv_dir }}/
register: venv_folder_content
changed_when: false
- name: Ensure that the keystone venv is present
assert:
that: "'keystone-{{ repo_build_release_tag }}-{{ ansible_architecture | lower }}.tgz' in venv_folder_content.stdout"
- name: Ensure that the tempest venv is present
assert:
that: "'tempest-{{ repo_build_release_tag }}-{{ ansible_architecture | lower }}.tgz' in venv_folder_content.stdout"
- name: Ensure that the nova venv is NOT present
assert:
that: "'nova-{{ repo_build_release_tag }}-{{ ansible_architecture | lower }}.tgz' not in venv_folder_content.stdout"
- name: List the files in the git folder
command: ls -1 /var/www/repo/openstackgit/
register: git_folder_content
changed_when: false
- name: Ensure that the keystone git repo is present
assert:
that: "'keystone' in git_folder_content.stdout"
- name: Ensure that the tempest git repo is present
assert:
that: "'tempest' in git_folder_content.stdout"
- name: Ensure that the requirements git repo is present
assert:
that: "'requirements' in git_folder_content.stdout"
- name: Ensure that the nova git repo is NOT present
assert:
that: "'nova' not in git_folder_content.stdout"
- name: Slurp upper constraints
slurp:
src: "{{ repo_build_git_dir }}/requirements/upper-constraints.txt"
register: slurp_upper_constraints
- name: Slurp requirements constraints
slurp:
src: "{{ repo_build_release_path }}/requirements_constraints.txt"
register: slurp_requirements_constraints
- name: Set fact for requirements constraints content
set_fact:
requirements_constraints_content: "{{ slurp_requirements_constraints.content | b64decode }}"
- name: Set fact for upper constraints content
set_fact:
upper_constraints_list: >
{%- set constraints = [] %}
{%- for constraint_raw in slurp_upper_constraints.content | b64decode | splitlines %}
{%- set constraint_name = constraint_raw | regex_replace('===.*', '') %}
{%- set constraint_data = constraint_raw | regex_replace('.*===', '') %}
{%- set constraint_name_normalized = constraint_name | replace('-', '_') | lower %}
{%- set constraint = constraint_name_normalized + '<=' + constraint_data %}
{%- set _ = constraints.append(constraint) %}
{%- endfor %}
{{- constraints -}}
- name: Set fact for upper constraints override
set_fact:
upper_constraints_override_list: >
{%- set override_packages = [] %}
{%- for override in repo_build_upper_constraints_overrides %}
{%- set name = override | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') %}
{%- set name_normalized = name | replace('-', '_') | lower %}
{%- set _ = override_packages.append(name_normalized) %}
{%- endfor %}
{{- override_packages -}}
- name: Set fact for global pins
set_fact:
global_pins_list: >
{%- set global_pins = [] %}
{%- for pin in local_packages.results.0.item.role_requirement_files.global_pins.pinned_packages %}
{%- set name = pin | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') %}
{%- set name_normalized = name | replace('-', '_') | lower %}
{%- set _ = global_pins.append(name_normalized) %}
{%- endfor %}
{{- global_pins -}}
- name: Set facts for packages built from git sources
set_fact:
git_package_list: >
{%- set git_packages = [] %}
{%- for remote_package_part in local_packages.results.0.item.remote_package_parts %}
{%- set _ = git_packages.append(remote_package_part['egg_name']) %}
{%- endfor %}
{{- git_packages -}}
- name: Ensure that upper constraints from the OpenStack requirements repo are complete
assert:
that: item in requirements_constraints_content
with_items: "{{ upper_constraints_list }}"
when:
- repo_build_use_upper_constraints | bool
- item | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') not in upper_constraints_override_list
- item | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') not in global_pins_list
- item | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') not in git_package_list
- name: Ensure that global pins have been applied
assert:
that: item in requirements_constraints_content
with_items: "{{ local_packages.results.0.item.role_requirement_files.global_pins.pinned_packages }}"
when:
- item | regex_replace('(\[|>=|<=|>|<|==|~=|!=).*$','') not in upper_constraints_override_list
- name: Ensure that upper constraints overrides are applied
assert:
that: item in requirements_constraints_content
with_items: "{{ repo_build_upper_constraints_overrides }}"