host_component_test.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. var App = require('app');
  19. require('models/host_component');
  20. require('models/host');
  21. require('router');
  22. require('models/service/hdfs');
  23. require('controllers/main/service');
  24. describe('App.HostComponent', function () {
  25. var hostComponentData = [
  26. {
  27. id: 'component1',
  28. component_name: 'DATANODE',
  29. host_id: 'host1'
  30. },
  31. {
  32. id: 'component2',
  33. component_name: 'DATANODE',
  34. host_id: 'host3'
  35. },
  36. {
  37. id: 'component3',
  38. component_name: 'TASKTRACKER',
  39. host_id: 'host2'
  40. }
  41. ];
  42. var hdfsData = {
  43. id: 'HDFS',
  44. service_name: 'HDFS',
  45. decommission_data_nodes: ['host1', 'host2']
  46. };
  47. //3 hosts are loaded to the model (host1, host2, host3) in models/host_test
  48. App.store.load(App.HDFSService, hdfsData);
  49. App.store.loadMany(App.HostComponent, hostComponentData);
  50. describe('#isDecommissioning', function () {
  51. it('component1 is DATANODE and on decommissioned host', function () {
  52. var hostComponent = App.HostComponent.find().findProperty('id', 'component1');
  53. expect(hostComponent.get('isDecommissioning')).to.equal(true);
  54. });
  55. it('component2 is DATANODE but not on decommissioned host', function () {
  56. var hostComponent = App.HostComponent.find().findProperty('id', 'component2');
  57. expect(hostComponent.get('isDecommissioning')).to.equal(false);
  58. });
  59. it('component3 isn\'t DATANODE', function () {
  60. var hostComponent = App.HostComponent.find().findProperty('id', 'component3');
  61. expect(hostComponent.get('isDecommissioning')).to.equal(false);
  62. });
  63. });
  64. });