step4_test.js 4.7 KB

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