mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-29 02:44:41 +00:00
[backport/2.2] Remove binary file from molecule test suite
SUMMARY
The binary file used to test k8s_cp is causing larger problems
downstream. There's no reason why the binary file needs to function as
all we care about is that the content of the file has not changed during
the copy process. This can be accomplished by comparing file hashes.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION
Reviewed-by: Abhijeet Kasurde
Reviewed-by: None
(cherry picked from commit fa65698)
Reviewed-by: None <None>
This commit is contained in:
3
changelogs/fragments/298-remove-binary-file.yaml
Normal file
3
changelogs/fragments/298-remove-binary-file.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- remove binary file from k8s_cp test suite (https://github.com/ansible-collections/kubernetes.core/pull/298).
|
||||||
Binary file not shown.
@@ -34,50 +34,65 @@
|
|||||||
kubectl_path: "{{ kubectl_path }}"
|
kubectl_path: "{{ kubectl_path }}"
|
||||||
|
|
||||||
# Binary file
|
# Binary file
|
||||||
- name: Generate random content
|
|
||||||
set_fact:
|
- name: Create temp binary file
|
||||||
hello_arg: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=16') }}"
|
tempfile:
|
||||||
|
state: file
|
||||||
|
register: binfile
|
||||||
|
|
||||||
|
- name: Generate random binary content
|
||||||
|
command: dd if=/dev/urandom of={{ binfile.path }} bs=1M count=1
|
||||||
|
|
||||||
- name: Copy executable into Pod
|
- name: Copy executable into Pod
|
||||||
k8s_cp:
|
k8s_cp:
|
||||||
namespace: '{{ copy_namespace }}'
|
namespace: '{{ copy_namespace }}'
|
||||||
pod: '{{ pod_with_one_container.name }}'
|
pod: '{{ pod_with_one_container.name }}'
|
||||||
remote_path: /tmp/hello.exe
|
remote_path: /tmp/hello.exe
|
||||||
local_path: files/hello
|
local_path: "{{ binfile.path }}"
|
||||||
state: to_pod
|
state: to_pod
|
||||||
|
|
||||||
- name: Compare executable
|
- name: Get remote hash
|
||||||
kubectl_file_compare:
|
kubernetes.core.k8s_exec:
|
||||||
namespace: '{{ copy_namespace }}'
|
namespace: "{{ copy_namespace }}"
|
||||||
pod: '{{ pod_with_one_container.name }}'
|
pod: "{{ pod_with_one_container.name }}"
|
||||||
remote_path: /tmp/hello.exe
|
command: sha256sum -b /tmp/hello.exe
|
||||||
local_path: "{{ role_path }}/files/hello"
|
register: remote_hash
|
||||||
kubectl_path: "{{ kubectl_path }}"
|
|
||||||
args:
|
- name: Get local hash
|
||||||
- "{{ hello_arg }}"
|
command: sha256sum -b {{ binfile.path }}
|
||||||
|
register: local_hash
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- remote_hash.stdout.split()[0] == local_hash.stdout.split()[0]
|
||||||
|
|
||||||
|
- name: Generate tempfile
|
||||||
|
tempfile:
|
||||||
|
state: file
|
||||||
|
register: binfile
|
||||||
|
|
||||||
- name: Copy executable from Pod
|
- name: Copy executable from Pod
|
||||||
k8s_cp:
|
k8s_cp:
|
||||||
namespace: '{{ copy_namespace }}'
|
namespace: '{{ copy_namespace }}'
|
||||||
pod: '{{ pod_with_one_container.name }}'
|
pod: '{{ pod_with_one_container.name }}'
|
||||||
remote_path: /tmp/hello.exe
|
remote_path: /tmp/hello.exe
|
||||||
local_path: /tmp/hello
|
local_path: "{{ binfile.path }}"
|
||||||
state: from_pod
|
state: from_pod
|
||||||
|
|
||||||
- name: update executable permission
|
- name: Get remote hash
|
||||||
file:
|
kubernetes.core.k8s_exec:
|
||||||
path: /tmp/hello
|
namespace: "{{ copy_namespace }}"
|
||||||
mode: '0755'
|
pod: "{{ pod_with_one_container.name }}"
|
||||||
|
command: sha256sum -b /tmp/hello.exe
|
||||||
|
register: remote_hash
|
||||||
|
|
||||||
- name: Compare executable
|
- name: Get local hash
|
||||||
kubectl_file_compare:
|
command: sha256sum -b {{ binfile.path }}
|
||||||
namespace: '{{ copy_namespace }}'
|
register: local_hash
|
||||||
pod: '{{ pod_with_one_container.name }}'
|
|
||||||
remote_path: /tmp/hello.exe
|
- assert:
|
||||||
local_path: /tmp/hello
|
that:
|
||||||
kubectl_path: "{{ kubectl_path }}"
|
- remote_hash.stdout.split()[0] == local_hash.stdout.split()[0]
|
||||||
args:
|
|
||||||
- "{{ hello_arg }}"
|
|
||||||
|
|
||||||
# zip files
|
# zip files
|
||||||
- name: copy zip file into remote pod
|
- name: copy zip file into remote pod
|
||||||
|
|||||||
Reference in New Issue
Block a user