|
| 1 | +*** Settings *** |
| 2 | +Documentation Networking smoke tests |
| 3 | +
|
| 4 | +Resource ../../resources/common.resource |
| 5 | +Resource ../../resources/oc.resource |
| 6 | +Resource ../../resources/microshift-network.resource |
| 7 | +Resource ../../resources/microshift-config.resource |
| 8 | +Resource ../../resources/microshift-process.resource |
| 9 | +Resource ../../resources/hosts.resource |
| 10 | + |
| 11 | +Suite Setup Setup Suite With Namespace |
| 12 | +Suite Teardown Teardown Suite With Namespace |
| 13 | + |
| 14 | +Test Tags slow |
| 15 | + |
| 16 | + |
| 17 | +*** Variables *** |
| 18 | +${HELLO_USHIFT_INGRESS} ./assets/hello/hello-microshift-ingress.yaml |
| 19 | +${HOSTNAME} hello-microshift.cluster.local |
| 20 | +${HOSTSCUSTOM} hello-microshift.api.com |
| 21 | +${FAKE_LISTEN_IP} 99.99.99.99 |
| 22 | +${CUSTOM_HOSTS_FILE} /tmp/hosts22 |
| 23 | +${PODS_HOSTS_FILE} /tmp/hosts/hosts |
| 24 | +${HOSTSFILE_ENABLED} SEPARATOR=\n |
| 25 | +... --- |
| 26 | +... dns: |
| 27 | +... \ \ hosts: |
| 28 | +... \ \ \ status: Enabled |
| 29 | +${HOSTS_CONFIG_CUSTOM} SEPARATOR=\n |
| 30 | +... --- |
| 31 | +... dns: |
| 32 | +... \ \ hosts: |
| 33 | +... \ \ \ status: Enabled |
| 34 | +... \ \ \ file: /tmp/hosts22 |
| 35 | + |
| 36 | + |
| 37 | +*** Test Cases *** |
| 38 | +Resolve Host from Default Hosts File |
| 39 | + [Documentation] Resolve host from default hosts file |
| 40 | + [Setup] Setup With Custom Config ${HOSTSFILE_ENABLED} |
| 41 | + ${hostname}= Generate Random HostName |
| 42 | + Add Fake IP To NIC ${FAKE_LISTEN_IP} |
| 43 | + Add Entry To Hosts ${FAKE_LISTEN_IP} ${hostname} |
| 44 | + Resolve Host From Pod ${hostname} |
| 45 | + [Teardown] Teardown Hosts File ${hostname} |
| 46 | + |
| 47 | +Resolve Host from Non-Default Hosts File |
| 48 | + [Documentation] Resolve host from default hosts file |
| 49 | + [Setup] Setup With Custom Config ${HOSTS_CONFIG_CUSTOM} |
| 50 | + ${hostname}= Generate Random HostName |
| 51 | + Add Fake IP To NIC ${FAKE_LISTEN_IP} |
| 52 | + Add Entry To Hosts ${FAKE_LISTEN_IP} ${hostname} ${CUSTOM_HOSTS_FILE} |
| 53 | + Resolve Host From Pod ${hostname} |
| 54 | + [Teardown] Teardown Hosts File ${hostname} |
| 55 | + |
| 56 | + |
| 57 | +*** Keywords *** |
| 58 | +Wait For DNS Updated With Hostname |
| 59 | + [Documentation] Wait for the file to be updated |
| 60 | + [Arguments] ${hostname} |
| 61 | + Wait Until Keyword Succeeds 2m 2s |
| 62 | + ... DNS Pod Contain Hosts ${hostname} |
| 63 | + |
| 64 | +DNS Pod Contain Hosts |
| 65 | + [Documentation] Check if the hosts file contains the given hostname |
| 66 | + [Arguments] ${hostname} |
| 67 | + |
| 68 | + # Find the dns-default-.* pod name in openshift-dns namespace, e.g., dns-default-dqp9n |
| 69 | + ${dns_pod}= Run With Kubeconfig |
| 70 | + ... oc get pod -n openshift-dns -o jsonpath='{.items[*].metadata.name}' | grep '^dns-default-' |
| 71 | + ${fuse_device}= Oc Exec ${dns_pod} cat ${PODS_HOSTS_FILE} openshift-dns |
| 72 | + Should Contain ${fuse_device} ${hostname} |
| 73 | + |
| 74 | +Resolve Host From Pod |
| 75 | + [Documentation] Resolve host from pod |
| 76 | + [Arguments] ${hostname} |
| 77 | + Create Hello MicroShift Pod |
| 78 | + Expose Hello MicroShift |
| 79 | + Wait For DNS Updated With Hostname ${hostname} |
| 80 | + Sleep 5 seconds |
| 81 | + ${fuse_device}= Oc Exec hello-microshift nslookup ${hostname} ${NAMESPACE} /bin/sh |
| 82 | + Should Contain ${fuse_device} Name: ${hostname} |
| 83 | + |
| 84 | +Setup With Custom Config |
| 85 | + [Documentation] Install a custom config and restart MicroShift |
| 86 | + [Arguments] ${config_content} |
| 87 | + Drop In MicroShift Config ${config_content} 20-dns |
| 88 | + Restart MicroShift |
| 89 | + |
| 90 | +Teardown Hosts File |
| 91 | + [Documentation] Teardown the hosts file |
| 92 | + [Arguments] ${hostname} |
| 93 | + Run Keywords |
| 94 | + ... Delete Hello MicroShift Pod And Service |
| 95 | + ... AND |
| 96 | + ... Remove Entry From Hosts ${hostname} |
| 97 | + ... AND |
| 98 | + ... Remove Fake IP From NIC ${FAKE_LISTEN_IP} |
| 99 | + ... AND |
| 100 | + ... Remove Drop In MicroShift Config 20-dns |
| 101 | + |
| 102 | +Add Fake IP To NIC |
| 103 | + [Documentation] Add the given IP to the given NIC temporarily. |
| 104 | + [Arguments] ${ip_address}=${FAKE_LISTEN_IP} ${nic_name}=br-ex |
| 105 | + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command |
| 106 | + ... ip address add ${ip_address}/32 dev ${nic_name} |
| 107 | + ... sudo=True return_rc=True return_stderr=True return_stdout=True |
| 108 | + Log Many ${stdout} ${stderr} |
| 109 | + Should Be Equal As Integers 0 ${rc} |
| 110 | + |
| 111 | +Remove Fake IP From NIC |
| 112 | + [Documentation] Remove the given IP from the given NIC. |
| 113 | + [Arguments] ${ip_address}=${FAKE_LISTEN_IP} ${nic_name}=br-ex |
| 114 | + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command |
| 115 | + ... ip address delete ${ip_address}/32 dev ${nic_name} |
| 116 | + ... sudo=True return_rc=True return_stderr=True return_stdout=True |
| 117 | + Log Many ${stdout} ${stderr} |
| 118 | + Should Be Equal As Integers 0 ${rc} |
0 commit comments