stack_service_component_test.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var modelSetup = require('test/init_model_test');
  20. require('models/stack_service_component');
  21. var stackServiceComponent,
  22. stackServiceComponentData = {
  23. id: 'ssc'
  24. },
  25. components = [
  26. {
  27. name: 'NAMENODE',
  28. isReassignable: true
  29. },
  30. {
  31. name: 'SECONDARY_NAMENODE',
  32. isReassignable: true
  33. },
  34. {
  35. name: 'JOBTRACKER',
  36. isReassignable: true
  37. },
  38. {
  39. name: 'RESOURCEMANAGER',
  40. isReassignable: true
  41. },
  42. {
  43. name: 'SUPERVISOR',
  44. isDeletable: true,
  45. isRollinRestartAllowed: true,
  46. isAddableToHost: true
  47. },
  48. {
  49. name: 'HBASE_MASTER',
  50. isDeletable: true,
  51. isAddableToHost: true
  52. },
  53. {
  54. name: 'DATANODE',
  55. isDeletable: true,
  56. isRollinRestartAllowed: true,
  57. isDecommissionAllowed: true,
  58. isAddableToHost: true
  59. },
  60. {
  61. name: 'TASKTRACKER',
  62. isDeletable: true,
  63. isRollinRestartAllowed: true,
  64. isDecommissionAllowed: true,
  65. isAddableToHost: true
  66. },
  67. {
  68. name: 'NODEMANAGER',
  69. isDeletable: true,
  70. isRollinRestartAllowed: true,
  71. isDecommissionAllowed: true,
  72. isAddableToHost: true
  73. },
  74. {
  75. name: 'HBASE_REGIONSERVER',
  76. isDeletable: true,
  77. isRollinRestartAllowed: true,
  78. isDecommissionAllowed: true,
  79. isAddableToHost: true
  80. },
  81. {
  82. name: 'GANGLIA_MONITOR',
  83. isDeletable: true,
  84. isAddableToHost: true
  85. },
  86. {
  87. name: 'FLUME_HANDLER',
  88. isRefreshConfigsAllowed: true
  89. },
  90. {
  91. name: 'ZOOKEEPER_SERVER',
  92. isAddableToHost: true
  93. },
  94. {
  95. name: 'MYSQL_SERVER',
  96. mastersNotShown: true
  97. },
  98. {
  99. name: 'JOURNALNODE',
  100. mastersNotShown: true
  101. }
  102. ],
  103. reassignable = components.filterProperty('isReassignable').mapProperty('name'),
  104. deletable = components.filterProperty('isDeletable').mapProperty('name'),
  105. rollingRestartable = components.filterProperty('isRollinRestartAllowed').mapProperty('name'),
  106. decommissionable = components.filterProperty('isDecommissionAllowed').mapProperty('name'),
  107. refreshable = components.filterProperty('isRefreshConfigsAllowed').mapProperty('name'),
  108. addable = components.filterProperty('isAddableToHost').mapProperty('name'),
  109. mastersNotShown = components.filterProperty('mastersNotShown').mapProperty('name');
  110. describe('App.StackServiceComponent', function () {
  111. beforeEach(function () {
  112. stackServiceComponent = App.StackServiceComponent.createRecord(stackServiceComponentData);
  113. });
  114. afterEach(function () {
  115. modelSetup.deleteRecord(stackServiceComponent);
  116. });
  117. describe('#isSlave', function () {
  118. it('should be true', function () {
  119. stackServiceComponent.set('componentCategory', 'SLAVE');
  120. expect(stackServiceComponent.get('isSlave')).to.be.true;
  121. });
  122. it('should be false', function () {
  123. stackServiceComponent.set('componentCategory', 'cc');
  124. expect(stackServiceComponent.get('isSlave')).to.be.false;
  125. });
  126. });
  127. describe('#isRestartable', function () {
  128. it('should be true', function () {
  129. stackServiceComponent.set('isClient', false);
  130. expect(stackServiceComponent.get('isRestartable')).to.be.true;
  131. });
  132. it('should be false', function () {
  133. stackServiceComponent.set('isClient', true);
  134. expect(stackServiceComponent.get('isRestartable')).to.be.false;
  135. });
  136. });
  137. describe('#isReassignable', function () {
  138. reassignable.forEach(function (item) {
  139. it('should be true', function () {
  140. stackServiceComponent.set('componentName', item);
  141. expect(stackServiceComponent.get('isReassignable')).to.be.true;
  142. });
  143. });
  144. it('should be false', function () {
  145. stackServiceComponent.set('componentName', 'name');
  146. expect(stackServiceComponent.get('isReassignable')).to.be.false;
  147. });
  148. });
  149. describe('#isDeletable', function () {
  150. deletable.forEach(function (item) {
  151. it('should be true', function () {
  152. stackServiceComponent.set('componentName', item);
  153. expect(stackServiceComponent.get('isDeletable')).to.be.true;
  154. });
  155. });
  156. it('should be false', function () {
  157. stackServiceComponent.set('componentName', 'name');
  158. expect(stackServiceComponent.get('isDeletable')).to.be.false;
  159. });
  160. });
  161. describe('#isRollinRestartAllowed', function () {
  162. rollingRestartable.forEach(function (item) {
  163. it('should be true', function () {
  164. stackServiceComponent.set('componentName', item);
  165. expect(stackServiceComponent.get('isRollinRestartAllowed')).to.be.true;
  166. });
  167. });
  168. it('should be false', function () {
  169. stackServiceComponent.set('componentName', 'name');
  170. expect(stackServiceComponent.get('isRollinRestartAllowed')).to.be.false;
  171. });
  172. });
  173. describe('#isDecommissionAllowed', function () {
  174. decommissionable.forEach(function (item) {
  175. it('should be true', function () {
  176. stackServiceComponent.set('componentName', item);
  177. expect(stackServiceComponent.get('isDecommissionAllowed')).to.be.true;
  178. });
  179. });
  180. it('should be false', function () {
  181. stackServiceComponent.set('componentName', 'name');
  182. expect(stackServiceComponent.get('isDecommissionAllowed')).to.be.false;
  183. });
  184. });
  185. describe('#isRefreshConfigsAllowed', function () {
  186. refreshable.forEach(function (item) {
  187. it('should be true', function () {
  188. stackServiceComponent.set('componentName', item);
  189. expect(stackServiceComponent.get('isRefreshConfigsAllowed')).to.be.true;
  190. });
  191. });
  192. it('should be false', function () {
  193. stackServiceComponent.set('componentName', 'name');
  194. expect(stackServiceComponent.get('isRefreshConfigsAllowed')).to.be.false;
  195. });
  196. });
  197. describe('#isAddableToHost', function () {
  198. addable.forEach(function (item) {
  199. it('should be true', function () {
  200. stackServiceComponent.set('componentName', item);
  201. expect(stackServiceComponent.get('isAddableToHost')).to.be.true;
  202. });
  203. });
  204. it('should be false', function () {
  205. stackServiceComponent.set('componentName', 'name');
  206. expect(stackServiceComponent.get('isAddableToHost')).to.be.false;
  207. });
  208. });
  209. describe('#isShownOnInstallerAssignMasterPage', function () {
  210. mastersNotShown.forEach(function (item) {
  211. it('should be false', function () {
  212. stackServiceComponent.set('componentName', item);
  213. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.false;
  214. });
  215. });
  216. it('should be true', function () {
  217. stackServiceComponent.set('componentName', 'APP_TIMELINE_SERVER');
  218. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.true;
  219. });
  220. it('should be true', function () {
  221. stackServiceComponent.setProperties({
  222. componentName: 'name',
  223. isMaster: true
  224. });
  225. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.true;
  226. });
  227. });
  228. });