-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathse_test.yml
More file actions
371 lines (303 loc) · 15.2 KB
/
se_test.yml
File metadata and controls
371 lines (303 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
---
- name: test a storage element
hosts: localhost
gather_facts: True
force_handlers: True
become: False
vars:
# these can be overridden with adding parameter "-e variable=value" to the ansible-playbook command
source_file: "/bin/bash"
ldap_server: "{{ server }}"
xrootd_port: "1094"
xrootd_server: "{{ server }}:{{ xrootd_port }}"
srm_port: "8443"
srm_server: "{{ server }}:{{ srm_port }}"
webdav_port: "2880"
webdav_server: "{{ server }}:{{ webdav_port }}"
webdav_protocol: "http"
enable_ldap_testing: False
enable_gfal2_testing: True
ldap_port: 2170
ldap_gluename: "GlueSESizeTotal"
test_xrootd: True
xrdcp_write_expected_return_code: 0 # set this to 54 to expect a write failure
xfed_cmstfc_test: False # set to True to test cmstfc
xrdcp_cmstfc_expected_return_code: 0 # set this to 0 to expect a read success
enable_webdav_testing: True
enable_webdav_geturl_testing: True
enable_webdav_curl_testing: True
webdav_curl_ca_path: "/etc/grid-security/certificates/"
webdav_write_expected_return_code: 1 # set this to 0 to expect a write success
gfal2_packages:
- "util"
- "plugin-srm"
- "plugin-xrootd"
- "plugin-gridftp"
- "plugin-http"
- "plugin-file"
handlers:
- name: cleanup
command: arcrm srm://{{ server }}{{path}}/{{ file }}
- name: cleanup2
file: path=/tmp/{{ file }} state=absent
- name: cleanup3
file: path=/tmp/{{ file }}{{ item }} state=absent
with_items: [ 2,3,4,5,6,7,8,9 ]
- name: cleanup_xrdcp_write
command: arcrm srm://{{ server }}{{path}}/{{ file }}_write
when: reg_xrdcp_write.rc|int == 0
- name: cleanup_webdav_write
command: arcrm srm://{{ server }}{{path}}/{{ file }}_webdav_write
when: reg_webdav_write.rc|int == 0
- name: cleanup_mkdir
command: arcrm srm://{{ srm_server }}{{path}}/mkdir_{{ item }}
with_items: "{{ mkdir_program }}"
- name: cleanup_rename_after
command: arcrm srm://{{ srm_server }}{{path}}/{{ file }}_after_{{ item }}
with_items: "{{ cp_program }}"
tasks:
- block:
# Safety
- name: findproxy validity - fails if no (valid) proxy found
command: arcproxy -i validityLeft
register: reg_arcproxy
changed_when: False
failed_when:
- reg_arcproxy.rc != 0 or reg_arcproxy.stdout|int == 0
# Set/Gather some helper variables
- name: fetch path to X509 proxy file
command: arcproxy -i path
register: reg_x509_cert
changed_when: False
- name: debug print x509 cert path
debug: var=reg_x509_cert.stdout verbosity=2
- name: command rpm check if the gfal2_rpms are installed
command: rpm -q gfal2-{{ item }}
register: reg_gfal2_rpms
with_items: "{{ gfal2_packages }}"
changed_when: reg_gfal2_rpms.rc != 0
ignore_errors: True
when: ansible_os_family == "RedHat" and enable_gfal2_testing
- name: set facts differently if gfal2-util is installed test with that too
set_fact:
ls_program: [ 'arcls', 'gfal-ls' ]
xrootd_ls_program: [ 'xrdfs', 'gfal-ls' ]
mkdir_program: [ 'arcmkdir', 'gfal-mkdir' ]
cp_program: [ 'arccp', 'gfal-copy' ]
rename_program: [ 'arcrename', 'gfal-rename' ]
source_files: ["reg_source_1", "reg_source_2" ]
when: reg_gfal2_rpms is defined and reg_gfal2_rpms.results[0]['rc']|int == 0
- name: set facts otherwise just use arcls
set_fact:
ls_program: [ 'arcls' ]
xrootd_ls_program: []
mkdir_program: [ 'arcmkdir' ]
cp_program: [ 'arccp' ]
rename_program: [ 'arcrename' ]
source_files: ["reg_source_1" ]
when: reg_gfal2_rpms is not defined or reg_gfal2_rpms.results[0]['rc']|int != 0
# Listing
- name: arcls SRM dir
command: "{{ item }} srm://{{ srm_server }}{{ path }}"
register: reg_arcls
when: server is defined and path is defined
with_items: "{{ ls_program }}"
- name: arcls SRM path / file
command: "{{ item }} srm://{{ srm_server }}{{ path }}/{{ file }}"
register: reg_arclsfile
failed_when: False
with_items: "{{ ls_program }}"
when: server is defined and path is defined and file is defined
- name: arcls SRM path / file_xrdcp write
command: "arcls srm://{{ srm_server }}{{ path }}/{{ file }}_write"
register: reg_arclsfile_xrdcp_write
failed_when: False
when: server is defined and path is defined and file is defined
- name: arcls SRM path / file_webdav write
command: "arcls srm://{{ srm_server }}{{ path }}/{{ file }}_webdav_write"
register: reg_arclsfile_webdav_write
failed_when: False
when: server is defined and path is defined and file is defined
- name: arcls SRM path / cp_programs
command: "arcls srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ item }}"
register: reg_arclsfile_cp_program
failed_when: False
with_items: "{{ cp_program }}"
when: server is defined and path is defined and file is defined
- name: debug print arcls cp_programs
debug: var=reg_arclsfile_cp_program verbosity=3
# Cleanup of some CTRL+C aborts
- name: arcrm SRM file_xrdcp write first if it exists
command: "arcrm srm://{{ srm_server }}{{ path }}/{{ file }}_write"
when:
- reg_arclsfile_xrdcp_write.rc|int == 0
- (server is defined and path is defined and file is defined)
- name: arcrm SRM file first if it exists
command: "arcrm srm://{{ srm_server }}{{ path }}/{{ file }}"
when:
- reg_arclsfile.results.0.rc|int == 0
- (server is defined and path is defined and file is defined)
- name: arcrm SRM webdav_file first if it exists
command: "arcrm srm://{{ srm_server }}{{ path }}/{{ file }}_webdav_write"
when:
- reg_arclsfile_webdav_write.rc|int == 0
- (server is defined and path is defined and file is defined)
- name: arcrm SRM dirs if they exist
command: "arcrm srm://{{ srm_server }}{{ path }}/mkdir_{{ item }}"
with_items: "{{ mkdir_program }}"
when:
- (server is defined and path is defined and file is defined and mkdir_program is defined)
ignore_errors: True
- name: arcrm SRM cp_program 0 files first if they exist
command: "arcrm srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ item }}"
with_items: "{{ cp_program[0] }}"
when:
- cp_program[0] is defined
- reg_arclsfile_cp_program.results[0].rc|int == 0
- (server is defined and path is defined and file is defined)
- name: arcrm SRM cp_program 1 files first if they exist
command: "arcrm srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ item }}"
with_items: "{{ cp_program[1] }}"
when:
- cp_program[1] is defined
- reg_arclsfile_cp_program.results[1].rc|int == 0
- (server is defined and path is defined and file is defined)
# xrootd ls
- name: root:// endpoint listing
command: "{{ item }} root://{{ xrootd_server }}{{ path }}"
register: reg_xrdfs
with_items: "{{ xrootd_ls_program }}"
when: server is defined and path is defined and xrootd_ls_program != []
# mkdirs
- name: mkdir SRM dir
command: "{{ item }} srm://{{ srm_server }}{{ path }}/mkdir_{{ item }}"
register: reg_mkdir
when: server is defined and path is defined
with_items: "{{ mkdir_program }}"
notify: cleanup_mkdir
# Checksum of original file
- name: stat source_file
stat: path={{ source_file }}
register: reg_source_file
- name: store source_file checksum in a fact
set_fact:
source_checksum: "{{ reg_source_file.stat.checksum }}"
# Copy files from here to there
- name: arccp SRM here to there
command: "arccp {{ source_file }} srm://{{ srm_server }}{{ path }}/{{ file }}"
notify: cleanup
when: server is defined and path is defined and file is defined
- name: copy files to SRM with cp_programs
command: "{{ item }} {{ source_file }} srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ item }}"
with_items: "{{ cp_program }}"
when: server is defined and path is defined and file is defined
# Rename
- name: rename srm files cp_program 0 with rename_program 0
command: "{{ item }} srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ cp_program[0] }} srm://{{ srm_server }}{{ path }}/{{ file }}_after_{{ cp_program[0] }}"
notify: cleanup_rename_after
with_items: "{{ rename_program[0] }}"
when: server is defined and path is defined and file is defined and cp_program[0] is defined and rename_program[1] is defined
- name: rename srm files cp_program 1 with rename_program 1
command: "{{ item }} srm://{{ srm_server }}{{ path }}/{{ file }}_before_{{ cp_program[1] }} srm://{{ srm_server }}{{ path }}/{{ file }}_after_{{ cp_program[1] }}"
notify: cleanup_rename_after
with_items: "{{ rename_program[1] }}"
when: server is defined and path is defined and file is defined and cp_program[1] is defined and rename_program[1] is defined
# Copy files from there to here
- name: arccp SRM there to here
command: "arccp srm://{{ srm_server }}{{ path }}/{{ file }} /tmp/{{ file }}"
notify: cleanup2
when: server is defined and path is defined and file is defined
- name: xrdcp there to here
command: "xrdcp root://{{ xrootd_server }}{{ path }}/{{ file }} /tmp/{{ file }}2"
notify: cleanup3
when: server is defined and path is defined and file is defined and test_xrootd|bool
# Try to write with xrdcp too
- name: xrdcp here to there - fail if return code is not xrdcp_write_expected_return_code
command: "xrdcp {{ source_file }} root://{{ xrootd_server }}{{ path }}/{{ file }}_write"
when: server is defined and path is defined and file is defined and test_xrootd|bool
register: reg_xrdcp_write
failed_when: reg_xrdcp_write.rc != xrdcp_write_expected_return_code|int
notify: cleanup_xrdcp_write
# Https/webdav
- name: arccp webdav here to there
command: "arccp {{ source_file }} {{ webdav_protocol }}://{{ webdav_server }}{{ path }}/{{ file }}_write_webdav"
register: reg_webdav_write
notify: cleanup_webdav_write
failed_when: reg_webdav_write.rc != webdav_write_expected_return_code|int
when: server is defined and path is defined and file is defined and enable_webdav_testing|bool
- name: arccp webdav there to here
command: "arccp {{ webdav_protocol }}://{{ webdav_server }}{{ path }}/{{ file }} /tmp/{{ file }}6"
notify: cleanup3
when: server is defined and path is defined and file is defined and enable_webdav_testing|bool
- name: ansible get_url webdav there to here
get_url:
url: "{{ webdav_protocol }}://{{ webdav_server }}{{ path }}/{{ file }}"
dest: "/tmp/{{ file}}7"
notify: cleanup3
when: server is defined and path is defined and file is defined and enable_webdav_geturl_testing|bool
- name: curl webdav there to here
command: "curl --show-error --connect-timeout 300 --max-time 3600 --cacert {{ reg_x509_cert.stdout }} --capath {{ webdav_curl_ca_path }} --cert {{ reg_x509_cert.stdout }} --key {{ reg_x509_cert.stdout }} -L {{ webdav_protocol }}://{{ webdav_server }}{{ path }}/{{ file }} -o /tmp/{{ file }}8"
notify: cleanup3
when: server is defined and path is defined and file is defined and enable_webdav_curl_testing|bool
# Checksum after copying
- name: stat fetched source_file
stat: path=/tmp/{{ file }}
register: reg_source_1
when: server is defined and path is defined and file is defined
- name: stat fetched source_file2
stat: path=/tmp/{{ file }}2
register: reg_source_2
when: server is defined and path is defined and file is defined and test_xrootd|bool
- name: debug print checksums of fetched files
debug: var={{ item }}.stat.checksum verbosity=1
when: server is defined and path is defined and file is defined
with_items: "{{ source_files }}"
# TODO: Could also add /tmp/{{ file }}7 if webdav_testing is enabled
- name: assert that checksums are all the same
assert:
that:
- "source_checksum == {{ item }}.stat.checksum"
when: server is defined and path is defined and file is defined
with_items: "{{ source_files }}"
# Xrootd Federation
- name: xrdcp from xrootd federation server1 to here
command: "xrdcp root://{{ xfed_server1 }}{{ xfed_pathfile }} /tmp/{{ file }}3"
notify: cleanup3
when: xfed_server1 is defined and xfed_pathfile is defined
- name: xrdcp from xrootd federation server2 to here
command: "xrdcp root://{{ xfed_server2 }}{{ xfed_pathfile }} /tmp/{{ file }}4"
notify: cleanup3
when: xfed_server2 is defined and xfed_pathfile is defined
- name: xrdcp from xrootd federation server3 to here
command: "xrdcp root://{{ xfed_server3 }}{{ xfed_pathfile }} /tmp/{{ file }}5"
notify: cleanup3
when: xfed_server3 is defined and xfed_pathfile is defined
- name: xrdcp from our xrootd server with cms-tfc plugin
command: "xrdcp root://{{ server }}{{ xfed_pathfile }} /tmp/{{ file }}9"
notify: cleanup3
register: reg_xrdcp_cms_tfc
failed_when: reg_xrdcp_cms_tfc.rc|int != xrdcp_cmstfc_expected_return_code
when: xfed_cmstfc_test and xfed_pathfile is defined
# Information system: One could use https://github.com/quinot/ansible-plugin-lookup_ldap instead - or perhaps glue-validator
- name: ldapsearch tool comes from openldap-clients on redhat
command: "rpm -qa openldap-clients"
register: reg_openldap
failed_when: reg_openldap.stdout == ""
when: ansible_os_family == "RedHat" and enable_ldap_testing
- name: ldapsearch tool comes from ldap-utils on debian
command: "dpkg --get-selections ldap-utils"
register: reg_ldap_utils
failed_when: reg_ldap_utils.stdout == ""
when: ansible_os_family == "Debian" and enable_ldap_testing
- name: shell ldapsearch towards ldap_server port ldap_port and grep for ldap_gluename
shell: "ldapsearch -LL -x -H ldap://{{ ldap_server }}:{{ ldap_port }} -b o=grid {{ ldap_gluename }}|grep -c ^{{ ldap_gluename }}"
register: reg_ldapsearch
failed_when: reg_ldapsearch.rc != 0 or reg_ldapsearch.stdout != "1"
changed_when: reg_ldapsearch.stdout != "1"
when: enable_ldap_testing
- name: debug print ldapsearch
debug: var=reg_ldapsearch verbosity=1
when: enable_ldap_testing
delegate_to: localhost
# end of block
...