cluster-metric-test.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. import { moduleForModel, test } from 'ember-qunit';
  19. moduleForModel('cluster-metric', 'Unit | Model | cluster metric', {
  20. needs: []
  21. });
  22. test('Basic creation test', function(assert) {
  23. let model = this.subject();
  24. assert.ok(model);
  25. assert.ok(model.appsSubmitted);
  26. assert.ok(model.appsCompleted);
  27. assert.ok(model.appsPending);
  28. assert.ok(model.appsRunning);
  29. assert.ok(model.appsFailed);
  30. assert.ok(model.appsKilled);
  31. assert.ok(model.reservedMB);
  32. assert.ok(model.availableMB);
  33. assert.ok(model.allocatedMB);
  34. assert.ok(model.reservedVirtualCores);
  35. assert.ok(model.availableVirtualCores);
  36. assert.ok(model.allocatedVirtualCores);
  37. assert.ok(model.containersAllocated);
  38. assert.ok(model.containersReserved);
  39. assert.ok(model.containersPending);
  40. assert.ok(model.totalMB);
  41. assert.ok(model.totalVirtualCores);
  42. assert.ok(model.totalNodes);
  43. assert.ok(model.lostNodes);
  44. assert.ok(model.unhealthyNodes);
  45. assert.ok(model.decommissionedNodes);
  46. assert.ok(model.rebootedNodes);
  47. assert.ok(model.activeNodes);
  48. });
  49. test('Testing fields', function(assert) {
  50. let model = this.subject({
  51. "appsCompleted": 0,
  52. "appsPending": 0,
  53. "appsRunning": 0,
  54. "appsFailed": 0,
  55. "appsKilled": 0,
  56. "reservedMB": 0,
  57. "availableMB": 32768,
  58. "allocatedMB": 0,
  59. "activeNodes": 4,
  60. "unhealthyNodes": 0,
  61. "decommissionedNodes": 0,
  62. "reservedVirtualCores": 0,
  63. "availableVirtualCores": 32,
  64. "allocatedVirtualCores": 0
  65. });
  66. assert.deepEqual(model.get('getFinishedAppsDataForDonutChart'),
  67. [{label: "Completed", value: 0}, {label: "Killed", value: 0}, {label: "Failed", value: 0}]);
  68. assert.deepEqual(model.get('getRunningAppsDataForDonutChart'),
  69. [{label: "Pending", value: 0}, {label: "Running", value: 0}]);
  70. assert.deepEqual(model.get('getNodesDataForDonutChart'),
  71. [{label: "Active", value: 4}, {label: "Unhealthy", value: 0}, {label: "Decommissioned", value: 0}]);
  72. assert.deepEqual(model.get('getMemoryDataForDonutChart'),
  73. [{label: "Allocated", value: 0}, {label: "Reserved", value: 0}, {label: "Available", value: 32768}]);
  74. assert.deepEqual(model.get('getVCoreDataForDonutChart'),
  75. [{label: "Allocated", value: 0}, {label: "Reserved", value: 0}, {label: "Available", value: 32}]);
  76. });