summaryrefslogtreecommitdiffstats
path: root/ansible_collections/kubernetes/core/tests/integration/targets/k8s_copy/tasks/test_copy_large_file.yml
blob: 6758202eb2dba0e385a8d7957d5bc71454ae54e3 (plain)
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
---
- name: test copy of large binary and text files
  block:
  - set_fact:
      test_directory: "/tmp/test_k8scp_large_files"
    no_log: true

  - name: create temporary directory for local files
    ansible.builtin.file:
      path: "{{ test_directory }}"
      state: directory

  - name: create large text file
    k8s_create_file:
      path: "{{ test_directory }}/large_text_file.txt"
      size: 150

  - name: create large binary file
    k8s_create_file:
      path: "{{ test_directory }}/large_bin_file.bin"
      size: 200
      binary: true

  # Copy large text file from/to local filesystem to Pod
  - name: copy large file into remote Pod
    k8s_cp:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_text_file.txt
      local_path: "{{ test_directory }}/large_text_file.txt"
      state: to_pod

  - name: Compare files
    kubectl_file_compare:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_text_file.txt
      local_path: "{{ test_directory }}/large_text_file.txt"

  - name: copy large file from Pod into local filesystem
    k8s_cp:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_text_file.txt
      local_path: "{{ test_directory }}/large_text_file_from_pod.txt"
      state: from_pod

  - name: Compare files
    kubectl_file_compare:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_text_file.txt
      local_path: "{{ test_directory }}/large_text_file_from_pod.txt"

  # Copy large binary file from/to local filesystem to Pod
  - name: copy large file into remote Pod
    k8s_cp:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_bin_file.bin
      local_path: "{{ test_directory }}/large_bin_file.bin"
      state: to_pod

  - name: Compare executable, local vs remote
    kubectl_file_compare:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_bin_file.bin
      local_path: "{{ test_directory }}/large_bin_file.bin"

  - name: copy executable from pod into local filesystem
    k8s_cp:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_bin_file.bin
      local_path: "{{ test_directory }}/large_bin_file_from_pod.bin"
      state: from_pod

  - name: Compare executable, local vs remote
    kubectl_file_compare:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      remote_path: /large_bin_file.bin
      local_path: "{{ test_directory }}/large_bin_file_from_pod.bin"

  always:
  - name: Delete temporary directory created for the test
    ansible.builtin.file:
      path: "{{ test_directory }}"
      state: absent
    ignore_errors: true

  - name: Delete file created on Pod
    k8s_exec:
      namespace: '{{ copy_namespace }}'
      pod: '{{ pod_with_one_container.name }}'
      command: 'rm {{ item }}'
    ignore_errors: true
    with_items:
    - /large_text_file.txt
    - /large_bin_file.bin