Browse Source

Merge "[tripleo_transfer] Add more thorough testing"

changes/20/772920/14
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
8de6d050fc
4 changed files with 127 additions and 7 deletions
  1. +29
    -0
      tripleo_ansible/roles/tripleo_transfer/molecule/default/cleanup.yml
  2. +36
    -6
      tripleo_ansible/roles/tripleo_transfer/molecule/default/converge.yml
  3. +15
    -1
      tripleo_ansible/roles/tripleo_transfer/molecule/default/molecule.yml
  4. +47
    -0
      tripleo_ansible/roles/tripleo_transfer/molecule/default/verify.yml

+ 29
- 0
tripleo_ansible/roles/tripleo_transfer/molecule/default/cleanup.yml View File

@ -0,0 +1,29 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Cleanup
hosts: localhost
connection: local
gather_facts: false
any_errors_fatal: true
tasks:
- name: Remove test files
file:
state: absent
path: "{{ item }}"
loop:
- "{{ test_src_dir }}"
- "{{ test_dst_dir }}"

+ 36
- 6
tripleo_ansible/roles/tripleo_transfer/molecule/default/converge.yml View File

@ -27,9 +27,39 @@
hosts: localhost
connection: local
any_errors_fatal: true
roles:
- role: "tripleo_transfer"
tripleo_transfer_src_host: controller2
tripleo_transfer_src_dir: /etc
tripleo_transfer_dest_host: controller1
tripleo_transfer_dest_dir: /opt/etc-target
tasks:
- name: Install openssl for file creation
package:
name: openssl
state: present
become: true
- name: Create test directories
file:
state: directory
path: "{{ item }}"
loop:
- "{{ test_src_dir }}"
- "{{ test_dst_dir }}"
- name: Create 1GB src test files with random content
shell: >-
openssl rand -out {{ item }} -base64 $(( 2**30 * 3/4 ))
args:
chdir: "{{ test_src_dir }}"
creates: "{{ item }}"
loop: "{{ test_src_files }}"
- name: Create empty dst test files with random content
file:
path: "{{ test_dst_dir }}/{{ item }}"
state: touch
loop: "{{ test_dst_files }}"
- include_role:
name: "tripleo_transfer"
vars:
tripleo_transfer_src_host: controller2
tripleo_transfer_src_dir: "{{ test_src_dir }}"
tripleo_transfer_dest_host: controller1
tripleo_transfer_dest_dir: "{{ test_dst_dir }}"

+ 15
- 1
tripleo_ansible/roles/tripleo_transfer/molecule/default/molecule.yml View File

@ -36,13 +36,27 @@ provisioner:
ansible_host: 127.0.0.2
controller2:
ansible_host: 127.0.0.3
vars:
test_src_dir: "/tmp/src_files"
test_src_files:
- testfile1
- testfile2
- testfile3
test_dst_dir: "/tmp/dst_files"
test_dst_files:
- testfile4
- testfile5
- testfile6
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- cleanup
- converge
- verify
- cleanup
verifier:
name: testinfra
name: ansible

+ 47
- 0
tripleo_ansible/roles/tripleo_transfer/molecule/default/verify.yml View File

@ -0,0 +1,47 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Verify
hosts: localhost
connection: local
any_errors_fatal: true
tasks:
- name: Collect file system data
find:
paths:
- "{{ test_src_dir }}"
- "{{ test_dst_dir }}"
get_checksum: true
recurse: true
register: _fs_data
- name: Verify that the src files copied to the dst
assert:
that:
- _fs_data | json_query(srcfilequery) == _fs_data | json_query(dstfilequery)
vars:
srcfilequery: files[?path =='{{ test_src_dir }}/{{ item }}'].checksum
dstfilequery: files[?path =='{{ test_dst_dir }}/{{ item }}'].checksum
loop: "{{ test_src_files }}"
- set_fact:
result_file_list: "{{ _fs_data | json_query('files[*].path') }}"
test_dst_files: "{{ test_dst_files | map('regex_replace', '(.*)', test_dst_dir ~ '/\\1') }}"
- name: Verify that the dst file are not there any more
assert:
that:
- test_dst_files is not subset(result_file_list)

Loading…
Cancel
Save