stack_service_component_test.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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('#displayName', function () {
  118. components.forEach(function (item) {
  119. var displayName = App.format.components[item.name];
  120. it('should be ' + displayName, function () {
  121. stackServiceComponent.set('componentName', item.name);
  122. expect(stackServiceComponent.get('displayName')).to.equal(displayName);
  123. });
  124. });
  125. });
  126. describe('#isSlave', function () {
  127. it('should be true', function () {
  128. stackServiceComponent.set('componentCategory', 'SLAVE');
  129. expect(stackServiceComponent.get('isSlave')).to.be.true;
  130. });
  131. it('should be false', function () {
  132. stackServiceComponent.set('componentCategory', 'cc');
  133. expect(stackServiceComponent.get('isSlave')).to.be.false;
  134. });
  135. });
  136. describe('#isRestartable', function () {
  137. it('should be true', function () {
  138. stackServiceComponent.set('isClient', false);
  139. expect(stackServiceComponent.get('isRestartable')).to.be.true;
  140. });
  141. it('should be false', function () {
  142. stackServiceComponent.set('isClient', true);
  143. expect(stackServiceComponent.get('isRestartable')).to.be.false;
  144. });
  145. });
  146. describe('#isReassignable', function () {
  147. reassignable.forEach(function (item) {
  148. it('should be true', function () {
  149. stackServiceComponent.set('componentName', item);
  150. expect(stackServiceComponent.get('isReassignable')).to.be.true;
  151. });
  152. });
  153. it('should be false', function () {
  154. stackServiceComponent.set('componentName', 'name');
  155. expect(stackServiceComponent.get('isReassignable')).to.be.false;
  156. });
  157. });
  158. describe('#isDeletable', function () {
  159. deletable.forEach(function (item) {
  160. it('should be true', function () {
  161. stackServiceComponent.set('componentName', item);
  162. expect(stackServiceComponent.get('isDeletable')).to.be.true;
  163. });
  164. });
  165. it('should be false', function () {
  166. stackServiceComponent.set('componentName', 'name');
  167. expect(stackServiceComponent.get('isDeletable')).to.be.false;
  168. });
  169. });
  170. describe('#isRollinRestartAllowed', function () {
  171. rollingRestartable.forEach(function (item) {
  172. it('should be true', function () {
  173. stackServiceComponent.set('componentName', item);
  174. expect(stackServiceComponent.get('isRollinRestartAllowed')).to.be.true;
  175. });
  176. });
  177. it('should be false', function () {
  178. stackServiceComponent.set('componentName', 'name');
  179. expect(stackServiceComponent.get('isRollinRestartAllowed')).to.be.false;
  180. });
  181. });
  182. describe('#isDecommissionAllowed', function () {
  183. decommissionable.forEach(function (item) {
  184. it('should be true', function () {
  185. stackServiceComponent.set('componentName', item);
  186. expect(stackServiceComponent.get('isDecommissionAllowed')).to.be.true;
  187. });
  188. });
  189. it('should be false', function () {
  190. stackServiceComponent.set('componentName', 'name');
  191. expect(stackServiceComponent.get('isDecommissionAllowed')).to.be.false;
  192. });
  193. });
  194. describe('#isRefreshConfigsAllowed', function () {
  195. refreshable.forEach(function (item) {
  196. it('should be true', function () {
  197. stackServiceComponent.set('componentName', item);
  198. expect(stackServiceComponent.get('isRefreshConfigsAllowed')).to.be.true;
  199. });
  200. });
  201. it('should be false', function () {
  202. stackServiceComponent.set('componentName', 'name');
  203. expect(stackServiceComponent.get('isRefreshConfigsAllowed')).to.be.false;
  204. });
  205. });
  206. describe('#isAddableToHost', function () {
  207. addable.forEach(function (item) {
  208. it('should be true', function () {
  209. stackServiceComponent.set('componentName', item);
  210. expect(stackServiceComponent.get('isAddableToHost')).to.be.true;
  211. });
  212. });
  213. it('should be false', function () {
  214. stackServiceComponent.set('componentName', 'name');
  215. expect(stackServiceComponent.get('isAddableToHost')).to.be.false;
  216. });
  217. });
  218. describe('#isShownOnInstallerAssignMasterPage', function () {
  219. mastersNotShown.forEach(function (item) {
  220. it('should be false', function () {
  221. stackServiceComponent.set('componentName', item);
  222. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.false;
  223. });
  224. });
  225. it('should be true', function () {
  226. stackServiceComponent.set('componentName', 'APP_TIMELINE_SERVER');
  227. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.true;
  228. });
  229. it('should be true', function () {
  230. stackServiceComponent.setProperties({
  231. componentName: 'name',
  232. isMaster: true
  233. });
  234. expect(stackServiceComponent.get('isShownOnInstallerAssignMasterPage')).to.be.true;
  235. });
  236. });
  237. });