stack-orchestrator/playbooks/relay-inbound-udp-test.yml

96 lines
2.7 KiB
YAML
Raw Normal View History

---
# Test inbound UDP through the Ashburn relay.
#
# Sends a UDP packet from kelce to 137.239.194.65:8001 and checks
# whether it arrives inside the kind node's network namespace.
#
# Usage:
# ansible-playbook -i inventory/biscayne.yml -i inventory/kelce.yml \
# playbooks/relay-inbound-udp-test.yml
#
- name: Inbound UDP relay test — listener
hosts: biscayne
gather_facts: false
become: true
vars:
relay_ip: 137.239.194.65
gossip_port: 8001
kind_node: laconic-70ce4c4b47e23b85-control-plane
tasks:
- name: Copy listener script
ansible.builtin.copy:
src: ../scripts/relay-test-udp-listen.py
dest: /tmp/relay-test-udp-listen.py
mode: "0755"
- name: Get kind node PID
ansible.builtin.shell:
cmd: >-
docker inspect --format '{%raw%}{{.State.Pid}}{%endraw%}' {{ kind_node }}
register: kind_pid_result
changed_when: false
- name: Set kind PID fact
ansible.builtin.set_fact:
kind_pid: "{{ kind_pid_result.stdout | trim }}"
- name: Start UDP listener in kind netns
ansible.builtin.shell:
cmd: >-
nsenter --net --target {{ kind_pid }}
python3 /tmp/relay-test-udp-listen.py {{ gossip_port }} 15
register: listener_result
async: 20
poll: 0
- name: Wait for listener to bind
ansible.builtin.pause:
seconds: 2
- name: Inbound UDP relay test — sender
hosts: kelce
gather_facts: false
vars:
relay_ip: 137.239.194.65
gossip_port: 8001
tasks:
- name: Copy sender script
ansible.builtin.copy:
src: ../scripts/relay-test-udp-send.py
dest: /tmp/relay-test-udp-send.py
mode: "0755"
- name: Send UDP probe to relay IP
ansible.builtin.command:
cmd: python3 /tmp/relay-test-udp-send.py {{ relay_ip }} {{ gossip_port }}
register: send_result
changed_when: false
- name: Show send result
ansible.builtin.debug:
var: send_result.stdout
- name: Inbound UDP relay test — collect results
hosts: biscayne
gather_facts: false
become: true
tasks:
- name: Wait for listener to complete
ansible.builtin.async_status:
jid: "{{ listener_result.ansible_job_id }}"
register: listener_final
until: listener_final.finished
retries: 10
delay: 2
- name: Show listener result
ansible.builtin.debug:
var: listener_final.stdout
- name: Assert UDP arrived
ansible.builtin.assert:
that:
- "'OK' in listener_final.stdout"
fail_msg: "Inbound UDP did not arrive at kind node: {{ listener_final.stdout }}"
success_msg: "Inbound UDP reached kind node: {{ listener_final.stdout }}"