Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

450 lines
15 KiB

  1. Option Explicit
  2. '***********************************************************************
  3. '
  4. ' ClusResGroups and related tests
  5. '
  6. '***********************************************************************
  7. '
  8. 'Following are marks for lines to be included in translated script version of test
  9. StartTest
  10. '----------------------------------------------------------------------
  11. Sub StartTest()
  12. On Error Resume Next
  13. Dim oLogView
  14. 'Set oLogView = CreateObject("Atl1.LogView")
  15. 'oLogView.logFileName = "d:\nt\private\cluster\admin\msclus\vbscript\vbResGroups.log"
  16. 'oLogView.logFileName = "d:\\projects\\msclust\\vb\\jsResGroups.log"
  17. ResGroupsTest oLogView
  18. End Sub
  19. '-----------------------------------------------------------------------
  20. Sub ResGroupsTest(oLogView)
  21. On Error Resume Next
  22. Dim oCluster
  23. Dim collResGroups
  24. 'oLogView.AddResult1 1, "Creating object MSCluster.Cluster"
  25. 'JS_TRY<
  26. Set oCluster = CreateObject("MSCluster.Cluster")
  27. 'JS_CATCH>
  28. If Err.Number <> 0 Then
  29. 'oLogView.AddResult1 2, "Cluster creation failed:" & Err.Description
  30. Exit Sub
  31. Else
  32. 'oLogView.AddResult1 8, "Instance of Cluster created"
  33. End If
  34. 'JS_TRY<
  35. oCluster.Open ("GALENB-CLUS")
  36. 'JS_CATCH>
  37. If Err.Number <> 0 Then
  38. 'oLogView.AddResult1 2, "Cluster open failed:" & Err.Description
  39. Exit Sub
  40. Else
  41. 'oLogView.AddResult1 8, "Cluster IGORPCLUS opened successfuly"
  42. End If
  43. 'JS_TRY<
  44. Set collResGroups = oCluster.ResourceGroups
  45. 'JS_CATCH>
  46. If Err.Number <> 0 Then
  47. 'oLogView.AddResult1 2, "Cluster:ResGroups failed:" & Err.Description
  48. Exit Sub
  49. Else
  50. 'oLogView.AddResult1 8, "Cluster:ResGroups retrieved"
  51. End If
  52. RunResGroupsTests oLogView, collResGroups
  53. End Sub
  54. '-----------------------------------------------------------------------
  55. Sub RunResGroupsTests(oLogView, collResGroups)
  56. On Error Resume Next
  57. Dim count
  58. Dim oResGroup
  59. 'JS_TRY<
  60. count = collResGroups.count
  61. 'JS_CATCH>
  62. If Err.Number <> 0 Then
  63. 'oLogView.AddResult1 2, "ClusResGroups:Count failed:" & Err.Description
  64. Exit Sub
  65. Else
  66. 'oLogView.AddResult1 8, "ClusResGroups:Count: " & count
  67. End If
  68. 'test collection's Refresh
  69. TestRefresh oLogView, collResGroups
  70. '---------- Create new group
  71. 'JS_TRY<
  72. Set oResGroup = collResGroups.CreateItem("8TestGroup")
  73. 'JS_CATCH>
  74. If Err.Number <> 0 Then
  75. 'oLogView.AddResult1 2, "ClusResGroups:CreateItem(8TestGroup) failed:" & Err.Description
  76. Exit Sub 'nothing to test
  77. Else
  78. 'oLogView.AddResult1 8, "ClusResGroups:CreateItem(8TestGroup) succeeded"
  79. TestResGroup oLogView, oResGroup
  80. TestPreferredOwners oLogView, oResGroup
  81. 'JS_TRY<
  82. collResGroups.DeleteItem ("8TestGroup")
  83. 'JS_CATCH>
  84. If Err.Number <> 0 Then
  85. 'oLogView.AddResult1 2, "ClusResGroups:DeleteItem(8TestGroup) failed:" & Err.Description
  86. Err.Clear 'clean exit
  87. Else
  88. 'oLogView.AddResult1 8, "ClusResGroups:DeleteItem(8TestGroup) succeeded"
  89. End If
  90. End If
  91. End Sub
  92. '-----------------------------------------------------------------------
  93. Sub TestResGroup(oLogView, oResGroup)
  94. On Error Resume Next
  95. ' all common stuff is tested in common test
  96. Dim state
  97. Dim oCluster
  98. Dim groupName
  99. '----------- test renaming
  100. 'oLogView.AddResult1 1, "Testing ClusResGroup.Name member"
  101. 'JS_TRY
  102. groupName = oResGroup.Name
  103. 'JS_CATCH
  104. If Err.Number <> 0 Then
  105. 'oLogView.AddResult1 2, "Get ClusResGroup.Name failed:" & Err.Description
  106. Err.Clear
  107. Else
  108. 'oLogView.AddResult1 8, "ClusResGroup.Name: " & groupName
  109. 'JS_TRY
  110. oResGroup.Name = "8TestAnotherName"
  111. 'JS_CATCH
  112. If Err.Number <> 0 Then
  113. 'oLogView.AddResult1 2, "Renaming ClusResGroup.Name failed:" & Err.Description
  114. Err.Clear
  115. Else
  116. 'oLogView.AddResult1 8, "New ClusResGroup.Name: " & oResGroup.Name
  117. 'JS_TRY
  118. oResGroup.Name = groupName
  119. 'JS_CATCH
  120. If Err.Number <> 0 Then
  121. 'oLogView.AddResult1 2, "Renaming to original name failed:" & Err.Description
  122. Err.Clear
  123. Else
  124. 'oLogView.AddResult1 8, "Original ClusResGroup.Name restored: " & groupName
  125. End If
  126. End If
  127. End If
  128. '----------- state
  129. 'JS_TRY<
  130. state = oResGroup.state
  131. 'JS_CATCH>
  132. If Err.Number <> 0 Then
  133. 'oLogView.AddResult1 2, "ClusResGroup.State failed:" & Err.Description
  134. Err.Clear
  135. Else
  136. 'oLogView.AddResult1 8, "ClusResGroup.State: " & state
  137. 'should be offline - freshly created
  138. If state = 1 Then 'ClusterGroupOffline
  139. TestGroupResources oLogView, oResGroup
  140. Else
  141. 'oLogView.AddResult1 3, "Created group " & oResGroup.Name & " not in expected offline state. Current state: " & state
  142. End If 'no offline
  143. End If
  144. End Sub
  145. '-----------------------------------------------------------------------
  146. Sub TestGroupResources(oLogView, oResGroup)
  147. On Error Resume Next
  148. Dim collResources
  149. Dim oResource
  150. Dim lCount
  151. Dim oOwnerNode
  152. Dim state
  153. Dim oAnotherOwner 'this time as VARIANT
  154. 'JS_TRY<
  155. Set collResources = oResGroup.Resources
  156. lCount = collResources.count
  157. 'JS_CATCH>
  158. If Err.Number <> 0 Then
  159. 'oLogView.AddResult1 2, "Get ClusResGroup.Resources failed:" & Err.Description
  160. Exit Sub
  161. Else
  162. 'oLogView.AddResult1 8, "Get ClusResGroup.Resources succeeded. Number of resources: " & lCount
  163. 'add item
  164. 'JS_TRY<
  165. Set oResource = collResources.CreateItem("8TestResource", "Generic Application", 0)
  166. collResources.Refresh
  167. 'JS_CATCH>
  168. If Err.Number <> 0 Then
  169. 'oLogView.AddResult1 2, "ClusResGroupResource.CreateItem failed:" & Err.Description
  170. Err.Clear
  171. Else
  172. 'oLogView.AddResult1 8, "ClusResGroupResource.CreateItem( Generic application) succeeded"
  173. End If
  174. If collResources.count <> 1 Then
  175. 'oLogView.AddResult1 2, "ClusResGroup.Resources.CreateItem: added resource not in collection"
  176. Else
  177. 'oLogView.AddResult1 8, "ClusResGroup.Resources.CreateItem: count = 1"
  178. End If
  179. 'JS_TRY<
  180. collResources.DeleteItem ("8TestResource")
  181. collResources.Refresh
  182. 'JS_CATCH>
  183. If Err.Number <> 0 Then
  184. 'oLogView.AddResult1 2, "ClusResGroup.Resources.DeleteItem failed: " & Err.Description
  185. Err.Clear
  186. Else
  187. 'oLogView.AddResult1 8, "ClusResGroup.Resources.DeleteItem succeeded"
  188. End If
  189. If collResources.count <> 0 Then
  190. 'oLogView.AddResult1 2, "ClusResGroup.Resources.DeleteItem: refresh after DeleteItem failure"
  191. Else
  192. 'oLogView.AddResult1 8, "ClusResGroup.Resources.DeleteItem Refresh count = 0"
  193. End If
  194. '------------ online
  195. 'JS_TRY<
  196. MsgBox "Online"
  197. oResGroup.Online( 10000 )
  198. 'JS_CATCH>
  199. If Err.Number <> 0 Then
  200. MsgBox "Online Error " & Err.Description
  201. 'oLogView.AddResult1 2, "ClusResGroup.Online failed: " & Err.Description
  202. Err.Clear
  203. Else
  204. MsgBox "Online succeeded"
  205. 'oLogView.AddResult1 8, "ClusResGroup.Online succeeded"
  206. End If
  207. '------------ offline
  208. 'JS_TRY<
  209. oResGroup.Offline 10000
  210. 'JS_CATCH>
  211. If Err.Number <> 0 Then
  212. 'oLogView.AddResult1 2, "ClusResGroup.Offline failed: " & Err.Description
  213. Err.Clear
  214. Else
  215. 'oLogView.AddResult1 8, "ClusResGroup.Offline succeeded"
  216. End If
  217. '------------- OwnerNode
  218. 'JS_TRY<
  219. Set oOwnerNode = oResGroup.OwnerNode
  220. 'JS_CATCH>
  221. If Err.Number <> 0 Then
  222. 'oLogView.AddResult1 2, "ClusResGroup.OwnerNode failed: " & Err.Description
  223. Err.Clear
  224. Else
  225. 'oLogView.AddResult1 8, "ClusResGroup.OwnerNode succeeded"
  226. End If
  227. '------------- move
  228. 'JS_TRY<
  229. oResGroup.Move 10000
  230. 'JS_CATCH>
  231. If Err.Number <> 0 Then
  232. 'oLogView.AddResult1 2, "ClusResGroup.Move failed: " & Err.Description
  233. Err.Clear
  234. Else
  235. 'oLogView.AddResult1 8, "ClusResGroup.Move succeeded"
  236. Set oAnotherOwner = oResGroup.OwnerNode
  237. If oAnotherOwner.Name <> oOwnerNode.Name Then
  238. 'oLogView.AddResult1 8, "New owner of test group: " & oAnotherOwner.Name
  239. Else
  240. 'oLogView.AddResult1 2, "New owner of test group after Move is the same as original: " & oAnotherOwner.Name
  241. End If
  242. End If
  243. 'move back
  244. 'JS_TRY<
  245. oResGroup.Move 10000, oOwnerNode
  246. 'JS_CATCH>
  247. If Err.Number <> 0 Then
  248. 'oLogView.AddResult1 2, "ClusResGroup.Move to original node failed: " & Err.Description
  249. Err.Clear
  250. Else
  251. 'oLogView.AddResult1 8, "ClusResGroup.Move to original node succeeded"
  252. Set oAnotherOwner = oResGroup.OwnerNode
  253. If oAnotherOwner.Name = oOwnerNode.Name Then
  254. 'oLogView.AddResult1 8, "New owner of test group is original node " & oAnotherOwner.Name
  255. Else
  256. 'oLogView.AddResult1 2, "New owner of test group after Move differs original: " & oAnotherOwner.Name
  257. End If
  258. End If
  259. Set oAnotherOwner = Nothing
  260. 'move it again and bring online on original node
  261. 'JS_TRY<
  262. oResGroup.Move 10000
  263. oResGroup.Online 10000, oOwnerNode
  264. 'JS_CATCH>
  265. If Err.Number <> 0 Then
  266. 'oLogView.AddResult1 2, "ClusResGroup.Move/Online failed: " & Err.Description
  267. Err.Clear
  268. Else
  269. 'oLogView.AddResult1 8, "ClusResGroup.Move/Online succeeded"
  270. 'check that node is online on expected node
  271. state = oResGroup.state
  272. If state <> 0 Then 'ClusterGroupOnline
  273. 'oLogView.AddResult1 2, "State after ClusResGroup.Move/Online differs from expected online: " & state
  274. Else
  275. 'oLogView.AddResult1 8, "State after ClusResGroup.Move/Online as expected: online"
  276. End If
  277. Set oAnotherOwner = oResGroup.OwnerNode
  278. If oAnotherOwner.Name = oOwnerNode.Name Then
  279. 'oLogView.AddResult1 8, "New owner of test group is original node " & oAnotherOwner.Name
  280. Else
  281. 'oLogView.AddResult1 2, "New owner of test group after Move differs original: " & oAnotherOwner.Name
  282. End If
  283. End If
  284. oResGroup.Offline 10000
  285. End If
  286. End Sub
  287. '-----------------------------------------------------------------------
  288. Sub TestPreferredOwners(oLogView, oResGroup)
  289. On Error Resume Next
  290. Dim collPreferredOwnerNodes
  291. Dim lCount
  292. Dim oClusNode 'try this as VARIANT
  293. 'JS_TRY<
  294. Set collPreferredOwnerNodes = oResGroup.PreferredOwnerNodes
  295. 'JS_CATCH>
  296. If Err.Number <> 0 Then
  297. 'oLogView.AddResult1 2, "Get ClusResGroup.PreferredOwnerNodes failed: " & Err.Description
  298. Exit Sub
  299. Else
  300. TestRefresh oLogView, collPreferredOwnerNodes
  301. 'JS_TRY<
  302. 'check number of preferred owners in collection
  303. lCount = collPreferredOwnerNodes.count
  304. 'JS_CATCH>
  305. If Err.Number <> 0 Then
  306. 'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.Count failed: " & Err.Description
  307. Exit Sub
  308. Else
  309. 'add node to the group
  310. 'JS_TRY<
  311. Set oClusNode = oResGroup.OwnerNode
  312. collPreferredOwnerNodes.InsertItem oClusNode
  313. 'JS_CATCH>
  314. If Err.Number <> 0 Then
  315. 'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.InsertItem failed: " & Err.Description
  316. Err.Clear
  317. Else
  318. 'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.InsertItem succeeded"
  319. 'check that Modified flag is set
  320. If collPreferredOwnerNodes.Modified <> 0 Then 'we expect true here
  321. 'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify set after InsertItem"
  322. Else
  323. 'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify NOT set after InsertItem"
  324. End If
  325. collPreferredOwnerNodes.Refresh
  326. If collPreferredOwnerNodes.Modified <> 0 Then 'we expect false here
  327. 'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify set after Refresh after InsertItem"
  328. Else
  329. 'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify not set after Refresh after InsertItem"
  330. End If
  331. 'check number of items in collection
  332. If collPreferredOwnerNodes.count = 1 Then
  333. 'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.count is 1"
  334. Else
  335. 'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.count is NOT 1: " & collPreferredOwnerNodes.count
  336. End If
  337. '--------- now remove item from collection
  338. 'JS_TRY<
  339. collPreferredOwnerNodes.RemoveItem oClusNode.Name
  340. 'JS_CATCH>
  341. If Err.Number <> 0 Then
  342. 'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.RemoveItem failed: " & Err.Description
  343. Err.Clear
  344. Else
  345. 'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.RemoveItem succeeded"
  346. 'check that Modified flag is set
  347. If collPreferredOwnerNodes.Modified <> 0 Then 'we expect true here
  348. 'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify set after RemoveItem"
  349. Else
  350. 'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify NOT set after RemoveItem"
  351. End If
  352. collPreferredOwnerNodes.Refresh
  353. If collPreferredOwnerNodes.Modified <> 0 Then 'we expect false here
  354. 'oLogView.AddResult1 3, "Flag ClusResGroupPreferredOwnerNodes.Modify set after Refresh after RemoveItem"
  355. Else
  356. 'oLogView.AddResult1 8, "Flag ClusResGroupPreferredOwnerNodes.Modify not set after Refresh after RemoveItem"
  357. End If
  358. 'check number of items in collection
  359. If collPreferredOwnerNodes.count = 0 Then
  360. 'oLogView.AddResult1 8, "ClusResGroupPreferredOwnerNodes.count is 0"
  361. Else
  362. 'oLogView.AddResult1 2, "ClusResGroupPreferredOwnerNodes.count is NOT 0"
  363. End If
  364. End If
  365. End If
  366. End If
  367. End If
  368. End Sub
  369. '-----------------------------------------------------------------------
  370. '-----------------------------------------------------------------------
  371. Sub TestRefresh(oLogObject, colCollection)
  372. On Error Resume Next
  373. Dim origCount
  374. Dim afterCount
  375. 'JS_TRY<
  376. origCount = colCollection.count
  377. colCollection.Refresh
  378. afterCount = colCollection.count
  379. 'JS_CATCH>
  380. If Err.Number <> 0 Then
  381. 'oLogObject.AddResult1 2, "Refresh failed with error:" & Err.Description
  382. Else
  383. If origCount <> afterCount Then 'counts are not equal
  384. 'oLogObject.AddResult1 2, "Count changes after Refresh:" & origCount & " differs from " & afterCount
  385. Else
  386. 'oLogObject.AddResult1 8, "Refresh succeeded"
  387. End If
  388. End If
  389. End Sub
  390. '----------------------- End of file -----------------------------------
  391. '*****************************************************************************
  392. '*
  393. '* Translated by VB2script translator on Thu Feb 18 17:31:58 1999
  394. '* from file resgroups.bas
  395. '*
  396. '*****************************************************************************