|
30 | 30 | tasks: |
31 | 31 | - name: Run Pytest tests |
32 | 32 | block: |
33 | | - - name: Create tempdir for code to test |
34 | | - tempfile: |
35 | | - state: directory |
36 | | - prefix: lsrtest_ |
37 | | - register: _rundir |
38 | | - |
39 | | - - name: Get tempfile for tar |
40 | | - tempfile: |
41 | | - prefix: lsrtest_ |
42 | | - suffix: ".tar" |
43 | | - register: temptar |
44 | | - delegate_to: localhost |
45 | | - |
46 | | - - name: Include the task '../tasks/get_modules_and_utils_paths.yml' |
47 | | - include_tasks: ../tasks/get_modules_and_utils_paths.yml |
48 | | - |
49 | | - - name: Get tests directory |
50 | | - set_fact: |
51 | | - tests_directory: "{{ lookup('first_found', params) }}" |
52 | | - vars: |
53 | | - params: |
54 | | - files: |
55 | | - - tests |
56 | | - - network |
57 | | - paths: |
58 | | - - "../.." |
59 | | - |
60 | | - # TODO: using tar and copying the file is a workaround for the |
61 | | - # synchronize module that does not work in test-harness. Related issue: |
62 | | - # https://github.com/linux-system-roles/test-harness/issues/102 |
63 | | - # |
64 | | - - name: Create Tar file |
65 | | - command: > |
66 | | - tar -cvf {{ temptar.path }} --exclude "*.pyc" |
67 | | - --exclude "__pycache__" |
68 | | - -C {{ tests_directory | realpath | dirname }} |
69 | | - {{ tests_directory | basename }} |
70 | | - -C {{ modules_parent_and_dir.stdout_lines[0] }} |
71 | | - {{ modules_parent_and_dir.stdout_lines[1] }} |
72 | | - -C {{ module_utils_parent_and_dir.stdout_lines[0] }} |
73 | | - {{ module_utils_parent_and_dir.stdout_lines[1] }} |
74 | | - # noqa command-instead-of-module |
75 | | - delegate_to: localhost |
76 | | - changed_when: false |
77 | | - |
78 | | - - name: Copy testrepo.tar to the remote system |
79 | | - copy: |
80 | | - src: "{{ temptar.path }}" |
81 | | - dest: "{{ _rundir.path }}" |
82 | | - mode: preserve |
83 | | - |
84 | | - - name: Untar testrepo.tar |
85 | | - unarchive: |
86 | | - src: "{{ _rundir.path }}/{{ temptar.path | basename }}" |
87 | | - dest: "{{ _rundir.path }}" |
88 | | - remote_src: true |
89 | | - |
90 | | - - name: "Create subdirectory './ansible' under '{{ _rundir.path }}'" |
91 | | - file: |
92 | | - state: directory |
93 | | - path: "{{ _rundir.path }}/ansible" |
94 | | - mode: "0755" |
95 | | - |
96 | | - - name: Move module_utils to ansible directory |
97 | | - shell: | |
98 | | - if [ -d {{ _rundir.path }}/module_utils ]; then |
99 | | - mv {{ _rundir.path }}/module_utils {{ _rundir.path }}/ansible |
100 | | - fi |
101 | | - changed_when: false |
102 | | - |
103 | | - - name: Fake out python module directories, primarily for python2 |
104 | | - shell: | |
105 | | - for dir in $(find {{ _rundir.path }} -type d -print); do |
106 | | - if [ ! -f "$dir/__init__.py" ]; then |
107 | | - touch "$dir/__init__.py" |
108 | | - fi |
109 | | - done |
110 | | - changed_when: false |
111 | | - |
112 | | - - name: Set _lsr_python_path |
113 | | - set_fact: |
114 | | - _lsr_python_path: "{{ |
115 | | - _rundir.path ~ '/' ~ |
116 | | - modules_parent_and_dir.stdout_lines[1] ~ ':' ~ _rundir.path |
117 | | - }}" |
118 | | - |
119 | | - - name: Show _lsr_python_path |
120 | | - debug: |
121 | | - msg: path {{ _lsr_python_path }} |
122 | | - |
123 | | - - name: "List the files in {{ _rundir.path }}" |
124 | | - command: ls -alrtFR {{ _rundir.path }} |
125 | | - changed_when: false |
| 33 | + - name: Copy python files to the remote system |
| 34 | + include_tasks: ../tasks/setup_remote_pytest.yml |
126 | 35 |
|
127 | 36 | - name: Run pytest with nm provider |
128 | 37 | block: |
129 | 38 | - name: Run pytest with nm |
130 | | - command: > |
131 | | - pytest-3 |
132 | | - {{ _rundir.path }}/{{ tests_directory | basename }}/integration/ |
133 | | - --provider=nm |
134 | | - register: playbook_run |
| 39 | + command: pytest-3 {{ _rundir.path }}/integration/ --provider=nm |
135 | 40 | environment: |
136 | 41 | PYTHONPATH: "{{ _lsr_python_path }}" |
| 42 | + register: playbook_run |
137 | 43 | changed_when: false |
138 | 44 | always: |
139 | 45 | - name: Debug stdout_lines of the running playbook with nm |
|
149 | 55 | use: "{{ (__network_is_ostree | d(false)) | |
150 | 56 | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" |
151 | 57 | - name: Run pytest with initscripts |
152 | | - command: > |
153 | | - pytest-3 |
154 | | - {{ _rundir.path }}/{{ tests_directory | basename }}/integration/ |
155 | | - --provider=initscripts |
156 | | - register: playbook_run |
| 58 | + command: pytest-3 {{ _rundir.path }}/integration/ --provider=initscripts |
157 | 59 | environment: |
158 | 60 | PYTHONPATH: "{{ _lsr_python_path }}" |
| 61 | + register: playbook_run |
159 | 62 | changed_when: false |
160 | 63 | always: |
161 | 64 | - name: Debug stdout_lines of the running playbook with initscripts |
|
0 commit comments