app_contoller_test.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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('controllers/main/apps_controller');
  20. /* require('models/cluster');
  21. require('models/service');
  22. require('models/pagination');
  23. require('controllers/main/host');*/
  24. describe('MainAppsController', function () {
  25. describe('#iTotalDisplayRecordsObserver()', function () {
  26. it('should set number of filtered jobs when switching to all jobs', function () {
  27. var mainAppsController = App.MainAppsController.create();
  28. mainAppsController.set("paginationObject.iTotalDisplayRecords", 5);
  29. expect(mainAppsController.get('filterObject.filteredDisplayRecords')).to.equal(5);
  30. })
  31. });
  32. describe('#filterObject.onRunTypeChange()', function () {
  33. it('should set sSearch_2 of filterObject when changing value of filterObject.runType', function () {
  34. var mainAppsController = App.MainAppsController.create();
  35. mainAppsController.set("filterObject.runType", "MapReduce");
  36. expect(mainAppsController.get('filterObject.sSearch_2')).to.equal("mr");
  37. mainAppsController.set("filterObject.runType", "Hive");
  38. expect(mainAppsController.get('filterObject.sSearch_2')).to.equal("hive");
  39. mainAppsController.set("filterObject.runType", "Pig");
  40. expect(mainAppsController.get('filterObject.sSearch_2')).to.equal("pig");
  41. })
  42. });
  43. describe('#filterObject.onJobsChange()', function () {
  44. it('should set minJobs,maxJobs of filterObject when changing value of filterObject.jobs', function () {
  45. var mainAppsController = App.MainAppsController.create();
  46. mainAppsController.set("filterObject.jobs", ">3");
  47. expect(mainAppsController.get('filterObject.minJobs')).to.equal("3");
  48. expect(mainAppsController.get('filterObject.maxJobs')).to.equal("");
  49. mainAppsController.set("filterObject.jobs", "<3");
  50. expect(mainAppsController.get('filterObject.minJobs')).to.equal("");
  51. expect(mainAppsController.get('filterObject.maxJobs')).to.equal("3");
  52. mainAppsController.set("filterObject.jobs", "3");
  53. expect(mainAppsController.get('filterObject.minJobs')).to.equal("3");
  54. expect(mainAppsController.get('filterObject.maxJobs')).to.equal("3");
  55. mainAppsController.set("filterObject.jobs", "=3");
  56. expect(mainAppsController.get('filterObject.minJobs')).to.equal("3");
  57. expect(mainAppsController.get('filterObject.maxJobs')).to.equal("3");
  58. })
  59. });
  60. describe('#filterObject.onInputChange()', function () {
  61. it('should set minInputBytes,maxInputBytes of filterObject when changing value of filterObject.input', function () {
  62. var mainAppsController = App.MainAppsController.create();
  63. mainAppsController.set("filterObject.input", ">3gb");
  64. expect(mainAppsController.get('filterObject.minInputBytes')).to.equal(3215856763);
  65. expect(mainAppsController.get('filterObject.maxInputBytes')).to.equal("");
  66. mainAppsController.set("filterObject.input", "<6m");
  67. expect(mainAppsController.get('filterObject.minInputBytes')).to.equal("");
  68. expect(mainAppsController.get('filterObject.maxInputBytes')).to.equal(6343884);
  69. mainAppsController.set("filterObject.input", "10kb");
  70. expect(mainAppsController.get('filterObject.minInputBytes')).to.equal(10189);
  71. expect(mainAppsController.get('filterObject.maxInputBytes')).to.equal(10291);
  72. mainAppsController.set("filterObject.input", "1");
  73. expect(mainAppsController.get('filterObject.minInputBytes')).to.equal(1024);
  74. expect(mainAppsController.get('filterObject.maxInputBytes')).to.equal(1075);
  75. })
  76. });
  77. describe('#filterObject.onOutputChange()', function () {
  78. it('should set minOutputBytes,maxOutputBytes of filterObject when changing value of filterObject.output', function () {
  79. var mainAppsController = App.MainAppsController.create();
  80. mainAppsController.set("filterObject.output", ">3gb");
  81. expect(mainAppsController.get('filterObject.minOutputBytes')).to.equal(3215856763);
  82. expect(mainAppsController.get('filterObject.maxOutputBytes')).to.equal("");
  83. mainAppsController.set("filterObject.output", "<6m");
  84. expect(mainAppsController.get('filterObject.minOutputBytes')).to.equal("");
  85. expect(mainAppsController.get('filterObject.maxOutputBytes')).to.equal(6343884);
  86. mainAppsController.set("filterObject.output", "10kb");
  87. expect(mainAppsController.get('filterObject.minOutputBytes')).to.equal(10189);
  88. expect(mainAppsController.get('filterObject.maxOutputBytes')).to.equal(10291);
  89. mainAppsController.set("filterObject.output", "1");
  90. expect(mainAppsController.get('filterObject.minOutputBytes')).to.equal(1024);
  91. expect(mainAppsController.get('filterObject.maxOutputBytes')).to.equal(1075);
  92. })
  93. });
  94. describe('#filterObject.onDurationChange()', function () {
  95. it('should set minDuration,maxDuration of filterObject when changing value of filterObject.duration', function () {
  96. var mainAppsController = App.MainAppsController.create();
  97. mainAppsController.set("filterObject.duration", ">3h");
  98. expect(mainAppsController.get('filterObject.minDuration')).to.equal(10799640);
  99. expect(mainAppsController.get('filterObject.maxDuration')).to.equal("");
  100. mainAppsController.set("filterObject.duration", "<6m");
  101. expect(mainAppsController.get('filterObject.minDuration')).to.equal("");
  102. expect(mainAppsController.get('filterObject.maxDuration')).to.equal(360060);
  103. mainAppsController.set("filterObject.duration", "10s");
  104. expect(mainAppsController.get('filterObject.minDuration')).to.equal(9990);
  105. expect(mainAppsController.get('filterObject.maxDuration')).to.equal(10010);
  106. mainAppsController.set("filterObject.duration", "1");
  107. expect(mainAppsController.get('filterObject.minDuration')).to.equal(990);
  108. expect(mainAppsController.get('filterObject.maxDuration')).to.equal(1010);
  109. })
  110. });
  111. describe('#filterObject.onRunDateChange()', function () {
  112. it('should set minStartTime,maxStartTime of filterObject when changing value of filterObject.runDate', function () {
  113. var mainAppsController = App.MainAppsController.create();
  114. mainAppsController.set("filterObject.runDate", "Any");
  115. expect(mainAppsController.get('filterObject.minStartTime')).to.equal("");
  116. mainAppsController.set("filterObject.runDate", "Past 1 Day");
  117. expect(mainAppsController.get('filterObject.minStartTime')).to.be.within(((new Date().getTime())-86400000)-10,((new Date().getTime())-86400000)+10);
  118. mainAppsController.set("filterObject.runDate", "Past 2 Days");
  119. expect(mainAppsController.get('filterObject.minStartTime')).to.be.within(((new Date().getTime())-172800000)-10,((new Date().getTime())-172800000)+10);
  120. mainAppsController.set("filterObject.runDate", "Past 7 Days");
  121. expect(mainAppsController.get('filterObject.minStartTime')).to.be.within(((new Date().getTime())-604800000)-10,((new Date().getTime())-604800000)+10);
  122. mainAppsController.set("filterObject.runDate", "Past 14 Days");
  123. expect(mainAppsController.get('filterObject.minStartTime')).to.be.within(((new Date().getTime())-1209600000)-10,((new Date().getTime())-1209600000)+10);
  124. mainAppsController.set("filterObject.runDate", "Past 30 Days");
  125. expect(mainAppsController.get('filterObject.minStartTime')).to.be.within(((new Date().getTime())-2592000000)-10,((new Date().getTime())-2592000000)+10);
  126. })
  127. });
  128. describe('#filterObject.createAppLink(), #filterObject.valueObserver()', function () {
  129. it('should set runUrl of filterObject when changing value for any filter', function () {
  130. var mainAppsController = App.MainAppsController.create();
  131. mainAppsController.set("filterObject.sSearch_0", "0");
  132. mainAppsController.set("filterObject.sSearch_1", "workflowName");
  133. mainAppsController.set("filterObject.sSearch_2", "pig");
  134. mainAppsController.set("filterObject.sSearch_3", "admin");
  135. mainAppsController.set("filterObject.minJobs", "1");
  136. mainAppsController.set("filterObject.maxJobs", "2");
  137. mainAppsController.set("filterObject.minInputBytes", "2000");
  138. mainAppsController.set("filterObject.maxInputBytes", "3000");
  139. mainAppsController.set("filterObject.minOutputBytes", "1500");
  140. mainAppsController.set("filterObject.maxOutputBytes", "2000");
  141. mainAppsController.set("filterObject.minDuration", "1000");
  142. mainAppsController.set("filterObject.maxDuration", "2000");
  143. mainAppsController.set("filterObject.minStartTime", "999");
  144. mainAppsController.set("filterObject.maxStartTime", "1000");
  145. mainAppsController.set("filterObject.sSearch", "searchTerm");
  146. mainAppsController.set("filterObject.iDisplayLength", "10");
  147. mainAppsController.set("filterObject.iDisplayStart", "10");
  148. mainAppsController.set("filterObject.iSortCol_0", "1");
  149. mainAppsController.set("filterObject.sSortDir_0", "ASC");
  150. expect(mainAppsController.get('runUrl')).to.equal("/jobhistory/datatable?" +
  151. "sSearch_0=0" +
  152. "&sSearch_1=workflowName" +
  153. "&sSearch_2=pig" +
  154. "&sSearch_3=admin" +
  155. "&minJobs=1" +
  156. "&maxJobs=2" +
  157. "&minInputBytes=2000" +
  158. "&maxInputBytes=3000" +
  159. "&minOutputBytes=1500" +
  160. "&maxOutputBytes=2000" +
  161. "&minDuration=1000" +
  162. "&maxDuration=2000" +
  163. "&minStartTime=999" +
  164. "&maxStartTime=1000" +
  165. "&sSearch=searchTerm" +
  166. "&iDisplayLength=10" +
  167. "&iDisplayStart=10" +
  168. "&iSortCol_0=1" +
  169. "&sSortDir_0=ASC");
  170. })
  171. });
  172. });