step4_test.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 Ember = require('ember');
  19. var App = require('app');
  20. require('controllers/wizard/step4_controller');
  21. describe('App.WizardStep4Controller', function () {
  22. var services = [
  23. 'HDFS', 'MAPREDUCE', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER', 'HCATALOG', 'WEBHCAT', 'YARN', 'MAPREDUCE2'
  24. ];
  25. var controller = App.WizardStep4Controller.create();
  26. services.forEach(function(serviceName, index){
  27. controller.pushObject(Ember.Object.create({
  28. 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': index == 0
  29. }));
  30. });
  31. describe('#isSubmitDisabled', function () {
  32. it('should return false if at least one selected service is not installed', function () {
  33. expect(controller.get('isSubmitDisabled')).to.equal(false);
  34. });
  35. it('should return true if all selected services are already installed', function () {
  36. controller.setEach('isInstalled', true);
  37. controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
  38. expect(controller.get('isSubmitDisabled')).to.equal(true);
  39. });
  40. });
  41. describe('#isAll', function () {
  42. it('should return true if all services are selected', function () {
  43. controller.findProperty('serviceName', 'HDFS').set('isSelected', true);
  44. expect(controller.get('isAll')).to.equal(true);
  45. });
  46. it('should return false if at least one service is not selected', function () {
  47. controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
  48. expect(controller.get('isAll')).to.equal(false);
  49. });
  50. });
  51. describe('#isMinimum', function () {
  52. it('should return true if there are no services selected, except disabled', function () {
  53. controller.setEach('isSelected', false);
  54. expect(controller.get('isMinimum')).to.equal(true);
  55. });
  56. it('should return false if at least one service is selected, except disabled', function () {
  57. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  58. expect(controller.get('isMinimum')).to.equal(false);
  59. });
  60. });
  61. describe('#checkDependencies()', function () {
  62. /*it('should set ZooKeeper isSelected property like in HBase', function () {
  63. controller.setEach('isSelected', false);
  64. controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
  65. controller.checkDependencies();
  66. expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
  67. });*/
  68. it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
  69. controller.setEach('isSelected', false);
  70. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  71. controller.checkDependencies();
  72. expect(controller.findProperty('serviceName', 'HCATALOG').get('isSelected')).to.equal(true);
  73. expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true);
  74. });
  75. it('should set MapReduce2 isSelected property like in Yarn', function () {
  76. App.set('currentStackVersion', 'HDP-2.0.1');
  77. App.set('defaultStackVersion', 'HDP-2.0.1');
  78. controller.setEach('isSelected', false);
  79. controller.findProperty('serviceName', 'YARN').set('isSelected', true);
  80. controller.checkDependencies();
  81. expect(controller.findProperty('serviceName', 'MAPREDUCE2').get('isSelected')).to.equal(true);
  82. App.set('currentStackVersion', 'HDP-1.2.2');
  83. App.set('defaultStackVersion', 'HDP-1.2.2');
  84. });
  85. });
  86. describe('#selectAll()', function () {
  87. it('should select all services', function () {
  88. controller.setEach('isSelected', false);
  89. controller.selectAll();
  90. expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
  91. });
  92. });
  93. describe('#selectMinimum()', function () {
  94. it('should set isSelected false for all not disabled services', function () {
  95. controller.setEach('isSelected', true);
  96. controller.selectMinimum();
  97. expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
  98. expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
  99. });
  100. });
  101. describe('#needToAddMapReduce()', function () {
  102. it('should return true if Pig is selected and MapReduce is not selected', function () {
  103. controller.setEach('isSelected', false);
  104. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  105. expect(controller.needToAddMapReduce()).to.equal(true);
  106. });
  107. it('should return true if Oozie is selected and MapReduce is not selected', function () {
  108. controller.setEach('isSelected', false);
  109. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  110. expect(controller.needToAddMapReduce()).to.equal(true);
  111. });
  112. it('should return true if Hive is selected and MapReduce is not selected', function () {
  113. controller.setEach('isSelected', false);
  114. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  115. expect(controller.needToAddMapReduce()).to.equal(true);
  116. });
  117. it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
  118. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  119. expect(controller.needToAddMapReduce()).to.equal(false);
  120. controller.setEach('isSelected', false);
  121. expect(controller.needToAddMapReduce()).to.equal(false);
  122. });
  123. });
  124. describe('#needToAddYarnMapReduce2()', function () {
  125. it('should return true if Pig is selected and YARN+MapReduce2 is not selected', function () {
  126. controller.setEach('isSelected', false);
  127. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  128. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  129. });
  130. it('should return true if Oozie is selected and YARN+MapReduce2 is not selected', function () {
  131. controller.setEach('isSelected', false);
  132. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  133. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  134. });
  135. it('should return true if Hive is selected and YARN+MapReduce2 is not selected', function () {
  136. controller.setEach('isSelected', false);
  137. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  138. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  139. });
  140. it('should return false if YARN+MapReduce2 is selected or Pig, Oozie and Hive are not selected', function () {
  141. controller.findProperty('serviceName', 'YARN').set('isSelected', true);
  142. expect(controller.needToAddYarnMapReduce2()).to.equal(false);
  143. controller.setEach('isSelected', false);
  144. expect(controller.needToAddYarnMapReduce2()).to.equal(false);
  145. });
  146. });
  147. describe('#needToAddZooKeeper()', function () {
  148. it('should return false if ZOOKEEPER is selected or HBASE is not selected', function () {
  149. controller.findProperty('serviceName', 'ZOOKEEPER').set('isSelected', true);
  150. expect(controller.needToAddZooKeeper()).to.equal(false);
  151. controller.setEach('isSelected', false);
  152. expect(controller.needToAddZooKeeper()).to.equal(false);
  153. });
  154. });
  155. describe('#gangliaOrNagiosNotSelected()', function () {
  156. it('should return true if Nagios or Ganglia is not selected', function () {
  157. controller.setEach('isSelected', true);
  158. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
  159. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  160. controller.setEach('isSelected', true);
  161. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
  162. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  163. });
  164. it('should return false if Nagios and Ganglia is selected', function () {
  165. controller.setEach('isSelected', false);
  166. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
  167. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
  168. expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
  169. });
  170. });
  171. });