| 
12 | 12 | # See the License for the specific language governing permissions and  | 
13 | 13 | # limitations under the License.  | 
14 | 14 | 
 
  | 
 | 15 | +- name: Assert variables are defined  | 
 | 16 | +  ansible.builtin.assert:  | 
 | 17 | +    that:  | 
 | 18 | +    - region is defined  | 
 | 19 | +    - custom_vars.project is defined  | 
 | 20 | + | 
15 | 21 | - name: Get cluster credentials for kubectl  | 
16 | 22 |   delegate_to: localhost  | 
17 | 23 |   ansible.builtin.command: gcloud container clusters get-credentials {{ deployment_name }} --region {{ cli_deployment_vars.region }} --project {{ custom_vars.project }} --verbosity=debug  | 
18 | 24 | 
 
  | 
19 |  | -- name: List files in deployment directory  | 
20 |  | -  delegate_to: localhost  | 
21 |  | -  ansible.builtin.shell: |  | 
22 |  | -    ls -l {{ workspace }}/{{ deployment_name }}  | 
23 |  | -  register: file_list  | 
24 |  | - | 
25 |  | -- name: Print file list  | 
26 |  | -  ansible.builtin.debug:  | 
27 |  | -    var: file_list.stdout_lines  | 
28 |  | - | 
29 |  | -- name: Execute the job  | 
 | 25 | +- name: Run the FIO benchmark job  | 
30 | 26 |   delegate_to: localhost  | 
31 | 27 |   ansible.builtin.shell: |  | 
32 |  | -    job=({{ workspace }}/{{ deployment_name }}/fio-benchmark.yaml)  | 
33 |  | -    kubectl create -f "$job" -v=9  | 
 | 28 | +    kubectl create -f {{ workspace }}/{{ deployment_name }}/fio-benchmark.yaml -v=9  | 
34 | 29 |   args:  | 
35 | 30 |     executable: /bin/bash  | 
36 |  | -  changed_when: False  | 
37 | 31 | 
 
  | 
38 |  | -- name: Wait for job to complete  | 
 | 32 | +- name: Wait for FIO Job to complete  | 
39 | 33 |   delegate_to: localhost  | 
40 |  | -  ansible.builtin.command: |  | 
41 |  | -    kubectl get job --field-selector  status.successful=1 -v=9  | 
42 |  | -  register: job_completion  | 
43 |  | -  until: job_completion.stdout_lines | length > 0  | 
 | 34 | +  ansible.builtin.shell: |  | 
 | 35 | +    kubectl get job fio-benchmark --field-selector status.successful=1 -v=9  | 
 | 36 | +  register: fio_job_completion  | 
 | 37 | +  until: fio_job_completion.stdout_lines | length > 1  | 
44 | 38 |   retries: 80  | 
45 | 39 |   delay: 15  | 
46 | 40 | 
 
  | 
47 |  | -- name: Print job_completion debug output  | 
48 |  | -  ansible.builtin.debug:  | 
49 |  | -    var: job_completion.stdout_lines  | 
 | 41 | +- name: Fetch logs from the FIO job pod and save to fio_pod_logs.txt  | 
 | 42 | +  delegate_to: localhost  | 
 | 43 | +  ansible.builtin.shell: |  | 
 | 44 | +    pod_name="$(kubectl get pods --no-headers -o custom-columns="Name:.metadata.name" -l job-name=fio-benchmark)"  | 
 | 45 | +    kubectl logs ${pod_name} > fio_pod_logs.txt  | 
 | 46 | +    cat fio_pod_logs.txt  | 
 | 47 | +  register: fio_test_logs  | 
 | 48 | + | 
 | 49 | +- name: Print the FIO test logs  | 
 | 50 | +  debug:  | 
 | 51 | +    msg: "{{fio_test_logs.stdout}}"  | 
 | 52 | + | 
 | 53 | +- name: Clean up FIO job  | 
 | 54 | +  delegate_to: localhost  | 
 | 55 | +  ansible.builtin.shell: |  | 
 | 56 | +    kubectl delete job fio-benchmark -v=9  | 
0 commit comments