progress_controller_test.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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/highAvailability_controller');
  20. require('models/host_component');
  21. require('models/host');
  22. require('utils/ajax/ajax');
  23. describe('App.HighAvailabilityProgressPageController', function () {
  24. var controller = App.HighAvailabilityProgressPageController.create();
  25. describe('#reconfigureSites()', function () {
  26. var tests = [
  27. {
  28. content: {
  29. controllerName: "rMHighAvailabilityWizardController"
  30. },
  31. siteNames: ["site1", "site2"],
  32. data: {
  33. items: [
  34. {
  35. type: "site1",
  36. properties: {
  37. site1_property1: "site1_property1_value",
  38. site1_property2: "site1_property2_value"
  39. },
  40. properties_attributes: {
  41. final: {
  42. site1_property1: "true"
  43. }
  44. }
  45. },
  46. {
  47. type: "site2",
  48. properties: {
  49. site2_property1: "site2_property1_value",
  50. site2_property2: "site2_property2_value"
  51. }
  52. },
  53. {
  54. type: "site3",
  55. properties: {
  56. site3_property: "site3_property_value"
  57. }
  58. }
  59. ]
  60. },
  61. result: [
  62. {
  63. type: "site1",
  64. tag: "version1",
  65. properties: {
  66. site1_property1: "site1_property1_value",
  67. site1_property2: "site1_property2_value"
  68. },
  69. service_config_version_note: Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format("ResourceManager"),
  70. properties_attributes: {
  71. final: {
  72. site1_property1: "true"
  73. }
  74. }
  75. },
  76. {
  77. type: "site2",
  78. tag: "version1",
  79. properties: {
  80. site2_property1: "site2_property1_value",
  81. site2_property2: "site2_property2_value"
  82. },
  83. service_config_version_note: Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format("ResourceManager")
  84. }
  85. ]
  86. },
  87. {
  88. content: {
  89. controllerName: "anyOther"
  90. },
  91. siteNames: ["site1"],
  92. data: {
  93. items: [
  94. {
  95. type: "site1",
  96. properties: {
  97. site1_property1: "site1_property1_value",
  98. site1_property2: "site1_property2_value"
  99. },
  100. properties_attributes: {
  101. final: {
  102. site1_property1: "true"
  103. }
  104. }
  105. }
  106. ]
  107. },
  108. result: [
  109. {
  110. type: "site1",
  111. tag: "version1",
  112. properties: {
  113. site1_property1: "site1_property1_value",
  114. site1_property2: "site1_property2_value"
  115. },
  116. service_config_version_note: Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format("NameNode"),
  117. properties_attributes: {
  118. final: {
  119. site1_property1: "true"
  120. }
  121. }
  122. }
  123. ]
  124. }];
  125. beforeEach(function() {
  126. App.set('testMode', true);
  127. });
  128. afterEach(function() {
  129. App.set('testMode', false);
  130. });
  131. it("reconfigures configs after HA", function() {
  132. tests.forEach(function(t) {
  133. controller.set('content', t.content);
  134. expect(controller.reconfigureSites(t.siteNames, t.data)).to.eql(t.result);
  135. });
  136. });
  137. });
  138. });