rolling_restart_view_test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. restartHostComponents: new Array(10),
  35. result: {
  36. batchSize: 1,
  37. tolerateSize: 1
  38. }
  39. },
  40. {
  41. restartHostComponents: new Array(11),
  42. result: {
  43. batchSize: 2,
  44. tolerateSize: 2
  45. }
  46. },
  47. {
  48. restartHostComponents: new Array(20),
  49. result: {
  50. batchSize: 2,
  51. tolerateSize: 2
  52. }
  53. }
  54. ];
  55. testCases.forEach(function (test) {
  56. it(test.restartHostComponents.length + ' components to restart', function () {
  57. view.set('batchSize', -1);
  58. view.set('interBatchWaitTimeSeconds', -1);
  59. view.set('tolerateSize', -1);
  60. view.set('restartHostComponents', test.restartHostComponents);
  61. view.initialize();
  62. expect(view.get('batchSize')).to.equal(test.result.batchSize);
  63. expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize);
  64. })
  65. }, this);
  66. });
  67. });