yarn-node-container-test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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('yarn-node-container', 'Unit | Model | NodeContainer', {
  20. // Specify the other units that are required for this test.
  21. needs: []
  22. });
  23. test('Basic creation test', function(assert) {
  24. let model = this.subject();
  25. assert.ok(model);
  26. assert.ok(model._notifyProperties);
  27. assert.ok(model.didLoad);
  28. assert.ok(model.containerId);
  29. assert.ok(model.state);
  30. assert.ok(model.user);
  31. assert.ok(model.exitCode);
  32. assert.ok(model.totalMemoryNeeded);
  33. assert.ok(model.totalVCoresNeeded);
  34. assert.ok(model.containerLogFiles);
  35. assert.ok(model.isDummyContainer);
  36. assert.ok(model.containerStateStyle);
  37. });
  38. test('test fields', function(assert) {
  39. let model = this.subject();
  40. Ember.run(function () {
  41. model.set("containerId", "container_e32_1456000363780_0002_01_000003");
  42. model.set("state", "RUNNING");
  43. model.set("exitCode", "-1000");
  44. model.set("user", "hadoop");
  45. model.set("id", "container_e32_1456000363780_0002_01_000003");
  46. model.set("totalMemoryNeeded", 1024);
  47. model.set("totalVCoresNeeded", 1);
  48. model.set("containerLogFiles", ["syslog", "stderr", "stdout"]);
  49. assert.equal(model.get("containerId"), "container_e32_1456000363780_0002_01_000003");
  50. assert.equal(model.get("id"), "container_e32_1456000363780_0002_01_000003");
  51. assert.equal(model.get("totalMemoryNeeded"), 1024);
  52. assert.equal(model.get("totalVCoresNeeded"), 1);
  53. assert.equal(model.get("user"), "hadoop");
  54. assert.equal(model.get("exitCode"), "-1000");
  55. assert.equal(model.get("containerLogFiles").length, 3);
  56. assert.deepEqual(model.get("containerLogFiles"), ["syslog", "stderr", "stdout"]);
  57. assert.equal(model.get("isDummyContainer"), false);
  58. assert.equal(model.get("containerStateStyle"), "label label-primary");
  59. model.set("id", "dummy");
  60. assert.equal(model.get("isDummyContainer"), true);
  61. model.set("state", "EXITED_WITH_SUCCESS");
  62. assert.equal(model.get("containerStateStyle"), "label label-success");
  63. model.set("state", "EXITED_WITH_FAILURE");
  64. assert.equal(model.get("containerStateStyle"), "label label-danger");
  65. model.set("state", "DONE");
  66. model.set("exitCode", "0");
  67. assert.equal(model.get("containerStateStyle"), "label label-success");
  68. model.set("exitCode", "-105");
  69. assert.equal(model.get("containerStateStyle"), "label label-danger");
  70. });
  71. });