step4_test.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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/main/admin/security/security_progress_controller');
  20. require('controllers/main/admin/security/add/step4');
  21. require('utils/polling');
  22. require('models/cluster_states');
  23. describe('App.MainAdminSecurityAddStep4Controller', function () {
  24. /**
  25. * Test object
  26. */
  27. var controller = App.MainAdminSecurityAddStep4Controller.create();
  28. describe('#moveToNextCommand()', function () {
  29. controller.reopen({
  30. saveCommands: function(){},
  31. enableSubmit: function(){},
  32. loadClusterConfigs: function(){}
  33. });
  34. App.clusterStatus.reopen({
  35. setClusterStatus: function(){}
  36. });
  37. controller.set('commands', [
  38. App.Poll.create({name: 'STOP_SERVICES', isStarted: false, isPolling: true, isCompleted: false, start: function(){}}),
  39. App.Poll.create({name: 'APPLY_CONFIGURATIONS', isStarted: false, isPolling: false, isCompleted: false, start: function(){}}),
  40. App.Poll.create({name: 'START_SERVICES', isStarted: false, isPolling: true, isCompleted: false, start: function(){}})
  41. ]);
  42. it('STOP_SERVICES is started', function(){
  43. controller.moveToNextCommand(controller.get('commands').findProperty('name', 'STOP_SERVICES'));
  44. expect(controller.get('commands').findProperty('name', 'STOP_SERVICES').get('isStarted')).to.equal(true);
  45. });
  46. it('APPLY_CONFIGURATIONS is started', function(){
  47. controller.moveToNextCommand(controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS'));
  48. expect(controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS').get('isStarted')).to.equal(true);
  49. });
  50. it('START_SERVICES is started', function(){
  51. controller.moveToNextCommand(controller.get('commands').findProperty('name', 'START_SERVICES'));
  52. expect(controller.get('commands').findProperty('name', 'START_SERVICES').get('isStarted')).to.equal(true);
  53. });
  54. });
  55. describe('#loadCommands()', function() {
  56. describe('YARN installed with ATS', function() {
  57. beforeEach(function(){
  58. controller.reopen({
  59. secureServices: function() {
  60. return [
  61. Em.Object.create({
  62. serviceName: 'YARN'
  63. })
  64. ];
  65. }.property()
  66. });
  67. controller.set('commands', []);
  68. controller.set('totalSteps', 3);
  69. var service = {
  70. id: 'YARN',
  71. service_name: 'YARN',
  72. host_components: ['APP_TIMLINE_SERVER_c6401.ambari.apache.org']
  73. };
  74. var hostComponent = {
  75. component_name: 'APP_TIMELINE_SERVER',
  76. id: 'APP_TIMLINE_SERVER_c6401.ambari.apache.org',
  77. service_id: 'YARN'
  78. };
  79. App.store.load(App.HostComponent, hostComponent);
  80. App.store.load(App.Service, service);
  81. controller.loadCommands();
  82. });
  83. it('delete ATS component stage should be after APPLY_CONFIGURATIONS', function() {
  84. expect(controller.get('commands').indexOf(controller.get('commands').findProperty('name','DELETE_ATS'))).to.eql(2);
  85. });
  86. it('commands length should be equal to 4', function() {
  87. expect(controller.get('commands').length).to.eql(4);
  88. });
  89. it('total steps should be equal to 4', function() {
  90. expect(controller.get('totalSteps')).to.eql(4);
  91. });
  92. });
  93. describe('YARN installed without ATS', function() {
  94. beforeEach(function(){
  95. controller.reopen({
  96. secureServices: function() {
  97. return [
  98. Em.Object.create({
  99. serviceName: 'YARN'
  100. })
  101. ];
  102. }.property()
  103. });
  104. controller.set('commands', []);
  105. controller.set('totalSteps', 3);
  106. var service = {
  107. id: 'YARN',
  108. service_name: 'YARN',
  109. host_components: []
  110. };
  111. App.store.load(App.Service, service);
  112. controller.loadCommands();
  113. });
  114. it('commands length should be equal to 3', function() {
  115. expect(controller.get('commands').length).to.eql(3);
  116. });
  117. it('total steps should be equal to 3', function() {
  118. expect(controller.get('totalSteps')).to.eql(3);
  119. });
  120. });
  121. });
  122. });