stack_mapper_test.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 Ember = require('ember');
  19. var App = require('app');
  20. require('mappers/server_data_mapper');
  21. require('mappers/stack_mapper');
  22. require('models/stack');
  23. require('models/operating_system');
  24. require('models/repository');
  25. describe('App.stackMapper', function () {
  26. describe("#map", function() {
  27. var test_data = {
  28. items: [{
  29. "Versions" : {
  30. "active" : true,
  31. "min_upgrade_version" : null,
  32. "parent_stack_version" : "1.3.3",
  33. "stack_name" : "HDP",
  34. "stack_version" : "1.3"
  35. },
  36. "operating_systems" : [
  37. {
  38. "OperatingSystems" : {
  39. "os_type" : "redhat5",
  40. "stack_name" : "HDP",
  41. "stack_version" : "1.3"
  42. },
  43. "repositories" : [
  44. {
  45. "Repositories" : {
  46. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.7.0",
  47. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.7.0",
  48. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.8.0",
  49. "mirrors_list" : null,
  50. "os_type" : "redhat5",
  51. "repo_id" : "HDP-1.3",
  52. "repo_name" : "HDP",
  53. "stack_name" : "HDP",
  54. "stack_version" : "1.3"
  55. }
  56. },{
  57. "Repositories" : {
  58. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
  59. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
  60. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
  61. "mirrors_list" : null,
  62. "os_type" : "redhat5",
  63. "repo_id" : "HDP-UTILS-1.1.0.16",
  64. "repo_name" : "HDP-UTILS",
  65. "stack_name" : "HDP",
  66. "stack_version" : "1.3"
  67. }
  68. }]
  69. },{
  70. "OperatingSystems" : {
  71. "os_type" : "redhat6",
  72. "stack_name" : "HDP",
  73. "stack_version" : "1.3"
  74. }, "repositories" : [
  75. {
  76. "Repositories" : {
  77. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.7.0",
  78. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.7.0",
  79. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.8.0",
  80. "mirrors_list" : null,
  81. "os_type" : "redhat6",
  82. "repo_id" : "HDP-1.3",
  83. "repo_name" : "HDP",
  84. "stack_name" : "HDP",
  85. "stack_version" : "1.3"
  86. }
  87. },
  88. {
  89. "Repositories" : {
  90. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
  91. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
  92. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
  93. "mirrors_list" : null,
  94. "os_type" : "redhat6",
  95. "repo_id" : "HDP-UTILS-1.1.0.16",
  96. "repo_name" : "HDP-UTILS",
  97. "stack_name" : "HDP",
  98. "stack_version" : "1.3"
  99. }
  100. }
  101. ]
  102. }]
  103. },{
  104. "Versions" : {
  105. "active" : false,
  106. "min_upgrade_version" : null,
  107. "parent_stack_version" : null,
  108. "stack_name" : "HDP",
  109. "stack_version" : "2.0.6"
  110. },
  111. "operating_systems" : [
  112. {
  113. "OperatingSystems" : {
  114. "os_type" : "redhat5",
  115. "stack_name" : "HDP",
  116. "stack_version" : "2.0.6"
  117. },
  118. "repositories" : [
  119. {
  120. "Repositories" : {
  121. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  122. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  123. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  124. "mirrors_list" : null,
  125. "os_type" : "redhat5",
  126. "repo_id" : "HDP-2.0.6",
  127. "repo_name" : "HDP",
  128. "stack_name" : "HDP",
  129. "stack_version" : "2.0.6"
  130. }
  131. },
  132. {
  133. "Repositories" : {
  134. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  135. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  136. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  137. "mirrors_list" : null,
  138. "os_type" : "redhat5",
  139. "repo_id" : "HDP-UTILS-1.1.0.17",
  140. "repo_name" : "HDP-UTILS",
  141. "stack_name" : "HDP",
  142. "stack_version" : "2.0.6"
  143. }
  144. }]
  145. }, {
  146. "OperatingSystems" : {
  147. "os_type" : "redhat6",
  148. "stack_name" : "HDP",
  149. "stack_version" : "2.0.6"
  150. },
  151. "repositories" : [
  152. {
  153. "Repositories" : {
  154. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  155. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  156. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  157. "mirrors_list" : null,
  158. "os_type" : "redhat6",
  159. "repo_id" : "HDP-2.0.6",
  160. "repo_name" : "HDP",
  161. "stack_name" : "HDP",
  162. "stack_version" : "2.0.6"
  163. }
  164. }, {
  165. "Repositories" : {
  166. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  167. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  168. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  169. "mirrors_list" : null,
  170. "os_type" : "redhat6",
  171. "repo_id" : "HDP-UTILS-1.1.0.17",
  172. "repo_name" : "HDP-UTILS",
  173. "stack_name" : "HDP",
  174. "stack_version" : "2.0.6"
  175. }
  176. }]
  177. }]
  178. },{
  179. "Versions" : {
  180. "active" : true,
  181. "min_upgrade_version" : null,
  182. "parent_stack_version" : null,
  183. "stack_name" : "HDP",
  184. "stack_version" : "2.1"
  185. },
  186. "operating_systems" : [
  187. {
  188. "OperatingSystems" : {
  189. "os_type" : "redhat5",
  190. "stack_name" : "HDP",
  191. "stack_version" : "2.1"
  192. },
  193. "repositories" : [
  194. {
  195. "Repositories" : {
  196. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  197. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  198. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
  199. "mirrors_list" : null,
  200. "os_type" : "redhat5",
  201. "repo_id" : "HDP-2.1",
  202. "repo_name" : "HDP",
  203. "stack_name" : "HDP",
  204. "stack_version" : "2.1"
  205. }
  206. },
  207. {
  208. "Repositories" : {
  209. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  210. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  211. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
  212. "mirrors_list" : null,
  213. "os_type" : "redhat5",
  214. "repo_id" : "HDP-UTILS-1.1.0.17",
  215. "repo_name" : "HDP-UTILS",
  216. "stack_name" : "HDP",
  217. "stack_version" : "2.1"
  218. }
  219. }]
  220. }, {
  221. "OperatingSystems" : {
  222. "os_type" : "redhat6",
  223. "stack_name" : "HDP",
  224. "stack_version" : "2.1"
  225. },
  226. "repositories" : [
  227. {
  228. "Repositories" : {
  229. "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  230. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  231. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
  232. "mirrors_list" : null,
  233. "os_type" : "redhat6",
  234. "repo_id" : "HDP-2.1",
  235. "repo_name" : "HDP",
  236. "stack_name" : "HDP",
  237. "stack_version" : "2.1"
  238. }
  239. }, {
  240. "Repositories" : {
  241. "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  242. "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  243. "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
  244. "mirrors_list" : null,
  245. "os_type" : "redhat6",
  246. "repo_id" : "HDP-UTILS-1.1.0.17",
  247. "repo_name" : "HDP-UTILS",
  248. "stack_name" : "HDP",
  249. "stack_version" : "2.1"
  250. }
  251. }]
  252. }]
  253. }]
  254. };
  255. beforeEach(function () {
  256. App.resetDsStoreTypeMap(App.Repository);
  257. App.resetDsStoreTypeMap(App.OperatingSystem);
  258. App.resetDsStoreTypeMap(App.Stack);
  259. sinon.stub(App.store, 'commit', Em.K);
  260. });
  261. afterEach(function(){
  262. App.store.commit.restore();
  263. });
  264. it ('should map active Stack data', function() {
  265. App.stackMapper.map(test_data);
  266. expect(App.Stack.find().get('length')).to.equal(2);
  267. expect(App.Stack.find().everyProperty('active')).to.equal(true);
  268. expect(App.Stack.find().everyProperty('isSelected')).to.equal(false);
  269. expect(App.Stack.find().mapProperty('id')).to.eql(['HDP-2.1','HDP-1.3']);
  270. });
  271. it ('should map Operating System data', function() {
  272. App.stackMapper.map(test_data);
  273. expect(App.OperatingSystem.find().get('length')).to.equal(4);
  274. expect(App.OperatingSystem.find().mapProperty('id')).to.eql(['HDP-2.1-redhat5', 'HDP-2.1-redhat6', 'HDP-1.3-redhat5', 'HDP-1.3-redhat6']);
  275. });
  276. it ('should map Repository data', function() {
  277. App.stackMapper.map(test_data);
  278. expect(App.Repository.find().get('length')).to.equal(8);
  279. expect(App.Repository.find().mapProperty('id')).to.eql(["HDP-2.1-redhat5-HDP-2.1", "HDP-2.1-redhat5-HDP-UTILS-1.1.0.17", "HDP-2.1-redhat6-HDP-2.1", "HDP-2.1-redhat6-HDP-UTILS-1.1.0.17", "HDP-1.3-redhat5-HDP-1.3", "HDP-1.3-redhat5-HDP-UTILS-1.1.0.16", "HDP-1.3-redhat6-HDP-1.3", "HDP-1.3-redhat6-HDP-UTILS-1.1.0.16"]);
  280. });
  281. });
  282. });