rolling_restart_view_test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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('views/common/rolling_restart_view');
  20. describe('App.RollingRestartView', function () {
  21. var view = App.RollingRestartView.create({
  22. restartHostComponents: []
  23. });
  24. describe('#initialize', function () {
  25. var testCases = [
  26. {
  27. restartHostComponents: [],
  28. result: {
  29. batchSize: 1,
  30. tolerateSize: 1
  31. }
  32. },
  33. {
  34. hostComponentName: 'NOT_DATANODE',
  35. restartHostComponents: new Array(10),
  36. result: {
  37. batchSize: 1,
  38. tolerateSize: 1
  39. }
  40. },
  41. {
  42. hostComponentName: 'NOT_DATANODE',
  43. restartHostComponents: new Array(11),
  44. result: {
  45. batchSize: 2,
  46. tolerateSize: 2
  47. }
  48. },
  49. {
  50. hostComponentName: 'NOT_DATANODE',
  51. restartHostComponents: new Array(20),
  52. result: {
  53. batchSize: 2,
  54. tolerateSize: 2
  55. }
  56. },
  57. {
  58. hostComponentName: 'DATANODE',
  59. restartHostComponents: new Array(20),
  60. result: {
  61. batchSize: 1,
  62. tolerateSize: 1
  63. }
  64. }
  65. ];
  66. testCases.forEach(function (test) {
  67. describe(test.restartHostComponents.length + ' components to restart', function () {
  68. beforeEach(function () {
  69. view.set('batchSize', -1);
  70. view.set('interBatchWaitTimeSeconds', -1);
  71. view.set('tolerateSize', -1);
  72. view.set('hostComponentName', test.hostComponentName);
  73. view.set('restartHostComponents', test.restartHostComponents);
  74. view.initialize();
  75. });
  76. it('batchSize is ' + test.result.batchSize, function() {
  77. expect(view.get('batchSize')).to.equal(test.result.batchSize);
  78. });
  79. it('tolerateSize is ' + test.result.tolerateSize, function() {
  80. expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize);
  81. });
  82. })
  83. }, this);
  84. });
  85. });