step4_test.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. require('controllers/installer/step4_controller');
  20. describe('App.InstallerStep4Controller', function () {
  21. var DEFAULT_SERVICES = ['HDFS'];
  22. var OPTIONAL_SERVICES = ['MAPREDUCE', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SQOOP', 'ZOOKEEPER', 'HCATALOG'];
  23. var controller = App.InstallerStep4Controller.create();
  24. describe('#selectMinimum()', function () {
  25. it('should set isSelected is false on all non-default services and isSelected is true on all default services', function() {
  26. controller.selectMinimum();
  27. DEFAULT_SERVICES.forEach(function (serviceName) {
  28. expect(controller.findProperty('serviceName', serviceName).get('isSelected')).to.equal(true);
  29. });
  30. OPTIONAL_SERVICES.forEach(function (serviceName) {
  31. expect(controller.findProperty('serviceName', serviceName).get('isSelected')).to.equal(false);
  32. });
  33. })
  34. })
  35. describe('#selectAll()', function () {
  36. it('should set isSelected is true on all non-default services and isSelected is true on all default services', function() {
  37. controller.selectAll();
  38. DEFAULT_SERVICES.forEach(function (serviceName) {
  39. expect(controller.findProperty('serviceName', serviceName).get('isSelected')).to.equal(true);
  40. });
  41. OPTIONAL_SERVICES.forEach(function (serviceName) {
  42. expect(controller.findProperty('serviceName', serviceName).get('isSelected')).to.equal(true);
  43. });
  44. })
  45. })
  46. describe('#isAll()', function () {
  47. beforeEach(function() {
  48. DEFAULT_SERVICES.forEach(function(serviceName) {
  49. controller.findProperty('serviceName', serviceName).set('isSelected', true);
  50. });
  51. OPTIONAL_SERVICES.forEach(function(serviceName) {
  52. controller.findProperty('serviceName', serviceName).set('isSelected', true);
  53. });
  54. });
  55. it('should return true if isSelected is true for all services', function() {
  56. expect(controller.get('isAll')).to.equal(true);
  57. })
  58. it('should return false if isSelected is false for one of the services', function() {
  59. controller.findProperty('serviceName', 'HBASE').set('isSelected', false);
  60. expect(controller.get('isAll')).to.equal(false);
  61. })
  62. })
  63. describe('#isMinimum()', function () {
  64. beforeEach(function() {
  65. DEFAULT_SERVICES.forEach(function(serviceName) {
  66. controller.findProperty('serviceName', serviceName).set('isSelected', true);
  67. });
  68. OPTIONAL_SERVICES.forEach(function(serviceName) {
  69. controller.findProperty('serviceName', serviceName).set('isSelected', false);
  70. });
  71. });
  72. it('should return true if isSelected is true for all default services and isSelected is false for all optional services', function() {
  73. expect(controller.get('isMinimum')).to.equal(true);
  74. })
  75. it('should return false if isSelected is true for all default serices and isSelected is true for one of optional services', function() {
  76. controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
  77. expect(controller.get('isMinimum')).to.equal(false);
  78. })
  79. })
  80. describe('#needToAddMapReduce', function() {
  81. describe('mapreduce not selected', function() {
  82. beforeEach(function() {
  83. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', false);
  84. })
  85. it('should return true if Hive is selected and MapReduce is not selected', function() {
  86. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  87. expect(controller.needToAddMapReduce()).to.equal(true);
  88. })
  89. it('should return true if Pig is selected and MapReduce is not selected', function() {
  90. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  91. expect(controller.needToAddMapReduce()).to.equal(true);
  92. })
  93. it('should return true if Oozie is selected and MapReduce is not selected', function() {
  94. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  95. expect(controller.needToAddMapReduce()).to.equal(true);
  96. })
  97. })
  98. describe('mapreduce not selected', function() {
  99. beforeEach(function() {
  100. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  101. })
  102. it('should return false if Hive is selected and MapReduce is selected', function() {
  103. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  104. expect(controller.needToAddMapReduce()).to.equal(false);
  105. })
  106. it('should return false if Pig is selected and MapReduce is not selected', function() {
  107. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  108. expect(controller.needToAddMapReduce()).to.equal(false);
  109. })
  110. it('should return false if Oozie is selected and MapReduce is not selected', function() {
  111. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  112. expect(controller.needToAddMapReduce()).to.equal(false);
  113. })
  114. })
  115. })
  116. describe('#saveSelectedServiceNamesToDB', function() {
  117. beforeEach(function() {
  118. DEFAULT_SERVICES.forEach(function(serviceName) {
  119. controller.findProperty('serviceName', serviceName).set('isSelected', true);
  120. });
  121. OPTIONAL_SERVICES.forEach(function(serviceName) {
  122. controller.findProperty('serviceName', serviceName).set('isSelected', true);
  123. });
  124. });
  125. it('should store the selected service names in App.db.selectedServiceNames', function() {
  126. App.db.setLoginName('tester');
  127. App.db.setClusterName('test');
  128. controller.saveSelectedServiceNamesToDB();
  129. // console.log('controller length=' + controller.get('length'));
  130. var selectedServiceNames = App.db.getSelectedServiceNames();
  131. // console.log('service length=' + selectedServiceNames.get('length'));
  132. expect(selectedServiceNames.length === DEFAULT_SERVICES.length + OPTIONAL_SERVICES.length).to.equal(true);
  133. })
  134. })
  135. })