Skip to content

Commit 34f7bf6

Browse files
committed
added tests
Signed-off-by: Evgeny Slutsky <[email protected]>
1 parent 07405be commit 34f7bf6

File tree

4 files changed

+151
-21
lines changed

4 files changed

+151
-21
lines changed

test/resources/hosts.resource

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
*** Settings ***
2+
Documentation Keywords for interacting with the hosts file
3+
4+
Library Process
5+
Library String
6+
7+
Resource common.resource
8+
9+
*** Keywords ***
10+
Generate Random HostName
11+
[Documentation] Generate Random Hostname
12+
${rand}= Generate Random String
13+
${rand}= Convert To Lower Case ${rand}
14+
RETURN ${rand}.api.com
15+
16+
Add Entry To Hosts
17+
[Documentation] Add new entry to local /etc/hosts
18+
[Arguments] ${ip} ${host} ${hostsfile}=/etc/hosts
19+
VAR ${ttt}= ${ip}\t${host} # RF test marker\n
20+
${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command
21+
... echo "${ttt}" | sudo tee -a ${hostsfile}
22+
... sudo=True return_rc=True return_stderr=True return_stdout=True
23+
Should Be Equal As Integers ${rc} 0
24+
Remove Entry From Hosts
25+
[Documentation] Removes entry from local /etc/hosts
26+
[Arguments] ${host} ${hostsfile}=/etc/hosts
27+
${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command
28+
... sed -i "/${host} # RF test marker/d" ${hostsfile}
29+
... sudo=True return_rc=True return_stderr=True return_stdout=True
30+
Should Be Equal As Integers ${rc} 0

test/resources/oc.resource

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ Oc Delete
5656
Oc Exec
5757
[Documentation] Run 'oc exec' on a specific pod in the curret test namespace
5858
... Returns the command's combined STDOUT/STDER
59-
[Arguments] ${pod} ${cmd} ${ns}=${NAMESPACE}
60-
${output}= Run With Kubeconfig oc exec -n ${ns} pod/${pod} -- /bin/bash -c '${cmd}'
59+
[Arguments] ${pod} ${cmd} ${ns}=${NAMESPACE} ${shell}=/bin/bash
60+
${output}= Run With Kubeconfig oc exec -n ${ns} pod/${pod} -- ${shell} -c '${cmd}'
6161
RETURN ${output}
6262

6363
Oc Wait

test/suites/standard1/dns.robot

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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}

test/suites/standard2/validate-custom-certificates.robot

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Documentation Tests custom certificates functionality
44
Resource ../../resources/microshift-config.resource
55
Resource ../../resources/microshift-process.resource
66
Resource ../../resources/openssl.resource
7+
Resource ../../resources/hosts.resource
78
Library ../../resources/journalctl.py
89

910
Suite Setup Setup
@@ -176,25 +177,6 @@ Configure Named Certificates
176177
END
177178
Drop In MicroShift Config ${subject_alt_names} 10-subjectAltNames
178179

179-
Generate Random HostName
180-
[Documentation] Generate Random Hostname
181-
${rand}= Generate Random String
182-
${rand}= Convert To Lower Case ${rand}
183-
RETURN ${rand}.api.com
184-
185-
Add Entry To Hosts
186-
[Documentation] Add new entry to local /etc/hosts
187-
[Arguments] ${ip} ${host}
188-
VAR ${ttt}= ${ip}\t${host} # RF test marker\n
189-
${result}= Run Process sudo tee -a /etc/hosts shell=True stdin=${ttt}
190-
Should Be Equal As Integers ${result.rc} 0
191-
192-
Remove Entry From Hosts
193-
[Documentation] Removes entry from local /etc/hosts
194-
[Arguments] ${host}
195-
${result}= Run Process sudo sed -i "/${host} # RF test marker/d" /etc/hosts shell=True
196-
Should Be Equal As Integers ${result.rc} 0
197-
198180
Replace Server In Kubeconfig
199181
[Documentation] replace the server part of kubeconfig
200182
[Arguments] ${fqdn}

0 commit comments

Comments
 (0)