step6_test.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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/installer/step6_controller');
  21. describe('App.InstallerStep6Controller', function () {
  22. var HOSTS = [ 'host1', 'host2', 'host3', 'host4' ];
  23. //App.InstallerStep6Controller.set.rawHosts = HOSTS;
  24. var controller = App.InstallerStep6Controller.create();
  25. controller.set('showHbase', false);
  26. HOSTS.forEach(function (_hostName) {
  27. controller.get('hosts').pushObject(Ember.Object.create({
  28. hostname: _hostName,
  29. isDataNode: true,
  30. isTaskTracker: true,
  31. isRegionServer: true
  32. }));
  33. });
  34. describe('#selectAllDataNodes()', function () {
  35. controller.get('hosts').setEach('isDataNode', false);
  36. it('should set isDataNode to true on all hosts', function () {
  37. controller.selectAllDataNodes();
  38. expect(controller.get('hosts').everyProperty('isDataNode', true)).to.equal(true);
  39. })
  40. })
  41. describe('#selectAllTaskTrackers()', function () {
  42. it('should set isTaskTracker to true on all hosts', function () {
  43. controller.selectAllTaskTrackers();
  44. expect(controller.get('hosts').everyProperty('isTaskTracker', true)).to.equal(true);
  45. })
  46. })
  47. describe('#selectAllRegionServers()', function () {
  48. it('should set isRegionServer to true on all hosts', function () {
  49. controller.selectAllRegionServers();
  50. expect(controller.get('hosts').everyProperty('isRegionServer', true)).to.equal(true);
  51. })
  52. })
  53. describe('#isAllDataNodes()', function () {
  54. beforeEach(function () {
  55. controller.get('hosts').setEach('isDataNode', true);
  56. })
  57. it('should return true if isDataNode is true for all services', function () {
  58. expect(controller.get('isAllDataNodes')).to.equal(true);
  59. })
  60. it('should return false if isDataNode is false for one host', function () {
  61. controller.get('hosts')[0].set('isDataNode', false);
  62. expect(controller.get('isAllDataNodes')).to.equal(false);
  63. })
  64. })
  65. describe('#isAllTaskTrackers()', function () {
  66. beforeEach(function () {
  67. controller.get('hosts').setEach('isTaskTracker', true);
  68. })
  69. it('should return true if isTaskTracker is true for all hosts', function () {
  70. expect(controller.get('isAllTaskTrackers')).to.equal(true);
  71. })
  72. it('should return false if isTaskTracker is false for one host', function () {
  73. controller.get('hosts')[0].set('isTaskTracker', false);
  74. expect(controller.get('isAllTaskTrackers')).to.equal(false);
  75. })
  76. })
  77. describe('#isAllRegionServers()', function () {
  78. beforeEach(function () {
  79. controller.get('hosts').setEach('isRegionServer', true);
  80. });
  81. it('should return true if isRegionServer is true for all hosts', function () {
  82. expect(controller.get('isAllRegionServers')).to.equal(true);
  83. })
  84. it('should return false if isRegionServer is false for one host', function () {
  85. controller.get('hosts')[0].set('isRegionServer', false);
  86. expect(controller.get('isAllRegionServers')).to.equal(false);
  87. })
  88. })
  89. describe('#validate()', function () {
  90. beforeEach(function () {
  91. controller.get('hosts').setEach('isDataNode', true);
  92. controller.get('hosts').setEach('isTaskTracker', true);
  93. controller.get('hosts').setEach('isRegionServer', true);
  94. });
  95. it('should return false if isDataNode is false for all hosts', function () {
  96. controller.get('hosts').setEach('isDataNode', false);
  97. expect(controller.validate()).to.equal(false);
  98. })
  99. it('should return false if isTaskTracker is false for all hosts', function () {
  100. controller.get('hosts').setEach('isTaskTracker', false);
  101. expect(controller.validate()).to.equal(false);
  102. })
  103. it('should return false if isRegionServer is false for all hosts', function () {
  104. controller.get('hosts').setEach('isRegionServer', false);
  105. expect(controller.validate()).to.equal(false);
  106. })
  107. it('should return true if isDataNode, isTaskTracker, and isRegionServer is true for all hosts', function () {
  108. expect(controller.validate()).to.equal(true);
  109. })
  110. it('should return true if isDataNode, isTaskTracker, and isRegionServer is true for only one host', function () {
  111. controller.get('hosts').setEach('isDataNode', false);
  112. controller.get('hosts').setEach('isTaskTracker', false);
  113. controller.get('hosts').setEach('isRegionServer', false);
  114. var host = controller.get('hosts')[0];
  115. host.set('isDataNode', true);
  116. host.set('isTaskTracker', true);
  117. host.set('isRegionServer', true);
  118. expect(controller.validate()).to.equal(true);
  119. })
  120. })
  121. })