yarn-nodes-test.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 { moduleFor, test } from 'ember-qunit';
  19. import Ember from 'ember';
  20. moduleFor('route:yarn-nodes', 'Unit | Route | Nodes', {
  21. });
  22. test('Basic creation test', function(assert) {
  23. let route = this.subject();
  24. assert.ok(route);
  25. assert.ok(route.model);
  26. });
  27. test('Test getting nodes', function(assert) {
  28. var response = [{
  29. rack: "/default-rack", state: "RUNNING", id: "192.168.1.1:64318",
  30. nodeHostName: "192.168.1.1", nodeHTTPAddress: "192.168.1.1:8042",
  31. lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT",
  32. healthReport: "", numContainers: 0, usedMemoryMB: 0,
  33. availMemoryMB: 163840, usedVirtualCores: 0,
  34. availableVirtualCores: 160,
  35. resourceUtilization: {
  36. nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549,
  37. nodeCPUUsage: 0.14995001256465912,
  38. aggregatedContainersPhysicalMemoryMB: 0,
  39. aggregatedContainersVirtualMemoryMB: 0,
  40. containersCPUUsage: 0
  41. }},
  42. {rack: "/default-rack", state: "RUNNING", id: "192.168.1.2:64318",
  43. nodeHostName: "192.168.1.2", nodeHTTPAddress: "192.168.1.2:8042",
  44. lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT",
  45. healthReport: "", numContainers: 0, usedMemoryMB: 0,
  46. availMemoryMB: 163840, usedVirtualCores: 0,
  47. availableVirtualCores: 160,
  48. resourceUtilization: {
  49. nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549,
  50. nodeCPUUsage: 0.14995001256465912,
  51. aggregatedContainersPhysicalMemoryMB: 0,
  52. aggregatedContainersVirtualMemoryMB: 0,
  53. containersCPUUsage: 0
  54. }}];
  55. var store = {
  56. findAll: function(type) {
  57. return new Ember.RSVP.Promise(function(resolve) {
  58. resolve(response);
  59. });
  60. }
  61. };
  62. var route = this.subject();
  63. route.set('store', store);
  64. var model = route.model()._result;
  65. assert.expect(4);
  66. assert.ok(model);
  67. assert.equal(model.length, 2);
  68. assert.deepEqual(response[0], model[0]);
  69. assert.deepEqual(response[1], model[1]);
  70. });