stack_mapper_test.js 13 KB

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