5 Resource DataModels.robot
8 Resource SSHKeywords.robot
10 Resource ../variables/netvirt/Variables.robot
11 Resource ../variables/Variables.robot
12 Resource VpnOperations.robot
13 Variables ../variables/coe/Modules.py
14 Variables ../variables/netvirt/Modules.py
17 ${CNI_BINARY_FILE} /opt/cni/bin/odlovs-cni
18 ${CONFIG_FILE} /etc/cni/net.d/odlovs-cni.conf
19 ${CONFIG_FILE_TEMPLATE} ${CURDIR}/../variables/coe/odlovs-cni.conf.j2
20 ${HOST_INVENTORY} ${CURDIR}/../variables/coe/hosts.yaml
21 ${K8s_MASTER_IP} ${TOOLS_SYSTEM_1_IP}
22 ${K8s_MINION1_IP} ${TOOLS_SYSTEM_2_IP}
23 ${K8s_MINION2_IP} ${TOOLS_SYSTEM_3_IP}
24 ${NODE_READY_STATUS} \\sReady
25 ${PLAYBOOK} ${CURDIR}/../variables/coe/coe_play.yaml
26 ${POD_RUNNING_STATUS} \\sRunning
27 ${WATCHER_COE} ${CURDIR}/../variables/coe/coe.yaml
28 @{NODE_IPs} ${K8s_MASTER_IP} ${K8s_MINION1_IP} ${K8s_MINION2_IP}
32 [Documentation] Suite setup keyword.
33 Coe.Configuration Playbook
34 Coe.Set Connection ids and Bridge
35 Coe.Verify Config Files
36 Coe.Verify Watcher Is Running
37 BuiltIn.Wait Until Keyword Succeeds 40s 2s Coe.Check Node Status Is Ready
39 Genius.Verify Tunnel Status as UP default-transport-zone
40 Coe.Derive Coe Data Models
42 Configuration Playbook
43 [Documentation] Ansible playbook which does all basic configuration for kubernetes nodes.
44 ${hosts} = OperatingSystem.Get File ${HOST_INVENTORY}
45 ${hosts} = String.Replace String ${hosts} master_ip ${K8s_MASTER_IP}
46 ${hosts} = String.Replace String ${hosts} minion1_ip ${K8s_MINION1_IP}
47 ${hosts} = String.Replace String ${hosts} minion2_ip ${K8s_MINION2_IP}
48 ${hosts} = String.Replace String ${hosts} odl_ip ${ODL_SYSTEM_IP}
49 ${hosts} = String.Replace String ${hosts} mport ${OVSDBPORT}
50 ${hosts} = String.Replace String ${hosts} cport ${ODL_OF_PORT_6653}
51 ${hosts} = String.Replace String ${hosts} filepath ${CONFIG_FILE_TEMPLATE}
52 ${hosts} = String.Replace String ${hosts} yamlpath ${USER_HOME}/coe.yaml
53 OperatingSystem.Create File ${USER_HOME}/hosts.yaml ${hosts}
54 ${watcher} = OperatingSystem.Get File ${WATCHER_COE}
55 ${watcher} = String.Replace String ${watcher} odlip ${ODL_SYSTEM_IP}
56 ${watcher} = String.Replace String ${watcher} port ${RESTCONFPORT}
57 OperatingSystem.Create File ${WATCHER_COE} ${watcher}
58 SSHKeywords.Copy_File_To_Remote_System ${K8s_MASTER_IP} ${WATCHER_COE} ${USER_HOME}
59 OperatingSystem.Move File ${PLAYBOOK} ${USER_HOME}
60 ${play_output} = OperatingSystem.Run ansible-playbook ${USER_HOME}/coe_play.yaml -i ${USER_HOME}/hosts.yaml
61 BuiltIn.Log ${play_output}
63 Set Connection ids and Bridge
64 [Documentation] Sets the connection ids for all the nodes and get the bridge from configuration file .
65 ${conn_id_1} = SSHLibrary.Open Connection ${K8s_MASTER_IP}
66 SSHKeywords.Flexible_SSH_Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
67 BuiltIn.Set Suite Variable ${conn_id_1}
68 ${conn_id_2} = SSHLibrary.Open Connection ${K8s_MINION1_IP}
69 SSHKeywords.Flexible_SSH_Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
70 BuiltIn.Set Suite Variable ${conn_id_2}
71 ${conn_id_3} = SSHLibrary.Open Connection ${K8s_MINION2_IP}
72 SSHKeywords.Flexible_SSH_Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
73 BuiltIn.Set Suite Variable ${conn_id_3}
74 ${file} = OperatingSystem.Get File ${CONFIG_FILE_TEMPLATE}
75 ${line} ${bridge} = Should Match Regexp ${file} "ovsBridge": "(\\w.*)"
76 BuiltIn.Set Suite Variable ${bridge}
79 [Documentation] Checks if the configuration files are present in all nodes
80 : FOR ${nodes} IN @{NODE_IPs}
81 \ Utils.Verify File Exists On Remote System ${nodes} ${CONFIG_FILE}
82 : FOR ${nodes} IN @{NODE_IPs}
83 \ Utils.Verify File Exists On Remote System ${nodes} ${CNI_BINARY_FILE}
85 Verify Watcher Is Running
86 [Documentation] Checks if watcher is running in the background
87 ${lines} = Utils.Run Command On Remote System ${K8s_MASTER_IP} ps -ef | grep watcher
88 BuiltIn.Should Match Regexp ${lines} .* watcher odl
90 Check Node Status Is Ready
91 [Documentation] Checks the status of nodes.This keyword is repeated until the status of all nodes is Ready
92 ${nodes} = Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl get nodes ${DEFAULT_USER} ${DEFAULT_PASSWORD} ${DEFAULT_LINUX_PROMPT_STRICT}
93 @{cluster} = String.Split To Lines ${nodes} 1
94 : FOR ${node} IN @{cluster}
95 \ BuiltIn.Should Match Regexp ${node} ${NODE_READY_STATUS}
98 [Documentation] Create labels for minions so that random allocation of pods to minions is avoided
99 ${nodes} = Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl get nodes
100 ${node_1} = String.Get Line ${nodes} 2
101 ${minion_1} = BuiltIn.Should Match Regexp ${node_1} ^\\w+-.*-\\d+
102 ${node_2} = String.Get Line ${nodes} 3
103 ${minion_2} = BuiltIn.Should Match Regexp ${node_2} ^\\w+-.*-\\d+
104 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} kubectl label nodes ${minion_1} disktype=ssd
105 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} kubectl label nodes ${minion_2} disktype=ssl
106 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} kubectl get nodes --show-labels
108 Derive Coe Data Models
109 [Documentation] Data models is created by integrating netvirt and coe data models which is given as input to get the model dumps
110 : FOR ${models} IN @{netvirt_data_models}
111 \ Collections.Append To List ${coe_data_models} ${models}
113 Check Pod Status Is Running
114 [Documentation] Checks the status of pods.This keyword is repeated until the status of all pods is Running
115 ${pods} = Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl get pods -o wide ${DEFAULT_USER} ${DEFAULT_PASSWORD} ${DEFAULT_LINUX_PROMPT_STRICT}
116 @{cluster} = String.Split To Lines ${pods} 1
117 : FOR ${pod} IN @{cluster}
118 \ BuiltIn.Should Match Regexp ${pod} ${POD_RUNNING_STATUS}
121 [Documentation] Test teardown to get dumpflows,ovsconfig,model dump,node status,pod status and to dump config files \ and delete pods.
122 OVSDB.Get DumpFlows And Ovsconfig ${conn_id_1} ${bridge}
123 OVSDB.Get DumpFlows And Ovsconfig ${conn_id_2} ${bridge}
124 OVSDB.Get DumpFlows And Ovsconfig ${conn_id_3} ${bridge}
125 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${coe_data_models}
127 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} kubectl get nodes ${DEFAULT_USER} ${DEFAULT_PASSWORD} ${DEFAULT_LINUX_PROMPT_STRICT}
128 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} kubectl get pods -o wide ${DEFAULT_USER} ${DEFAULT_PASSWORD} ${DEFAULT_LINUX_PROMPT_STRICT}
132 [Documentation] Waits till the keyword delete status succeeds implying that all pods created have been deleted
133 ${lines} = Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl get pods -o wide
134 @{lines} = String.Split To Lines ${lines} 1
135 : FOR ${status} IN @{lines}
136 \ ${pod_name} = BuiltIn.Should Match Regexp ${status} ^\\w+
137 \ Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl delete pods ${pod_name}
138 BuiltIn.Wait Until Keyword Succeeds 60s 3s Coe.Check If Pods Are Terminated
140 Check If Pods Are Terminated
141 [Documentation] Checks if the pods created have been terminated.The keyword is repeated until the pods are deleted
142 ${status} = Utils.Run Command On Remote System ${K8s_MASTER_IP} kubectl get pods -o wide ${DEFAULT_USER} ${DEFAULT_PASSWORD} ${DEFAULT_LINUX_PROMPT_STRICT}
143 ... ${DEFAULT_TIMEOUT} return_stdout=False return_stderr=True
144 BuiltIn.Should Contain ${status} No resources
147 [Documentation] Logs the configuration files present in all nodes
148 : FOR ${nodes} IN @{NODE_IPs}
149 \ Utils.Run Command On Remote System And Log ${nodes} cat ${CONFIG_FILE}
152 [Documentation] Suite teardown keyword
153 Coe.Collect Watcher Log
154 Coe.Collect Journalctl Log
157 SSHLibrary.Close All Connections
160 [Documentation] Watcher running in background logs into watcher.out which is copied to ${JENKINS_WORKSPACE}/archives/watcher.log
161 SSHLibrary.Open Connection ${K8s_MASTER_IP}
162 SSHKeywords.Flexible_SSH_Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
163 SSHLibrary.Get File /tmp/watcher.out ${JENKINS_WORKSPACE}/archives/watcher.log
164 SSHLibrary.Close Connection
166 Collect Journalctl Log
167 [Documentation] Logs of the command journalctl -u kubelet is copied to ${JENKINS_WORKSPACE}/archives/journal.log
168 Utils.Run Command On Remote System And Log ${K8s_MASTER_IP} sudo journalctl -u kubelet > ${USER_HOME}/journal.txt
169 SSHLibrary.Open Connection ${K8s_MASTER_IP}
170 SSHKeywords.Flexible_SSH_Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
171 SSHLibrary.Get File ${USER_HOME}/journal.txt ${JENKINS_WORKSPACE}/archives/journalctl.log
172 SSHLibrary.Close Connection
175 [Documentation] Kill the watcher running at the background after completion of tests cases
176 ${lines} = Utils.Run Command On Remote System ${K8s_MASTER_IP} ps -ef | grep watcher
177 ${line} ${pid} = BuiltIn.Should Match Regexp ${lines} \\w+\\s+(\\d+).*watcher odl
178 Utils.Run Command On Remote System ${K8s_MASTER_IP} kill -9 ${pid}
181 [Documentation] Reset K8s to clear up all stale entries
182 : FOR ${nodes} IN @{NODE_IPs}
183 \ ${kube} = Utils.Run Command On Remote System And Log ${nodes} sudo kubeadm reset
184 \ BuiltIn.Should Contain ${kube} Stopping the kubelet service.