hdfs_test.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. var modelSetup = require('test/init_model_test');
  20. require('models/service/hdfs');
  21. var hdfsService,
  22. hdfsServiceData = {
  23. id: 'hdfs'
  24. },
  25. hostComponentsData = [
  26. {
  27. id: 'datanode',
  28. componentName: 'DATANODE'
  29. },
  30. {
  31. id: 'journalnode',
  32. componentName: 'JOURNALNODE'
  33. }
  34. ],
  35. cases = [
  36. {
  37. propertyName: 'dataNodes',
  38. componentId: 'datanode'
  39. },
  40. {
  41. propertyName: 'journalNodes',
  42. componentId: 'journalnode'
  43. }
  44. ];
  45. describe('App.HDFSService', function () {
  46. beforeEach(function () {
  47. hdfsService = App.HDFSService.createRecord(hdfsServiceData);
  48. });
  49. afterEach(function () {
  50. modelSetup.deleteRecord(hdfsService);
  51. });
  52. cases.forEach(function (item) {
  53. var propertyName = item.propertyName;
  54. describe('#' + propertyName, function () {
  55. it('should take one component from hostComponents', function () {
  56. hdfsService.reopen({
  57. hostComponents: hostComponentsData
  58. });
  59. expect(hdfsService.get(propertyName)).to.have.length(1);
  60. expect(hdfsService.get(propertyName)[0].id).to.equal(item.componentId);
  61. });
  62. });
  63. });
  64. });