yarn-node-test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Converter from 'yarn-ui/utils/converter';
  20. moduleFor('serializer:yarn-node', 'Unit | Serializer | Node', {
  21. });
  22. test('Basic creation test', function(assert) {
  23. let serializer = this.subject();
  24. assert.ok(serializer);
  25. assert.ok(serializer.normalizeSingleResponse);
  26. assert.ok(serializer.internalNormalizeSingleResponse);
  27. });
  28. test('normalizeSingleResponse test', function(assert) {
  29. let serializer = this.subject(),
  30. modelClass = {
  31. modelName: "yarn-node"
  32. },
  33. payload = {
  34. nodeInfo: {
  35. healthReport: "Healthy", totalVmemAllocatedContainersMB: 344064,
  36. totalPmemAllocatedContainersMB: 163840,
  37. totalVCoresAllocatedContainers: 160,
  38. vmemCheckEnabled: true, pmemCheckEnabled: true,
  39. lastNodeUpdateTime: 1456250210310, nodeHealthy: true,
  40. nodeManagerVersion: "3.0.0-SNAPSHOT",
  41. nodeManagerBuildVersion: "3.0.0-SNAPSHOT",
  42. nodeManagerVersionBuiltOn: "2000-01-01T00:00Z",
  43. hadoopVersion: "3.0.0-SNAPSHOT",
  44. hadoopBuildVersion: "3.0.0-SNAPSHOT",
  45. hadoopVersionBuiltOn: "2000-01-01T00:00Z",
  46. id: "localhost:64318", nodeHostName: "192.168.0.102",
  47. nmStartupTime: 1456250208231
  48. }
  49. };
  50. assert.expect(6);
  51. var id = "localhost:64318";
  52. var response = serializer.normalizeSingleResponse({}, modelClass, payload, id, null);
  53. assert.equal(response.data.id, id);
  54. assert.equal(response.data.type, modelClass.modelName);
  55. assert.equal(response.data.attributes.totalVmemAllocatedContainersMB,
  56. payload.nodeInfo.totalVmemAllocatedContainersMB);
  57. assert.equal(response.data.attributes.totalPmemAllocatedContainersMB,
  58. payload.nodeInfo.totalPmemAllocatedContainersMB);
  59. assert.equal(response.data.attributes.totalVCoresAllocatedContainers,
  60. payload.nodeInfo.totalVCoresAllocatedContainers);
  61. assert.equal(response.data.attributes.nmStartupTime,
  62. Converter.timeStampToDate(payload.nodeInfo.nmStartupTime));
  63. });