Merge "[tripleo_transfer] Add more thorough testing"
This commit is contained in:
commit
8de6d050fc
|
@ -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 }}"
|
|
@ -27,9 +27,39 @@
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
roles:
|
tasks:
|
||||||
- role: "tripleo_transfer"
|
- name: Install openssl for file creation
|
||||||
tripleo_transfer_src_host: controller2
|
package:
|
||||||
tripleo_transfer_src_dir: /etc
|
name: openssl
|
||||||
tripleo_transfer_dest_host: controller1
|
state: present
|
||||||
tripleo_transfer_dest_dir: /opt/etc-target
|
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 }}"
|
||||||
|
|
|
@ -36,13 +36,27 @@ provisioner:
|
||||||
ansible_host: 127.0.0.2
|
ansible_host: 127.0.0.2
|
||||||
controller2:
|
controller2:
|
||||||
ansible_host: 127.0.0.3
|
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
|
log: true
|
||||||
env:
|
env:
|
||||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||||
|
|
||||||
scenario:
|
scenario:
|
||||||
test_sequence:
|
test_sequence:
|
||||||
|
- cleanup
|
||||||
- converge
|
- converge
|
||||||
|
- verify
|
||||||
|
- cleanup
|
||||||
|
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: ansible
|
||||||
|
|
|
@ -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…
Reference in New Issue