mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-27 05:43:02 +00:00
Remove binary file from molecule test suite (#298)
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. Fixes #297 #293 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Abhijeet Kasurde <None> 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 }}"
|
||||
|
||||
# Binary file
|
||||
- name: Generate random content
|
||||
set_fact:
|
||||
hello_arg: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=16') }}"
|
||||
|
||||
- name: Create temp binary file
|
||||
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
|
||||
k8s_cp:
|
||||
namespace: '{{ copy_namespace }}'
|
||||
pod: '{{ pod_with_one_container.name }}'
|
||||
remote_path: /tmp/hello.exe
|
||||
local_path: files/hello
|
||||
local_path: "{{ binfile.path }}"
|
||||
state: to_pod
|
||||
|
||||
- name: Compare executable
|
||||
kubectl_file_compare:
|
||||
namespace: '{{ copy_namespace }}'
|
||||
pod: '{{ pod_with_one_container.name }}'
|
||||
remote_path: /tmp/hello.exe
|
||||
local_path: "{{ role_path }}/files/hello"
|
||||
kubectl_path: "{{ kubectl_path }}"
|
||||
args:
|
||||
- "{{ hello_arg }}"
|
||||
- name: Get remote hash
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ copy_namespace }}"
|
||||
pod: "{{ pod_with_one_container.name }}"
|
||||
command: sha256sum -b /tmp/hello.exe
|
||||
register: remote_hash
|
||||
|
||||
- name: Get local hash
|
||||
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
|
||||
k8s_cp:
|
||||
namespace: '{{ copy_namespace }}'
|
||||
pod: '{{ pod_with_one_container.name }}'
|
||||
remote_path: /tmp/hello.exe
|
||||
local_path: /tmp/hello
|
||||
local_path: "{{ binfile.path }}"
|
||||
state: from_pod
|
||||
|
||||
- name: update executable permission
|
||||
file:
|
||||
path: /tmp/hello
|
||||
mode: '0755'
|
||||
- name: Get remote hash
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: "{{ copy_namespace }}"
|
||||
pod: "{{ pod_with_one_container.name }}"
|
||||
command: sha256sum -b /tmp/hello.exe
|
||||
register: remote_hash
|
||||
|
||||
- name: Compare executable
|
||||
kubectl_file_compare:
|
||||
namespace: '{{ copy_namespace }}'
|
||||
pod: '{{ pod_with_one_container.name }}'
|
||||
remote_path: /tmp/hello.exe
|
||||
local_path: /tmp/hello
|
||||
kubectl_path: "{{ kubectl_path }}"
|
||||
args:
|
||||
- "{{ hello_arg }}"
|
||||
- name: Get local hash
|
||||
command: sha256sum -b {{ binfile.path }}
|
||||
register: local_hash
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- remote_hash.stdout.split()[0] == local_hash.stdout.split()[0]
|
||||
|
||||
# zip files
|
||||
- name: copy zip file into remote pod
|
||||
|
||||
Reference in New Issue
Block a user