yarn-node-test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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-node', 'Unit | Route | Node', {
  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 a node', function(assert) {
  28. var nodeResponse =
  29. {healthReport: "Healthy", totalVmemAllocatedContainersMB: 344064,
  30. totalPmemAllocatedContainersMB: 163840,
  31. totalVCoresAllocatedContainers: 160,
  32. vmemCheckEnabled: true, pmemCheckEnabled: true,
  33. lastNodeUpdateTime: 1456250210310, nodeHealthy: true,
  34. nodeManagerVersion: "3.0.0-SNAPSHOT",
  35. nodeManagerBuildVersion: "3.0.0-SNAPSHOT",
  36. nodeManagerVersionBuiltOn: "2000-01-01T00:00Z",
  37. hadoopVersion: "3.0.0-SNAPSHOT",
  38. hadoopBuildVersion: "3.0.0-SNAPSHOT",
  39. hadoopVersionBuiltOn: "2000-01-01T00:00Z",
  40. id: "localhost:64318", nodeHostName: "192.168.0.102",
  41. nmStartupTime: 1456250208231};
  42. var rmNodeResponse =
  43. {rack: "/default-rack", state: "RUNNING", id: "localhost:64318",
  44. nodeHostName: "localhost", nodeHTTPAddress: "localhost:8042",
  45. lastHealthUpdate: 1456251290905, version: "3.0.0-SNAPSHOT",
  46. healthReport: "", numContainers: 0, usedMemoryMB: 0,
  47. availMemoryMB: 163840, usedVirtualCores: 0,
  48. availableVirtualCores: 160,
  49. resourceUtilization: {
  50. nodePhysicalMemoryMB: 4549, nodeVirtualMemoryMB: 4549,
  51. nodeCPUUsage: 0.14995001256465912,
  52. aggregatedContainersPhysicalMemoryMB: 0,
  53. aggregatedContainersVirtualMemoryMB: 0,
  54. containersCPUUsage: 0
  55. }};
  56. // Create store which returns appropriate responses.
  57. var store = {
  58. findRecord: function(type) {
  59. if (type == 'yarnNode') {
  60. return new Ember.RSVP.Promise(function(resolve) {
  61. resolve(nodeResponse);
  62. });
  63. } else if (type == 'yarnRmNode') {
  64. return new Ember.RSVP.Promise(function(resolve) {
  65. resolve(rmNodeResponse);
  66. });
  67. }
  68. }
  69. };
  70. var route = this.subject();
  71. assert.expect(4);
  72. route.set('store', store);
  73. var model = route.model(
  74. {node_addr:"localhost:8042", node_id:"localhost:64318"})._result;
  75. assert.ok(model.node);
  76. assert.deepEqual(model.node, nodeResponse);
  77. assert.ok(model.rmNode);
  78. assert.deepEqual(model.rmNode, rmNodeResponse);
  79. });