step4_test.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. var ajax_send;
  62. describe('#checkDependencies()', function () {
  63. beforeEach(function() {
  64. ajax_send = App.ajax.send;
  65. App.ajax.send = function() {};
  66. });
  67. afterEach(function() {
  68. App.ajax.send = ajax_send;
  69. });
  70. it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
  71. controller.setEach('isSelected', false);
  72. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  73. controller.checkDependencies();
  74. expect(controller.findProperty('serviceName', 'HCATALOG').get('isSelected')).to.equal(true);
  75. expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true);
  76. });
  77. it('should set MapReduce2 isSelected property like in Yarn', function () {
  78. App.set('currentStackVersion', 'HDP-2.0.1');
  79. App.set('defaultStackVersion', 'HDP-2.0.1');
  80. controller.setEach('isSelected', false);
  81. controller.findProperty('serviceName', 'YARN').set('isSelected', true);
  82. controller.checkDependencies();
  83. expect(controller.findProperty('serviceName', 'MAPREDUCE2').get('isSelected')).to.equal(true);
  84. App.set('currentStackVersion', 'HDP-1.2.2');
  85. App.set('defaultStackVersion', 'HDP-1.2.2');
  86. });
  87. });
  88. describe('#selectAll()', function () {
  89. it('should select all services', function () {
  90. controller.setEach('isSelected', false);
  91. controller.selectAll();
  92. expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
  93. });
  94. });
  95. describe('#selectMinimum()', function () {
  96. it('should set isSelected false for all not disabled services', function () {
  97. controller.setEach('isSelected', true);
  98. controller.selectMinimum();
  99. expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
  100. expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
  101. });
  102. });
  103. describe('#needToAddMapReduce()', function () {
  104. it('should return true if Pig is selected and MapReduce is not selected', function () {
  105. controller.setEach('isSelected', false);
  106. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  107. expect(controller.needToAddMapReduce()).to.equal(true);
  108. });
  109. it('should return true if Oozie is selected and MapReduce is not selected', function () {
  110. controller.setEach('isSelected', false);
  111. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  112. expect(controller.needToAddMapReduce()).to.equal(true);
  113. });
  114. it('should return true if Hive is selected and MapReduce is not selected', function () {
  115. controller.setEach('isSelected', false);
  116. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  117. expect(controller.needToAddMapReduce()).to.equal(true);
  118. });
  119. it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
  120. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  121. expect(controller.needToAddMapReduce()).to.equal(false);
  122. controller.setEach('isSelected', false);
  123. expect(controller.needToAddMapReduce()).to.equal(false);
  124. });
  125. });
  126. describe('#needToAddYarnMapReduce2()', function () {
  127. it('should return true if Pig is selected and YARN+MapReduce2 is not selected', function () {
  128. controller.setEach('isSelected', false);
  129. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  130. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  131. });
  132. it('should return true if Oozie is selected and YARN+MapReduce2 is not selected', function () {
  133. controller.setEach('isSelected', false);
  134. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  135. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  136. });
  137. it('should return true if Hive is selected and YARN+MapReduce2 is not selected', function () {
  138. controller.setEach('isSelected', false);
  139. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  140. expect(controller.needToAddYarnMapReduce2()).to.equal(true);
  141. });
  142. it('should return false if YARN+MapReduce2 is selected or Pig, Oozie and Hive are not selected', function () {
  143. controller.findProperty('serviceName', 'YARN').set('isSelected', true);
  144. expect(controller.needToAddYarnMapReduce2()).to.equal(false);
  145. controller.setEach('isSelected', false);
  146. expect(controller.needToAddYarnMapReduce2()).to.equal(false);
  147. });
  148. });
  149. describe('#needToAddZooKeeper()', function () {
  150. it('should return false if ZOOKEEPER is selected or HBASE is not selected', function () {
  151. controller.findProperty('serviceName', 'ZOOKEEPER').set('isSelected', true);
  152. expect(controller.needToAddZooKeeper()).to.equal(false);
  153. controller.setEach('isSelected', false);
  154. expect(controller.needToAddZooKeeper()).to.equal(false);
  155. });
  156. });
  157. describe('#gangliaOrNagiosNotSelected()', function () {
  158. it('should return true if Nagios or Ganglia is not selected', function () {
  159. controller.setEach('isSelected', true);
  160. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
  161. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  162. controller.setEach('isSelected', true);
  163. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
  164. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  165. });
  166. it('should return false if Nagios and Ganglia is selected', function () {
  167. controller.setEach('isSelected', false);
  168. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
  169. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
  170. expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
  171. });
  172. });
  173. });