step9_test.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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('models/hosts');
  21. require('controllers/installer/step9_controller');
  22. describe('App.InstallerStep9Controller', function () {
  23. //var controller = App.InstallerStep3Controller.create();
  24. describe('#isStepFailed', function () {
  25. var controller = App.InstallerStep9Controller.create();
  26. it('should return true if even a single action of a role with 100% success factor fails', function () {
  27. var polledData = new Ember.Set([
  28. {
  29. actionId: '1',
  30. name: '192.168.1.1',
  31. status: 'completed',
  32. sf: '100',
  33. role: 'DataNode',
  34. message: 'completed 30%'
  35. },
  36. {
  37. actionId: '2',
  38. name: '192.168.1.2',
  39. status: 'completed',
  40. sf: '100',
  41. role: 'DataNode',
  42. message: 'completed 20%'
  43. },
  44. {
  45. actionId: '3',
  46. name: '192.168.1.3',
  47. status: 'completed',
  48. sf: '100',
  49. role: 'DataNode',
  50. message: 'completed 30%'
  51. },
  52. {
  53. actionId: '4',
  54. name: '192.168.1.4',
  55. status: 'failed',
  56. sf: '100',
  57. role: 'DataNode',
  58. message: 'completed 40%'
  59. }
  60. ]);
  61. expect(controller.isStepFailed(polledData)).to.equal(true);
  62. })
  63. it('should return false if action of a role fails but with less percentage than success factor of the role', function () {
  64. var polledData = new Ember.Set([
  65. {
  66. actionId: '1',
  67. name: '192.168.1.1',
  68. status: 'failed',
  69. sf: '30',
  70. role: 'DataNode',
  71. message: 'completed 30%'
  72. },
  73. {
  74. actionId: '2',
  75. name: '192.168.1.2',
  76. status: 'failed',
  77. sf: '30',
  78. role: 'DataNode',
  79. message: 'completed 20%'
  80. },
  81. {
  82. actionId: '3',
  83. name: '192.168.1.3',
  84. status: 'completed',
  85. sf: '30',
  86. role: 'DataNode',
  87. message: 'completed 30%'
  88. },
  89. {
  90. actionId: '4',
  91. name: '192.168.1.4',
  92. status: 'completed',
  93. sf: '30',
  94. role: 'DataNode',
  95. message: 'completed 40%'
  96. }
  97. ]);
  98. expect(controller.isStepFailed(polledData)).to.equal(false);
  99. })
  100. })
  101. describe('#setHostsStatus', function () {
  102. var controller = App.InstallerStep9Controller.create();
  103. it('sets the status of all hosts in the content to the passed status value', function () {
  104. var mockData = new Ember.Set(
  105. {
  106. actionId: '1',
  107. name: '192.168.1.1',
  108. status: 'completed',
  109. sf: '100',
  110. role: 'DataNode',
  111. message: 'completed 30%'
  112. },
  113. {
  114. actionId: '2',
  115. name: '192.168.1.2',
  116. status: 'completed',
  117. sf: '100',
  118. role: 'DataNode',
  119. message: 'completed 20%'
  120. },
  121. {
  122. actionId: '3',
  123. name: '192.168.1.3',
  124. status: 'completed',
  125. sf: '100',
  126. role: 'DataNode',
  127. message: 'completed 30%'
  128. },
  129. {
  130. actionId: '4',
  131. name: '192.168.1.4',
  132. status: 'completed',
  133. sf: '100',
  134. role: 'DataNode',
  135. message: 'completed 40%'
  136. }
  137. );
  138. mockData.forEach(function(_polledData){
  139. controller.content.pushObject(_polledData);
  140. });
  141. controller.setHostsStatus(mockData,'finish');
  142. var result = controller.content.everyProperty('status','finish');
  143. //console.log('value of pop is: '+ result.pop.actionId);
  144. expect(result).to.equal(true);
  145. })
  146. })
  147. })