X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Fcsit%2Flibraries%2FClusterKeywords.robot;fp=test%2Fcsit%2Flibraries%2FClusterKeywords.robot;h=46c1b979c177e4803a6db448e3e3458ed44adee3;hb=1d0f5a9a85cce93f7f0d332e13a238a16a6dd4fb;hp=45ba24a4c56fbd1268f5234657dded2a0b2ecf8e;hpb=72621754eca503ff5fd76be1ed550335ed6ab94d;p=integration.git diff --git a/test/csit/libraries/ClusterKeywords.robot b/test/csit/libraries/ClusterKeywords.robot index 45ba24a4..46c1b979 100644 --- a/test/csit/libraries/ClusterKeywords.robot +++ b/test/csit/libraries/ClusterKeywords.robot @@ -266,3 +266,63 @@ Check CarPeople \ ${counter}= Convert to String ${INDEX} \ Log user${counter} \ Should Contain ${resp.content} user${counter} + +Isolate a Controller From Cluster + [Arguments] ${isolated controller} @{controllers} + [Documentation] Use IPTables to isolate one controller from the cluster. + ... On the isolated controller it blocks IP traffic to and from each of the other controllers. + : FOR ${controller} IN @{controllers} + \ ${other controller}= Evaluate "${isolated controller}" != "${controller}" + \ Run Keyword If ${other controller} Isolate One Controller From Another ${isolated controller} ${controller} + +Rejoin a Controller To Cluster + [Arguments] ${isolated controller} @{controllers} + [Documentation] Use IPTables to rejoin one controller to the cluster. + ... On the isolated controller it unblocks IP traffic to and from each of the other controllers. + : FOR ${controller} IN @{controllers} + \ ${other controller}= Evaluate "${isolated controller}" != "${controller}" + \ Run Keyword If ${other controller} Rejoin One Controller To Another ${isolated controller} ${controller} + +Isolate One Controller From Another + [Arguments] ${isolated controller} ${controller} + [Documentation] Inserts an IPTable rule to disconnect one controller from another controller in the cluster. + Modify IPTables ${isolated controller} ${controller} -I + +Rejoin One Controller To Another + [Arguments] ${isolated controller} ${controller} + [Documentation] Deletes an IPTable rule, allowing one controller to reconnect to another controller in the cluster. + Modify IPTables ${isolated controller} ${controller} -D + +Modify IPTables + [Arguments] ${isolated controller} ${controller} ${rule type} + [Documentation] Adds a rule, usually inserting or deleting an entry between two controllers. + ${base string} Set Variable sudo iptables ${rule type} OUTPUT -p all --source + ${cmd string} Catenate ${base string} ${isolated controller} --destination ${controller} -j DROP + Run Command On Remote System ${isolated controller} ${cmd string} + ${cmd string} Catenate ${base string} ${controller} --destination ${isolated controller} -j DROP + Run Command On Remote System ${isolated controller} ${cmd string} + ${cmd string} Set Variable sudo iptables -L -n + ${return string}= Run Command On Remote System ${isolated controller} ${cmd string} + #If inserting rules: + Run Keyword If "${rule type}" == '-I' Should Match Regexp ${return string} [\s\S]*${isolated controller} *${controller}[\s\S]* + Run Keyword If "${rule type}" == '-I' Should Match Regexp ${return string} [\s\S]*${controller} *${isolated controller}[\s\S]* + #If deleting rules: + Run Keyword If "${rule type}" == '-D' Should Match Regexp ${return string} (?![\s\S]*${isolated controller} *${controller}[\s\S]*) + Run Keyword If "${rule type}" == '-D' Should Match Regexp ${return string} (?![\s\S]*${controller} *${isolated controller}[\s\S]*) + +Rejoin All Isolated Controllers + [Arguments] @{controllers} + [Documentation] Wipe all IPTables rules from all controllers, thus rejoining all controllers. + : FOR ${isolated controller} IN @{controllers} + \ Flush IPTables ${isolated controller} + +Flush IPTables + [Arguments] ${isolated controller} + [Documentation] This keyword is generally not called from a test case but supports a complete wipe of all rules on + ... all contollers. + ${cmd string} Set Variable sudo iptables -v -F + ${return string}= Run Command On Remote System ${isolated controller} ${cmd string} + Log return: ${return string} + Should Contain ${return string} Flushing chain `INPUT' + Should Contain ${return string} Flushing chain `FORWARD' + Should Contain ${return string} Flushing chain `OUTPUT'