def testMasterSlaveRemove(self): self.setupClusterA(temp_cib) output, returnVal = pcs( temp_cib, "constraint location ClusterIP5 prefers rh7-1") assert returnVal == 0 assert output == "" output, returnVal = pcs( temp_cib, "constraint location ClusterIP5 prefers rh7-2") assert returnVal == 0 assert output == "" output, returnVal = pcs(temp_cib, "resource delete Master") assert returnVal == 1 assert output == "Error: Master is not a resource (it can be removed with 'resource unmaster Master')\n" output, returnVal = pcs(temp_cib, "resource unmaster Master") assert returnVal == 0 assert output == "" output, returnVal = pcs(temp_cib, "config") assert returnVal == 0 ac( output, 'Cluster Name: test99\nCorosync Nodes:\n rh7-1 rh7-2 \nPacemaker Nodes:\n \n\nResources: \n Resource: ClusterIP6 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP6-monitor-interval-30s)\n Group: TestGroup1\n Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP-monitor-interval-30s)\n Group: TestGroup2\n Resource: ClusterIP2 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP2-monitor-interval-30s)\n Resource: ClusterIP3 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP3-monitor-interval-30s)\n Clone: ClusterIP4-clone\n Resource: ClusterIP4 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP4-monitor-interval-30s)\n Resource: ClusterIP5 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP5-monitor-interval-30s)\n\nStonith Devices: \nFencing Levels: \n\nLocation Constraints:\n Resource: ClusterIP5\n Enabled on: rh7-1 (score:INFINITY) (id:location-ClusterIP5-rh7-1-INFINITY)\n Enabled on: rh7-2 (score:INFINITY) (id:location-ClusterIP5-rh7-2-INFINITY)\nOrdering Constraints:\nColocation Constraints:\n\nCluster Properties:\n' )
def testPcmkHostAllowsMissingPort(self): # Test that port is not required when pcmk_host_argument or # pcmk_host_list or pcmk_host_map is specified output, returnVal = pcs( temp_cib, 'stonith create apc-1 fence_apc params ipaddr="ip" login="******" action="reboot"' ) ac(output, """\ Error: missing required option(s): 'port' for resource type: stonith:fence_apc (use --force to override) """) self.assertEquals(returnVal, 1) output, returnVal = pcs( temp_cib, 'stonith create apc-2 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_map="buzz-01:1;buzz-02:2"' ) ac(output, "") self.assertEquals(returnVal, 0) output, returnVal = pcs( temp_cib, 'stonith create apc-3 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_list="buzz-01,buzz-02"' ) ac(output, "") self.assertEquals(returnVal, 0) output, returnVal = pcs( temp_cib, 'stonith create apc-4 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_argument="buzz-01"' ) ac(output, "") self.assertEquals(returnVal, 0)
def test_set_property_validation_integer(self): output, returnVal = pcs( temp_cib, "property set default-resource-stickiness=0" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: default-resource-stickiness: 0 """ ) output, returnVal = pcs( temp_cib, "property set default-resource-stickiness=-10" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: default-resource-stickiness: -10 """ ) output, returnVal = pcs( temp_cib, "property set default-resource-stickiness=0 --force" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: default-resource-stickiness: 0 """ ) output, returnVal = pcs( temp_cib, "property set default-resource-stickiness=0.1" ) ac( output, "Error: invalid value of property: " "'default-resource-stickiness=0.1', (use --force to override)\n" ) self.assertEqual(returnVal, 1) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: default-resource-stickiness: 0 """ ) output, returnVal = pcs( temp_cib, "property set default-resource-stickiness=0.1 --force" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: default-resource-stickiness: 0.1 """ )
def testAllConstraints(self): output, returnVal = pcs(temp_cib, "constraint location D5 prefers node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint order Master then D5") assert ( returnVal == 0 and output == "Adding Master D5 (kind: Mandatory) (Options: first-action=start then-action=start)\n" ), output output, returnVal = pcs(temp_cib, "constraint colocation add Master with D5") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint --full") assert returnVal == 0 ac( output, "Location Constraints:\n Resource: D5\n Enabled on: node1 (score:INFINITY) (id:location-D5-node1-INFINITY)\nOrdering Constraints:\n start Master then start D5 (Mandatory) (id:order-Master-D5-mandatory)\nColocation Constraints:\n Master with D5 (INFINITY) (id:colocation-Master-D5-INFINITY)\n", ) output, returnVal = pcs(temp_cib, "constraint show --full") assert returnVal == 0 ac( output, "Location Constraints:\n Resource: D5\n Enabled on: node1 (score:INFINITY) (id:location-D5-node1-INFINITY)\nOrdering Constraints:\n start Master then start D5 (Mandatory) (id:order-Master-D5-mandatory)\nColocation Constraints:\n Master with D5 (INFINITY) (id:colocation-Master-D5-INFINITY)\n", )
def testPcmkHostAllowsMissingPort(self): # Test that port is not required when pcmk_host_argument or # pcmk_host_list or pcmk_host_map is specified output, returnVal = pcs( temp_cib, 'stonith create apc-1 fence_apc params ipaddr="ip" login="******" action="reboot"' ) ac( output, """\ Error: missing required option(s): 'port' for resource type: stonith:fence_apc (use --force to override) """) self.assertEquals(returnVal, 1) output, returnVal = pcs( temp_cib, 'stonith create apc-2 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_map="buzz-01:1;buzz-02:2"' ) ac(output, "") self.assertEquals(returnVal, 0) output, returnVal = pcs( temp_cib, 'stonith create apc-3 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_list="buzz-01,buzz-02"' ) ac(output, "") self.assertEquals(returnVal, 0) output, returnVal = pcs( temp_cib, 'stonith create apc-4 fence_apc params ipaddr="ip" login="******" action="reboot" pcmk_host_argument="buzz-01"' ) ac(output, "") self.assertEquals(returnVal, 0)
def testBadInstanceVariables(self): output, returnVal = pcs( temp_cib, "resource create D0 Dummy test=testC test2=test2a op monitor interval=35 meta test7=test7a test6=" ) assert returnVal == 1 assert output == "Error: resource option(s): 'test, test2', are not recognized for resource type: 'ocf:heartbeat:Dummy' (use --force to override)\n", [ output ] output, returnVal = pcs( temp_cib, "resource create --force D0 Dummy test=testC test2=test2a test4=test4A op monitor interval=35 meta test7=test7a test6=" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource update D0 test=testA test2=testB") assert returnVal == 1 assert output == "Error: resource option(s): 'test, test2', are not recognized for resource type: 'ocf:heartbeat:Dummy' (use --force to override)\n", [ output ] output, returnVal = pcs( temp_cib, "resource update --force D0 test=testB test2=testC test3=testD") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource show D0") assert returnVal == 0 assert output == " Resource: D0 (class=ocf provider=heartbeat type=Dummy)\n Attributes: test=testB test2=testC test4=test4A test3=testD \n Meta Attrs: test7=test7a test6= \n Operations: monitor interval=35 (D0-monitor-interval-35)\n", [ output ]
def testMissingRole(self): os.system("CIB_file="+temp_cib+" cibadmin -R --scope nodes --xml-text '<nodes><node id=\"1\" uname=\"rh7-1\"/><node id=\"2\" uname=\"rh7-2\"/></nodes>'") o,r = pcs("resource create stateful0 Stateful --master") os.system("CIB_file="+temp_cib+" cibadmin -R --scope constraints --xml-text '<constraints><rsc_location id=\"cli-prefer-stateful0-master\" role=\"Master\" rsc=\"stateful0-master\" node=\"rh7-1\" score=\"INFINITY\"/><rsc_location id=\"cli-ban-stateful0-master-on-rh7-1\" rsc=\"stateful0-master\" role=\"Slave\" node=\"rh7-1\" score=\"-INFINITY\"/></constraints>'") o,r = pcs("constraint") ac(o,"Location Constraints:\n Resource: stateful0-master\n Enabled on: rh7-1 (score:INFINITY) (role: Master)\n Disabled on: rh7-1 (score:-INFINITY) (role: Slave)\nOrdering Constraints:\nColocation Constraints:\n") assert r == 0
def testNodeStandby(self): output, returnVal = pcs(temp_cib, "cluster standby rh7-1") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_cib, "cluster standby nonexistant-node") assert returnVal == 1 assert output == "Error: node 'nonexistant-node' does not appear to exist in configuration\n"
def testNodeStandby(self): output, returnVal = pcs(temp_cib, "cluster standby rh7-1") assert returnVal == 0 assert output == "" output, returnVal = pcs(temp_cib, "cluster standby nonexistant-node") assert returnVal == 1 assert output == "Error: node 'nonexistant-node' does not appear to exist in configuration\n"
def testStonithFenceConfirm(self): output, returnVal = pcs(temp_cib, "stonith fence blah blah") assert returnVal == 1 assert output == "Error: must specify one (and only one) node to fence\n" output, returnVal = pcs(temp_cib, "stonith confirm blah blah") assert returnVal == 1 assert output == "Error: must specify one (and only one) node to confirm fenced\n"
def testAdvancedConstraintRule(self): o,r = pcs(temp_cib, "constraint location D1 rule score=INFINITY not_defined pingd or pingd lte 0") ac(o,"") assert r == 0 output, returnVal = pcs(temp_cib, "constraint --full") assert returnVal == 0 ac (output,'Location Constraints:\n Resource: D1\n Constraint: location-D1\n Rule: score=INFINITY boolean-op=or (id:location-D1-rule) \n Expression: not_defined pingd (id:location-D1-rule-expr-1) \n Expression: pingd lte 0 (id:location-D1-rule-expr-2) \nOrdering Constraints:\nColocation Constraints:\n')
def testPcmkHostList(self): output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb'") assert returnVal == 0 ac(output,"Warning: missing required option(s): 'ipaddr, login, port, action' for resource type: stonith:fence_apc\n") output, returnVal = pcs(temp_cib, "stonith show F1") assert returnVal == 0 assert output == ' Resource: F1 (class=stonith type=fence_apc)\n Attributes: pcmk_host_list="nodea nodeb" \n Operations: monitor interval=60s (F1-monitor-interval-60s)\n',[output]
def testPcmkHostList(self): output, returnVal = pcs(temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb' --force") assert returnVal == 0 ac(output,"") output, returnVal = pcs(temp_cib, "stonith show F1") assert returnVal == 0 assert output == ' Resource: F1 (class=stonith type=fence_apc)\n Attributes: pcmk_host_list="nodea nodeb" \n Operations: monitor interval=60s (F1-monitor-interval-60s)\n',[output]
def testConstraintRemoval(self): output, returnVal = pcs(temp_cib, "constraint location D5 prefers node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint rm blahblah") assert returnVal == 1 and output.startswith( "Error: Unable to find constraint - 'blahblah'"), output
def testResourceShow(self): line = "resource create ClusterIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" output, returnVal = pcs(temp_cib, "resource show ClusterIP") assert returnVal == 0 assert output == ' Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP-monitor-interval-30s)\n', [output]
def testColocationSets(self): o, r = pcs( temp_cib, "constraint colocation set D5 D6 D7 sequential=false set D8 D9 sequential=true setoptions score=INFINITY " ) ac(o, "") assert r == 0 o, r = pcs(temp_cib, "constraint colocation set D5 D6") assert r == 0 ac(o, "") o, r = pcs(temp_cib, "constraint colocation set D5 D6 set D7 D8 set D8 D9") assert r == 0 ac(o, "") o, r = pcs(temp_cib, "constraint colocation --full") ac( o, "Colocation Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set) set D8 D9 sequential=true (id:pcs_rsc_set-1) setoptions score=INFINITY (id:pcs_rsc_colocation)\n set D5 D6 (id:pcs_rsc_set-2) (id:pcs_rsc_colocation-1)\n set D5 D6 (id:pcs_rsc_set-3) set D7 D8 (id:pcs_rsc_set-4) set D8 D9 (id:pcs_rsc_set-5) (id:pcs_rsc_colocation-2)\n" ) assert r == 0 o, r = pcs(temp_cib, "constraint remove pcs_rsc_colocation-1") ac(o, "") assert r == 0 o, r = pcs(temp_cib, "constraint colocation --full") ac( o, "Colocation Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set) set D8 D9 sequential=true (id:pcs_rsc_set-1) setoptions score=INFINITY (id:pcs_rsc_colocation)\n set D5 D6 (id:pcs_rsc_set-3) set D7 D8 (id:pcs_rsc_set-4) set D8 D9 (id:pcs_rsc_set-5) (id:pcs_rsc_colocation-2)\n" ) assert r == 0 o, r = pcs(temp_cib, "resource delete D5") ac( o, "Removing D5 from set pcs_rsc_set\nRemoving D5 from set pcs_rsc_set-3\nDeleting Resource - D5\n" ) assert r == 0 o, r = pcs(temp_cib, "resource delete D6") ac( o, "Removing D6 from set pcs_rsc_set\nRemoving D6 from set pcs_rsc_set-3\nRemoving set pcs_rsc_set-3\nDeleting Resource - D6\n" ) assert r == 0 o, r = pcs(temp_cib, "constraint ref D7") ac(o, "Resource: D7\n pcs_rsc_colocation\n pcs_rsc_colocation-2\n") assert r == 0 o, r = pcs(temp_cib, "constraint ref D8") ac(o, "Resource: D8\n pcs_rsc_colocation\n pcs_rsc_colocation-2\n") assert r == 0
def test_set_property_validation_boolean(self): output, returnVal = pcs(temp_cib, "property set enable-acl=TRUE") ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: enable-acl: TRUE """ ) output, returnVal = pcs(temp_cib, "property set enable-acl=no") ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: enable-acl: no """ ) output, returnVal = pcs( temp_cib, "property set enable-acl=TRUE --force" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: enable-acl: TRUE """ ) output, returnVal = pcs( temp_cib, "property set enable-acl=not_valid_value" ) ac( output, "Error: invalid value of property: " "'enable-acl=not_valid_value', (use --force to override)\n" ) self.assertEqual(returnVal, 1) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: enable-acl: TRUE """ ) output, returnVal = pcs( temp_cib, "property set enable-acl=not_valid_value --force" ) ac(output, "") self.assertEqual(returnVal, 0) o, _ = pcs(temp_cib, "property list") ac(o, """Cluster Properties: enable-acl: not_valid_value """ )
def testConstraintRules(self): print "WARNING: RULES TEMPORARILY DISABLED" return output, returnVal = pcs( temp_cib, "constraint location D1 rule 222: '#uname' eq c00n03") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D2 rule -INFINITY: '#uname' eq c00n04") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D3 rule pingd: defined pingd") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D4 rule INFINITY: date start=2005-001 operation=gt" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D5 rule INFINITY: date start=2005-001 end=2006-001 operation=in_range" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D6 rule INFINITY: date operation=date_spec years=2005" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D3 rule -INFINITY: not_defined pingd or pingd lte 0" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D3 rule -INFINITY: not_defined pingd and pingd lte 0" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "constraint") assert returnVal == 0 ac( output, 'Location Constraints:\n Resource: D1\n Rule: score=222 \n Expression: #uname eq c00n03 \n Resource: D2\n Rule: score=-INFINITY \n Expression: #uname eq c00n04 \n Resource: D3\n Rule: score-attribute=pingd \n Expression: defined pingd \n Rule: score=-INFINITY boolean-op=or \n Expression: not_defined pingd \n Expression: pingd lte 0 \n Rule: score=-INFINITY boolean-op=and \n Expression: not_defined pingd \n Expression: pingd lte 0 \n Resource: D4\n Rule: score=INFINITY \n Expression: start=2005-001 operation=gt \n Resource: D5\n Rule: score=INFINITY \n Expression: start=2005-001 operation=in_range end=2006-001 \n Resource: D6\n Rule: score=INFINITY \n Expression: operation=date_spec \n Date Spec: years=2005 \nOrdering Constraints:\nColocation Constraints:\n' )
def testColocationConstraints(self): o, r = pcs(temp_cib, "constraint colocation add D1 D3") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add D1 D2 100") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add D4 with D5 100") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add master M1 with master M2") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add M3 with M4") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add slave M5 with started M6 500") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add M7 with Master M8") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add Slave M9 with M10") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint") assert r == 0 and o == 'Location Constraints:\nOrdering Constraints:\nColocation Constraints:\n D1 with D3\n D1 with D2 (100)\n D4 with D5 (100)\n M1 with M2 (rsc-role:Master) (with-rsc-role:Master)\n M3 with M4\n M5 with M6 (500) (rsc-role:Slave) (with-rsc-role:Started)\n M7 with M8 (rsc-role:Started) (with-rsc-role:Master)\n M9 with M10 (rsc-role:Slave) (with-rsc-role:Started)\n', [o]
def testColocationConstraints(self): o, r = pcs(temp_cib, "constraint colocation add D1 D3") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add D1 D2 100") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add D4 with D5 100") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add master M1 with master M2") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add M3 with M4") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add slave M5 with started M6 500") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add M7 with Master M8") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint colocation add Slave M9 with M10") assert r == 0 and o == "", o o, r = pcs(temp_cib, "constraint") assert r == 0 and o == 'Location Constraints:\nOrdering Constraints:\nColocation Constraints:\n D1 with D3\n D1 with D2 (100)\n D4 with D5 (100)\n M1 with M2 (rsc-role:Master) (with-rsc-role:Master)\n M3 with M4\n M5 with M6 (500) (rsc-role:Slave) (with-rsc-role:Started)\n M7 with M8 (rsc-role:Started) (with-rsc-role:Master)\n M9 with M10 (rsc-role:Slave) (with-rsc-role:Started)\n', [ o ]
def testResourceShow(self): line = "resource create ClusterIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" output, returnVal = pcs(temp_cib, "resource show ClusterIP") assert returnVal == 0 assert output == ' Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP-monitor-interval-30s)\n', [ output ]
def testLSBResource(self): output, returnVal = pcs(temp_cib, "resource create D2 lsb:network") assert returnVal == 0 assert output == "", [output] output, returnval = pcs(temp_cib, "resource update D2 blah=blah") assert returnVal == 0 assert output == "", [output] output, returnval = pcs(temp_cib, "resource update D2") assert returnVal == 0 assert output == "", [output]
def testMultipleOrderConstraints(self): o,r = pcs("constraint order stop D1 then stop D2") ac(o,"Adding D1 D2 (kind: Mandatory) (Options: first-action=stop then-action=stop)\n") assert r == 0 o,r = pcs("constraint order start D1 then start D2") ac(o,"Adding D1 D2 (kind: Mandatory) (Options: first-action=start then-action=start)\n") assert r == 0 o,r = pcs("constraint --full") ac(o,"Location Constraints:\nOrdering Constraints:\n stop D1 then stop D2 (kind:Mandatory) (id:order-D1-D2-mandatory)\n start D1 then start D2 (kind:Mandatory) (id:order-D1-D2-mandatory-1)\nColocation Constraints:\n") assert r == 0
def testBadProperties(self): o,r = pcs("property set xxxx=zzzz") assert r==1 ac(o,"Error: unknown cluster property: 'xxxx', (use --force to override)\n") o,r = pcs("property unset zzzzz") assert r==1 ac(o,"Error: can't remove property: 'zzzzz' that doesn't exist\n") o,r = pcs("property unset zzzz --force") assert r==0 ac(o,"")
def testPcmkHostList(self): output, returnVal = pcs( temp_cib, "stonith create F1 fence_apc 'pcmk_host_list=nodea nodeb' --force") assert returnVal == 0 ac(output, "") output, returnVal = pcs(temp_cib, "stonith show F1") assert returnVal == 0 assert output == ' Resource: F1 (class=stonith type=fence_apc)\n Attributes: pcmk_host_list="nodea nodeb" \n Operations: monitor interval=60s (F1-monitor-interval-60s)\n', [ output ]
def testDescribe(self): output, returnVal = pcs(temp_cib, "resource describe bad_resource") assert returnVal == 1 assert output == "Error: Unable to find resource: bad_resource\n" output, returnVal = pcs(temp_cib, "resource describe ocf:heartbeat:Dummy") assert returnVal == 0 ac(output,"Resource options for: ocf:heartbeat:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\n") output, returnVal = pcs(temp_cib, "resource describe Dummy") assert returnVal == 0 ac(output,"Resource options for: ocf:heartbeat:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\nResource options for: ocf:pacemaker:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\n op_sleep: Number of seconds to sleep during operations. This can be used to\n test how the cluster reacts to operation timeouts.\n")
def test_stonith_create_provides_unfencing_rhel6(self): if not utils.is_rhel6(): return output, returnVal = pcs( temp_cib, "stonith create f1 fence_mpath key=abc" ) ac(output, "") self.assertEqual(0, returnVal) output, returnVal = pcs( temp_cib, "stonith create f2 fence_mpath key=abc meta provides=unfencing" ) ac(output, "") self.assertEqual(0, returnVal) output, returnVal = pcs( temp_cib, "stonith create f3 fence_mpath key=abc meta provides=something" ) ac(output, "") self.assertEqual(0, returnVal) output, returnVal = pcs( temp_cib, "stonith create f4 fence_xvm meta provides=something" ) ac(output, "") self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "stonith show --full") ac(output, """\ Resource: f1 (class=stonith type=fence_mpath) Attributes: key=abc Meta Attrs: provides=unfencing Operations: monitor interval=60s (f1-monitor-interval-60s) Resource: f2 (class=stonith type=fence_mpath) Attributes: key=abc Meta Attrs: provides=unfencing Operations: monitor interval=60s (f2-monitor-interval-60s) Resource: f3 (class=stonith type=fence_mpath) Attributes: key=abc Meta Attrs: provides=unfencing Operations: monitor interval=60s (f3-monitor-interval-60s) Resource: f4 (class=stonith type=fence_xvm) Meta Attrs: provides=something Operations: monitor interval=60s (f4-monitor-interval-60s) """) self.assertEqual(0, returnVal)
def testResourceUpdate(self): line = "resource create ClusterIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = 'resource update' output, returnVal = pcs(temp_cib, line) assert returnVal == 1 assert output.startswith("\nUsage: pcs resource") output, returnVal = pcs(temp_cib, "resource update ClusterIP ip=192.168.0.100") assert returnVal == 0 assert output == ""
def setupClusterA(self,temp_cib): line = "resource create D1 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D2 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D3 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D4 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D5 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D6 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource clone D3" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource master Master D4" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == ""
def testMasterSlaveConstraint(self): os.system("CIB_file="+temp_cib+" cibadmin -R --scope nodes --xml-text '<nodes><node id=\"1\" uname=\"rh7-1\"/><node id=\"2\" uname=\"rh7-2\"/></nodes>'") o,r = pcs("resource create dummy1 dummy") ac(o,"") assert r == 0 o,r = pcs("resource create stateful1 stateful --master") ac(o,"") assert r == 0 o,r = pcs("constraint order stateful1 then dummy1") ac(o,"Error: stateful1 is a master/slave resource, you must use the master id: stateful1-master when adding constraints\n") assert r == 1 o,r = pcs("constraint order dummy1 then stateful1") ac(o,"Error: stateful1 is a master/slave resource, you must use the master id: stateful1-master when adding constraints\n") assert r == 1 o,r = pcs("constraint colocation add stateful1 with dummy1") ac(o,"Error: stateful1 is a master/slave resource, you must use the master id: stateful1-master when adding constraints\n") assert r == 1 o,r = pcs("constraint colocation add dummy1 with stateful1") ac(o,"Error: stateful1 is a master/slave resource, you must use the master id: stateful1-master when adding constraints\n") assert r == 1 o,r = pcs("constraint order dummy1 then stateful1") ac(o,"Error: stateful1 is a master/slave resource, you must use the master id: stateful1-master when adding constraints\n") assert r == 1 o,r = pcs("constraint --full") ac(o,"Location Constraints:\nOrdering Constraints:\nColocation Constraints:\n") assert r == 0
def testOrderSets(self): o, r = pcs(temp_cib, "constraint order set D5 D6 D7 sequential=false set D8 D9 sequential=true") ac(o,"") assert r == 0 o, r = pcs(temp_cib, "constraint order set D5 D6") assert r == 0 ac(o,"") o, r = pcs(temp_cib, "constraint order set D5 D6 set D7 D8 set D8 D9") assert r == 0 ac(o,"") o, r = pcs(temp_cib, "constraint order --full") assert r == 0 ac(o,"Ordering Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set) set D8 D9 sequential=true (id:pcs_rsc_set-1) (id:pcs_rsc_order)\n set D5 D6 (id:pcs_rsc_set-2) (id:pcs_rsc_order-1)\n set D5 D6 (id:pcs_rsc_set-3) set D7 D8 (id:pcs_rsc_set-4) set D8 D9 (id:pcs_rsc_set-5) (id:pcs_rsc_order-2)\n") o, r = pcs(temp_cib, "constraint remove pcs_rsc_order-1") assert r == 0 ac(o,"") o, r = pcs(temp_cib, "constraint order --full") assert r == 0 ac(o,"Ordering Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set) set D8 D9 sequential=true (id:pcs_rsc_set-1) (id:pcs_rsc_order)\n set D5 D6 (id:pcs_rsc_set-3) set D7 D8 (id:pcs_rsc_set-4) set D8 D9 (id:pcs_rsc_set-5) (id:pcs_rsc_order-2)\n") o, r = pcs(temp_cib, "resource delete D5") ac(o,"Removing D5 from set pcs_rsc_set\nRemoving D5 from set pcs_rsc_set-3\nDeleting Resource - D5\n") assert r == 0 o, r = pcs(temp_cib, "resource delete D6") ac(o,"Removing D6 from set pcs_rsc_set\nRemoving D6 from set pcs_rsc_set-3\nRemoving set pcs_rsc_set-3\nDeleting Resource - D6\n") assert r == 0
def testDefaults(self): output, returnVal = pcs(temp_cib, "property --defaults") assert returnVal == 0, 'Unable to list resources' assert output == 'Cluster Properties:\n batch-limit: 30\n cluster-delay: 60s\n cluster-infrastructure: heartbeat\n cluster-recheck-interval: 15min\n crmd-finalization-timeout: 30min\n crmd-integration-timeout: 3min\n crmd-transition-delay: 0s\n dc-deadtime: 20s\n dc-version: none\n default-action-timeout: 20s\n default-resource-stickiness: 0\n election-timeout: 2min\n enable-startup-probes: true\n expected-quorum-votes: 2\n is-managed-default: true\n maintenance-mode: false\n migration-limit: -1\n no-quorum-policy: stop\n node-health-green: 0\n node-health-red: -INFINITY\n node-health-strategy: none\n node-health-yellow: 0\n pe-error-series-max: -1\n pe-input-series-max: 4000\n pe-warn-series-max: 5000\n placement-strategy: default\n remove-after-stop: false\n shutdown-escalation: 20min\n start-failure-is-fatal: true\n startup-fencing: true\n stonith-action: reboot\n stonith-enabled: true\n stonith-timeout: 60s\n stop-all-resources: false\n stop-orphan-actions: true\n stop-orphan-resources: true\n symmetric-cluster: true\n', [output] output, returnVal = pcs(temp_cib, "property --all") assert returnVal == 0, 'Unable to list resources' assert output == 'Cluster Properties:\n batch-limit: 30\n cluster-delay: 60s\n cluster-infrastructure: heartbeat\n cluster-recheck-interval: 15min\n crmd-finalization-timeout: 30min\n crmd-integration-timeout: 3min\n crmd-transition-delay: 0s\n dc-deadtime: 20s\n dc-version: none\n default-action-timeout: 20s\n default-resource-stickiness: 0\n election-timeout: 2min\n enable-startup-probes: true\n expected-quorum-votes: 2\n is-managed-default: true\n maintenance-mode: false\n migration-limit: -1\n no-quorum-policy: stop\n node-health-green: 0\n node-health-red: -INFINITY\n node-health-strategy: none\n node-health-yellow: 0\n pe-error-series-max: -1\n pe-input-series-max: 4000\n pe-warn-series-max: 5000\n placement-strategy: default\n remove-after-stop: false\n shutdown-escalation: 20min\n start-failure-is-fatal: true\n startup-fencing: true\n stonith-action: reboot\n stonith-enabled: true\n stonith-timeout: 60s\n stop-all-resources: false\n stop-orphan-actions: true\n stop-orphan-resources: true\n symmetric-cluster: true\n', [output] output, returnVal = pcs(temp_cib, "property set blahblah=blah") assert returnVal == 1 assert output == "Error: unknown cluster property: 'blahblah', (use --force to override)\n",[output] output, returnVal = pcs(temp_cib, "property set blahblah=blah --force") assert returnVal == 0,output assert output == "",output output, returnVal = pcs(temp_cib, "property set stonith-enabled=false") assert returnVal == 0,output assert output == "",output output, returnVal = pcs(temp_cib, "property") assert returnVal == 0 assert output == "Cluster Properties:\n blahblah: blah\n stonith-enabled: false\n", [output] output, returnVal = pcs(temp_cib, "property --defaults") assert returnVal == 0, 'Unable to list resources' assert output == 'Cluster Properties:\n batch-limit: 30\n cluster-delay: 60s\n cluster-infrastructure: heartbeat\n cluster-recheck-interval: 15min\n crmd-finalization-timeout: 30min\n crmd-integration-timeout: 3min\n crmd-transition-delay: 0s\n dc-deadtime: 20s\n dc-version: none\n default-action-timeout: 20s\n default-resource-stickiness: 0\n election-timeout: 2min\n enable-startup-probes: true\n expected-quorum-votes: 2\n is-managed-default: true\n maintenance-mode: false\n migration-limit: -1\n no-quorum-policy: stop\n node-health-green: 0\n node-health-red: -INFINITY\n node-health-strategy: none\n node-health-yellow: 0\n pe-error-series-max: -1\n pe-input-series-max: 4000\n pe-warn-series-max: 5000\n placement-strategy: default\n remove-after-stop: false\n shutdown-escalation: 20min\n start-failure-is-fatal: true\n startup-fencing: true\n stonith-action: reboot\n stonith-enabled: true\n stonith-timeout: 60s\n stop-all-resources: false\n stop-orphan-actions: true\n stop-orphan-resources: true\n symmetric-cluster: true\n', [output] output, returnVal = pcs(temp_cib, "property --all") assert returnVal == 0, 'Unable to list resources' assert output == 'Cluster Properties:\n batch-limit: 30\n blahblah: blah\n cluster-delay: 60s\n cluster-infrastructure: heartbeat\n cluster-recheck-interval: 15min\n crmd-finalization-timeout: 30min\n crmd-integration-timeout: 3min\n crmd-transition-delay: 0s\n dc-deadtime: 20s\n dc-version: none\n default-action-timeout: 20s\n default-resource-stickiness: 0\n election-timeout: 2min\n enable-startup-probes: true\n expected-quorum-votes: 2\n is-managed-default: true\n maintenance-mode: false\n migration-limit: -1\n no-quorum-policy: stop\n node-health-green: 0\n node-health-red: -INFINITY\n node-health-strategy: none\n node-health-yellow: 0\n pe-error-series-max: -1\n pe-input-series-max: 4000\n pe-warn-series-max: 5000\n placement-strategy: default\n remove-after-stop: false\n shutdown-escalation: 20min\n start-failure-is-fatal: true\n startup-fencing: true\n stonith-action: reboot\n stonith-enabled: false\n stonith-timeout: 60s\n stop-all-resources: false\n stop-orphan-actions: true\n stop-orphan-resources: true\n symmetric-cluster: true\n', [output]
def testConstraintRules(self): output, returnVal = pcs(temp_cib, "constraint location D1 rule score=222 '#uname' eq c00n03") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "constraint location D2 rule score=-INFINITY '#uname' eq c00n04") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "constraint location D3 rule score=pingd defined pingd") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "constraint location D4 rule score=INFINITY date start=2005-001 gt") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D5 rule score=INFINITY date start=2005-001 end=2006-001 in_range" ) assert returnVal == 0 assert output == "", [output] output, returnVal = pcs( temp_cib, "constraint location D6 rule score=INFINITY date-spec operation=date_spec years=2005" ) assert output == "", [output] assert returnVal == 0 # We don't support and/or yet # output, returnVal = pcs(temp_cib, "constraint location D3 rule score=-INFINITY not_defined pingd or pingd lte 0") # assert returnVal == 0 # assert output == "", [output] # output, returnVal = pcs(temp_cib, "constraint location D3 rule score=-INFINITY not_defined pingd and pingd lte 0") # assert returnVal == 0 # assert output == "", [output] output, returnVal = pcs(temp_cib, "constraint --full") assert returnVal == 0 ac( output, "Location Constraints:\n Resource: D1\n Constraint: location-D1\n Rule: score=222 (id:location-D1-rule) \n Expression: #uname eq c00n03 (id:location-D1-rule-expr) \n Resource: D2\n Constraint: location-D2\n Rule: score=-INFINITY (id:location-D2-rule) \n Expression: #uname eq c00n04 (id:location-D2-rule-expr) \n Resource: D3\n Constraint: location-D3\n Rule: score-attribute=pingd (id:location-D3-rule) \n Expression: defined pingd (id:location-D3-rule-expr) \n Resource: D4\n Constraint: location-D4\n Rule: score=INFINITY (id:location-D4-rule) \n Expression: start=2005-001 operation=gt (id:location-D4-rule-expr) \n Resource: D5\n Constraint: location-D5\n Rule: score=INFINITY (id:location-D5-rule) \n Expression: start=2005-001 operation=in_range end=2006-001 (id:location-D5-rule-expr) \n Resource: D6\n Constraint: location-D6\n Rule: score=INFINITY (id:location-D6-rule) \n Expression: (id:location-D6-rule-expr) \n Date Spec: years=2005 (id:location-D6-rule-expr-datespec) \nOrdering Constraints:\nColocation Constraints:\n", ) o, r = pcs("constraint remove location-D4-rule") ac(o, "") assert r == 0 output, returnVal = pcs(temp_cib, "constraint --full") assert returnVal == 0 ac( output, "Location Constraints:\n Resource: D1\n Constraint: location-D1\n Rule: score=222 (id:location-D1-rule) \n Expression: #uname eq c00n03 (id:location-D1-rule-expr) \n Resource: D2\n Constraint: location-D2\n Rule: score=-INFINITY (id:location-D2-rule) \n Expression: #uname eq c00n04 (id:location-D2-rule-expr) \n Resource: D3\n Constraint: location-D3\n Rule: score-attribute=pingd (id:location-D3-rule) \n Expression: defined pingd (id:location-D3-rule-expr) \n Resource: D5\n Constraint: location-D5\n Rule: score=INFINITY (id:location-D5-rule) \n Expression: start=2005-001 operation=in_range end=2006-001 (id:location-D5-rule-expr) \n Resource: D6\n Constraint: location-D6\n Rule: score=INFINITY (id:location-D6-rule) \n Expression: (id:location-D6-rule-expr) \n Date Spec: years=2005 (id:location-D6-rule-expr-datespec) \nOrdering Constraints:\nColocation Constraints:\n", )
def setupClusterA(self, temp_cib): line = "resource create D1 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D2 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D3 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D4 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D5 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource create D6 Dummy" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource clone D3" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == "" line = "resource master Master D4" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 and output == ""
def testAddBadResources(self): line = "resource create bad_resource idontexist test=bad" output, returnVal = pcs(temp_cib, line) assert returnVal == 1 assert output == "Error: Unable to create resource 'idontexist', it is not installed on this system (use --force to override)\n",[output] line = "resource create bad_resource2 idontexist2 test4=bad3 --force" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource show --all" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == " Resource: bad_resource2 (class=ocf provider=heartbeat type=idontexist2)\n Attributes: test4=bad3 \n Operations: monitor interval=60s (bad_resource2-monitor-interval-60s)\n",[output]
def testBadProperties(self): o,r = pcs("property set xxxx=zzzz") assert r==1 ac(o,"Error: unknown cluster property: 'xxxx', (use --force to override)\n") output, returnVal = pcs("property set =5678 --force") ac(output, "Error: property name cannot be empty\n") assert returnVal == 1 o,r = pcs("property unset zzzzz") assert r==1 ac(o,"Error: can't remove property: 'zzzzz' that doesn't exist\n") o,r = pcs("property unset zzzz --force") assert r==0 ac(o,"")
def testIPV6(self): o,r = pcs("cluster setup --force --local --corosync_conf=corosync.conf.tmp --name cnam rh7-1 rh7-2 --ipv6") ac(o,"") assert r == 0 with open("corosync.conf.tmp") as f: data = f.read() ac(data,'totem {\nversion: 2\nsecauth: off\ncluster_name: cnam\ntransport: udpu\nip_version: ipv6\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n')
def testBadProperties(self): o,r = pcs("property set xxxx=zzzz") assert r==1 ac(o,"Error: unknown cluster property: 'xxxx', (use --force to override)\n") output, returnVal = pcs("property set 1234=5678 --force") ac(output, "Error: invalid property name '1234', '1' is not a valid first character for a property name\n") assert returnVal == 1 o,r = pcs("property unset zzzzz") assert r==1 ac(o,"Error: can't remove property: 'zzzzz' that doesn't exist\n") o,r = pcs("property unset zzzz --force") assert r==0 ac(o,"")
def testTotemOptions(self): o,r = pcs("cluster setup --force --local --corosync_conf=corosync.conf.tmp --name test99 rh7-1 rh7-2 --token 20000 --join 20001 --consensus 20002 --miss_count_const 20003 --fail_recv_const 20004") ac(o,"") assert r == 0 with open("corosync.conf.tmp") as f: data = f.read() ac(data,'totem {\nversion: 2\nsecauth: off\ncluster_name: test99\ntransport: udpu\ntoken: 20000\njoin: 20001\nconsensus: 20002\nmiss_count_const: 20003\nfail_recv_const: 20004\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n')
def testLocationConstraints(self): output, returnVal = pcs(temp_cib, "constraint location D5 prefers node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint location D5 avoids node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint location D5 prefers node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint location D5 avoids node2") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint location add location-D5-node1-INFINITY ") assert returnVal == 1 assert output.startswith("\nUsage: pcs constraint"), output
def testCaseInsensitive(self): o,r = pcs(temp_cib, "resource create D1 dummy") assert r == 0 ac(o,'') o,r = pcs(temp_cib, "resource create D2 DUMMY") assert r == 0 ac(o,'') o,r = pcs(temp_cib, "resource create D3 ipaddr2") assert r == 0 ac(o,'') o,r = pcs(temp_cib, "resource create D4 ipaddr3") assert r == 1 ac(o,"Error: Unable to create resource 'ipaddr3', it is not installed on this system (use --force to override)\n")
def testAllConstraints(self): output, returnVal = pcs(temp_cib, "constraint location D5 prefers node1") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint order D4 then D5") assert returnVal == 0 and output == "Adding D4 D5 (kind: Mandatory) (Options: first-action=start then-action=start)\n", output output, returnVal = pcs(temp_cib, "constraint colocation add D4 with D5") assert returnVal == 0 and output == "", output output, returnVal = pcs(temp_cib, "constraint --all") assert returnVal == 0 and output == "Location Constraints:\n Resource: D5\n Enabled on: node1 (score:INFINITY) (id:location-D5-node1-INFINITY)\nOrdering Constraints:\n start D4 then start D5 (Mandatory) (id:order-D4-D5-mandatory)\nColocation Constraints:\n D4 with D5 (INFINITY) (id:colocation-D4-D5-INFINITY)\n", output output, returnVal = pcs(temp_cib, "constraint show --all") assert returnVal == 0 and output == "Location Constraints:\n Resource: D5\n Enabled on: node1 (score:INFINITY) (id:location-D5-node1-INFINITY)\nOrdering Constraints:\n start D4 then start D5 (Mandatory) (id:order-D4-D5-mandatory)\nColocation Constraints:\n D4 with D5 (INFINITY) (id:colocation-D4-D5-INFINITY)\n", output
def testClusterConfig(self): self.setupClusterA(temp_cib) output, returnVal = pcs(temp_cib, "config") assert returnVal == 0 assert output == 'Cluster Name: test99\nCorosync Nodes:\n rh7-1 rh7-2 \nPacemaker Nodes:\n \n\nResources: \n Resource: ClusterIP6 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP6-monitor-interval-30s)\n Group: TestGroup1\n Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP-monitor-interval-30s)\n Group: TestGroup2\n Resource: ClusterIP2 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP2-monitor-interval-30s)\n Resource: ClusterIP3 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP3-monitor-interval-30s)\n Clone: ClusterIP4-clone\n Resource: ClusterIP4 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP4-monitor-interval-30s)\n Master: Master\n Resource: ClusterIP5 (class=ocf provider=heartbeat type=IPaddr2)\n Attributes: ip=192.168.0.99 cidr_netmask=32 \n Operations: monitor interval=30s (ClusterIP5-monitor-interval-30s)\n\nStonith Devices: \nFencing Levels: \n\nLocation Constraints:\nOrdering Constraints:\nColocation Constraints:\n\nCluster Properties:\n', [ output ]
def setupClusterA(self, temp_cib): line = "resource create ClusterIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource create ClusterIP2 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource create ClusterIP3 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource create ClusterIP4 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource create ClusterIP5 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource create ClusterIP6 ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=32 op monitor interval=30s" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource group add TestGroup1 ClusterIP" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource group add TestGroup2 ClusterIP2 ClusterIP3" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource clone ClusterIP4" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource master Master ClusterIP5" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == ""
def testMSGroup(self): output, returnVal = pcs(temp_cib, "resource create D0 Dummy") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource create D1 Dummy") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource group add Group D0 D1") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource master GroupMaster Group") assert returnVal == 0 assert output == "", [output] output, returnVal = pcs(temp_cib, "resource --all") assert returnVal == 0 assert output == ' Master: GroupMaster\n Group: Group\n Resource: D0 (class=ocf provider=heartbeat type=Dummy)\n Operations: monitor interval=60s (D0-monitor-interval-60s)\n Resource: D1 (class=ocf provider=heartbeat type=Dummy)\n Operations: monitor interval=60s (D1-monitor-interval-60s)\n', [ output ] output, returnVal = pcs(temp_cib, "resource delete D0") assert returnVal == 0 assert output == "Deleting Resource - D0\n", [output] output, returnVal = pcs(temp_cib, "resource delete D1") assert returnVal == 0 assert output == 'Deleting Resource (and group and M/S) - D1\n', [ output ]
def testAddBadResources(self): line = "resource create bad_resource idontexist test=bad" output, returnVal = pcs(temp_cib, line) assert returnVal == 1 assert output == "Error: Unable to create resource 'idontexist', it is not installed on this system (use --force to override)\n", [ output ] line = "resource create bad_resource2 idontexist2 test4=bad3 --force" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == "" line = "resource show --all" output, returnVal = pcs(temp_cib, line) assert returnVal == 0 assert output == " Resource: bad_resource2 (class=ocf provider=heartbeat type=idontexist2)\n Attributes: test4=bad3 \n Operations: monitor interval=60s (bad_resource2-monitor-interval-60s)\n", [ output ]
def testDescribe(self): output, returnVal = pcs(temp_cib, "resource describe bad_resource") assert returnVal == 1 assert output == "Error: Unable to find resource: bad_resource\n" output, returnVal = pcs(temp_cib, "resource describe ocf:heartbeat:Dummy") assert returnVal == 0 ac( output, "Resource options for: ocf:heartbeat:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\n" ) output, returnVal = pcs(temp_cib, "resource describe Dummy") assert returnVal == 0 ac( output, "Resource options for: ocf:heartbeat:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\nResource options for: ocf:pacemaker:Dummy\n state: Location to store the resource state in.\n fake: Fake attribute that can be changed to cause a reload\n op_sleep: Number of seconds to sleep during operations. This can be used to\n test how the cluster reacts to operation timeouts.\n" )
def testCaseInsensitive(self): o, r = pcs(temp_cib, "resource create D1 dummy") assert r == 0 ac(o, '') o, r = pcs(temp_cib, "resource create D2 DUMMY") assert r == 0 ac(o, '') o, r = pcs(temp_cib, "resource create D3 ipaddr2") assert r == 0 ac(o, '') o, r = pcs(temp_cib, "resource create D4 ipaddr3") assert r == 1 ac( o, "Error: Unable to create resource 'ipaddr3', it is not installed on this system (use --force to override)\n" )
def testIPV6(self): if utils.is_rhel6(): print "WARNING: not testing IPV6 due to RHEL6" return o,r = pcs("cluster setup --force --local --corosync_conf=corosync.conf.tmp --name cnam rh7-1 rh7-2 --ipv6") ac(o,"") assert r == 0 with open("corosync.conf.tmp") as f: data = f.read() ac(data,'totem {\nversion: 2\nsecauth: off\ncluster_name: cnam\ntransport: udpu\nip_version: ipv6\n}\n\nnodelist {\n node {\n ring0_addr: rh7-1\n nodeid: 1\n }\n node {\n ring0_addr: rh7-2\n nodeid: 2\n }\n}\n\nquorum {\nprovider: corosync_votequorum\ntwo_node: 1\n}\n\nlogging {\nto_syslog: yes\n}\n')
def testBadProperties(self): o, r = pcs("property set xxxx=zzzz") assert r == 1 ac( o, "Error: unknown cluster property: 'xxxx', (use --force to override)\n" ) output, returnVal = pcs("property set =5678 --force") ac(output, "Error: property name cannot be empty\n") assert returnVal == 1 o, r = pcs("property unset zzzzz") assert r == 1 ac(o, "Error: can't remove property: 'zzzzz' that doesn't exist\n") o, r = pcs("property unset zzzz --force") assert r == 0 ac(o, "")
def testManyConstraints(self): shutil.copy(large_cib, temp_large_cib) output, returnVal = pcs(temp_large_cib, "constraint location dummy prefers rh7-1") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint location show resources dummy --full") ac(output, "Location Constraints:\n Resource: dummy\n Enabled on: rh7-1 (score:INFINITY) (id:location-dummy-rh7-1-INFINITY)\n") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint location remove location-dummy-rh7-1-INFINITY") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint colocation add dummy1 with dummy2") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint colocation remove dummy1 dummy2") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint order dummy1 then dummy2") ac(output, "Adding dummy1 dummy2 (kind: Mandatory) (Options: first-action=start then-action=start)\n") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint order remove dummy1") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint location dummy prefers rh7-1") ac(output, "") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint location show resources dummy --full") ac(output, "Location Constraints:\n Resource: dummy\n Enabled on: rh7-1 (score:INFINITY) (id:location-dummy-rh7-1-INFINITY)\n") assert returnVal == 0 output, returnVal = pcs(temp_large_cib, "constraint remove location-dummy-rh7-1-INFINITY") ac(output, "") assert returnVal == 0