41eb0732b1fcd81a60b9f3ed3f3b7d17a8da8ba2
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.translator.services.heattotosca.impl.fulltest;
18
19 import org.junit.Test;
20 import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseFullTranslationTest;
21
22 import java.io.IOException;
23
24 public class UnifiedCompositionSubInterfaceFullTest extends BaseFullTranslationTest {
25
26   private static final String PATTERN_1A_BASE_DIRECTORY =
27       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern1a/";
28   private static final String PATTERN_1B_BASE_DIRECTORY =
29       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern1b/";
30   private static final String PATTERN_1C1_BASE_DIRECTORY =
31       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern1c1/";
32   private static final String PATTERN_1C2_BASE_DIRECTORY =
33       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern1c2/";
34   private static final String PATTERN_4_BASE_DIRECTORY =
35       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern4/";
36   private static final String PATTERN_5_BASE_DIRECTORY =
37       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/pattern5/";
38   private static final String VFC_INSTANCE_GROUP_BASE_DIRECTORY =
39       "/mock/services/heattotosca/fulltest/subinterface/vlantagging/vfcInstanceGroup/";
40
41   @Test
42   public void testSubInterfaceComputePortNetworkWithGroup() throws IOException {
43     /*
44      * Heat file with one compute, one port and one subinterface resource group with only port
45      * connected to network
46      */
47     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "computePortNetworkSubInterface");
48   }
49
50   @Test
51   public void testSubInterfaceNodesConnectedOut() throws IOException {
52     /*
53      * Heat file with one compute, one port and one subinterface resource group with
54      * 1. Port connected to network
55      * 2. Sub-interface connected to same network
56      * 3. Sub-interface has depends on (out) connectivity with network resource
57      */
58     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
59   }
60
61   @Test
62   public void testSubInterfaceNodesConnectedIn() throws IOException {
63     /*
64      * Heat file with one compute, one port and one subinterface resource group with
65      * 1. Port connected to network
66      * 2. Sub-interface connected to different network
67      * 3. Sub-interface has depends on (in) connectivity from network resource
68      */
69     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
70   }
71
72   @Test
73   public void testSubInterfaceGetAttrInOut() throws IOException {
74     /*
75      * Heat file with one compute, one port and one subinterface resource group with
76      * 1. Port connected to network
77      * 2. Sub-interface connected to different network
78      * 3. Sub-interface has get attribute (in) connectivity from network resource
79      * 4. Sub-interface has get attribute (out) connectivity to second network resource
80      * 5. Sub-interface has get attribute (in) connectivity from output param
81      */
82     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
83   }
84
85   @Test
86   public void testSubInterfaceMultipleVlanSameNestedFile() throws IOException {
87     /*
88      * Heat file with one compute, one port and two subinterface resource groups with
89      * 1. Port connected to network
90      * 2. Sub-interfaces with same nested files
91      */
92     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanSameType");
93   }
94
95   @Test
96   public void testSubInterfaceMultipleVlanDiffNestedFile() throws IOException {
97     /*
98      * Heat file with one compute, one port and two subinterface resource groups with
99      * 1. Port connected to network
100      * 2. Sub-interfaces with different nested files
101      */
102     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanDiffType");
103   }
104
105   @Test
106   public void testSubInterfaceMultiplePortsMultipleVlans() throws IOException {
107     /*
108      * Heat file with one compute, two ports and two subinterface resource groups with
109      * 1. Port connected to network
110      * 2. Sub-interfaces each with different nested files
111      */
112     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multiplePortsMultipleVlans");
113   }
114
115   @Test
116   public void testSubInterfaceRegularNested() throws IOException {
117     /*
118      * Heat file with one compute, one port and one subinterface resource represented through a
119      * regular nested resource and not using a resource group
120      */
121     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "regularNestedSubInterface");
122   }
123
124   @Test
125   public void testSubInterfaceNotBoundToPort() throws IOException {
126     /*
127      * Heat file with one compute, one port and one subinterface resource group with
128      * 1. Resource group missing virtual_machine_interface_refs property
129      * 2. Resource group missing virtual_machine_interface_properties_sub_interface_vlan_tag
130      *    property
131      * 3. Resource group parent port as get_param
132      */
133     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "notBoundToParentPort");
134   }
135
136   //Pattern 1B test
137   @Test
138   public void testDiffComputeSubInterface() throws IOException {
139     /*
140      * Heat file with one compute, one port and one subinterface resource group with
141      * 1. There are two compute both of different type
142      */
143     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "diffComputeSubInterface");
144   }
145
146   @Test
147   public void testOnePortIsConnectedWithSubInf() throws IOException {
148     /*
149      * Heat file with one compute, one port and one subinterface resource group with
150      * 1. Two compute of same type
151      * 2. Two port of same type but only one of them is having sub interface binding
152      */
153     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "onePortIsConnectedWithSubInf");
154   }
155
156   @Test
157   public void testRegularNestedSubInterface() throws IOException {
158     /*
159      * Heat file with one compute, one port and one sub interface without resource group
160      * 1. Two compute of same type
161      * 2. Two port are of different type
162      * 3. Sub interface properties are same in both port
163      */
164     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "regularNestedSubInterface");
165   }
166
167   @Test
168   public void testSameComputeDiffPortSubInterface() throws IOException {
169     /*
170      * Heat file with one compute, one port and one subinterface resource group with
171      * 1. Two compute of same type
172      * 2. Two port are of different type
173      * 3. Sub interface properties are same in both port
174      */
175     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeDiffPortSubInterface");
176   }
177
178   @Test
179   public void testSameComputeSamePortDiffSubInterfaceFile() throws IOException {
180     /*
181      * Heat file with one compute, one port and one subinterface resource group with
182      * 1. Two compute of same type
183      * 2. Two port are of same type connected with different sub interface nested file
184      * 3. Sub interface property are same for both port
185      */
186     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeSamePortDiffSubInterfaceFile");
187   }
188
189   //****************** PATTERN 1C1 Tests ***************************
190
191   @Test
192   public void testSubInterfaceScalingOnePortVlanSameType() throws IOException {
193     /*
194      * Heat file with two computes of same type, two ports of same type and two subinterface resource groups of same
195      * type with
196      * 1. Compute has one port each
197      * 2. Port has one sub-interface each
198      * 3. Port connected to network
199      * 3. Sub-interface not connected to network
200      */
201     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "onePortVlanSameType");
202   }
203
204   @Test
205   public void testSubInterfaceScalingMultiplePortsMultipleVlansWithGroup() throws IOException {
206     /*
207      * Heat file with two computes of different type, four ports of two types each and four subinterface resource groups
208      * of two types each
209      * 1. Each compute has two ports, one of each type
210      * 2. Port has one sub-interface each
211      * 3. Ports connected to different networks
212      * 4. Sub-interface of one type connected to network
213      */
214     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "multiplePortsMultipleVlans");
215   }
216
217   @Test
218   public void testSubInterfaceScalingOptionalPropertiesConsolidation() throws IOException {
219     /*
220      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
221      * of same type
222      * 1. Each compute has two ports, one of each type
223      * 2. One of the ports has a subinterface
224      * 3. Ports connected to network
225      * 4. Subinterfaces not connected to network
226      * 5. Optional properties contained in one subinterface and not in other
227      */
228     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "optionalPropertiesConsolidation");
229   }
230
231   @Test
232   public void testSubInterfaceScalingRegularNestedSubInterface() throws IOException {
233     /*
234      * Heat file with two computes, two ports of same type connected to network and two subinterface resource
235      * represented through a regular nested resource and not using a resource group not connected to network
236      */
237     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "regularNestedSubInterface");
238   }
239
240   @Test
241   public void testSubInterfaceScalingAllConnectivities() throws IOException {
242     /*
243      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
244      * of same type
245      * 1. Each compute has two ports, one of each type
246      * 2. One of the ports has a subinterface
247      * 3. Port connected to network
248      * 4. Both ports and subinterfaces connected to network
249      * 5. All connectivities including dependency, get attribute from nodes and output param
250      */
251     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "allConnectivities");
252   }
253
254   @Test
255   public void testSubInterfaceWithDifferentResourceGroupCount() throws IOException {
256     /*
257      * Heat file with two computes of the same type, each one has one port with one sub interface
258      * (from same type)
259      * resource group have a different count which creates a catalog instance
260      * */
261
262     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentResourceGroupCount");
263   }
264
265   @Test
266   public void testSubInterfaceDifferentNodesConnectedOutToResourceGroup() throws IOException {
267     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentNodesConnectedOut");
268   }
269
270   @Test
271   public void testSubInterfaceDifferentNetwork() throws IOException {
272     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentNetwork");
273   }
274
275   //Pattern5 Test Cases
276   @Test
277   public void testBaseScenarioPattern5() throws IOException {
278     /*
279      * Base heat has only nested component and nested heat has reference to subinterface and
280      * two VFCs of different type
281      * 1. Each server connected with two port
282      * 2. One Port of each server connected to network
283      * 3. Only one port out of four is having sub interface connectivity
284      * 4. Sub-interface connected to different network then port
285      */
286     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "baseScenario");
287   }
288
289   @Test
290   public void testComplexVFCScalingScenarioPattern5() throws IOException {
291     /*
292      * 1. Base heat has only nested component and nested has reference to subinterface and
293      * two VFCs of same type
294      * 1. Each server connected with two port
295      * 2. One Port of each server connected to network
296      * 3. Only one port out of four is having sub interface
297      * 4. Sub-interface connected to different network then port
298      */
299     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCScalingScenario");
300   }
301
302   @Test
303   public void testComplexVFCMultiLevelNestedScenarioPattern5() throws IOException {
304     /*
305      * 1. First level nested is having one VFC and one Port with Sub interface
306      * 2. Second level nested is having one VFC and one Port with Sub interface which are of same
307      * type as parent heat file
308      */
309     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedScenario");
310   }
311
312   @Test
313   public void testComplexVFCMultiLevelNestedDiffComputeScenarioPattern5() throws
314       IOException {
315     /*
316      * 1. First level nested is having one VFC and one Port with Sub interface
317      * 2. Second level nested is having one VFC and one Port with Sub interface which are of
318      * different type as parent heat file
319      */
320     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedDiffComputeScenario");
321   }
322
323   @Test
324   public void testComplexVFCMultiComputeInAllHeatPattern5() throws
325       IOException {
326     /*
327      * 1. Main is having 4 VFC of 2 type and 2 port and all having sub interface
328      * 2. Second level nested is having 4 VFC of 2 type and 2 port and all having sub interface
329      */
330     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiVFCInAllHeatScalingScenario");
331   }
332
333   @Test
334   public void testComplexVFCMultiLevelNestedMultiComputeScenarioPattern5() throws
335       IOException {
336     /*
337      * 1. First level nested is having one VFC and one Port with Sub interface
338      * 2. Second level nested is having two VFC of same type and two Port with Sub interface
339      */
340     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedMultiComputeScenario");
341   }
342
343   @Test
344   public void testComplexVFCWithDiffSubInfConnectivityScenarioPattern5() throws IOException {
345     /*
346      * 1. First level nested is having one VFC and one Port with Sub interface
347      * 2. Second level nested is having two VFC of same type and one Port with only one port
348      * connected to Sub interface
349      */
350     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCWithDiffSubInfConnectivityScenario");
351   }
352
353   @Test
354   public void testComplexVFCWithDiffSubInfCountScenarioPattern5() throws IOException {
355     /*
356      * 1. First level nested is having one VFC and one Port with Sub interface
357      * 2. Second level nested is having two VFC of same type and connected to Sub interface but
358      * having different count
359      */
360     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCWithDiffSubInfCountScenario");
361   }
362
363   //Pattern 4 Test Cases
364   @Test
365   public void testSubInterfaceComputePortNetworkPattern4() throws IOException {
366     /*
367      * Nested Heat file with one compute, one port and one subinterface resource group with only
368      * port connected to network
369      */
370     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "computePortNetworkSubInterface");
371   }
372
373   @Test
374   public void testSubInterfaceMultiplePortsMultipleVlansPattern4() throws IOException {
375     /*
376      * Nested Heat file with one compute, two ports and two subinterface resource groups with
377      * 1. Port connected to network
378      * 2. Sub-interfaces each with different nested files
379      */
380     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multiplePortsMultipleVlans");
381   }
382
383   @Test
384   public void testSubInterfaceMultipleVlanDiffFilePattern4() throws IOException {
385     /*
386      * Nested Heat file with one compute, one port and two subinterface resource groups with
387      * 1. Port connected to network
388      * 2. Sub-interfaces with different nested files
389      */
390     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanDiffFile");
391   }
392
393   @Test
394   public void testSubInterfaceMultipleVlanSameFilePattern4() throws IOException {
395     /*
396      * Nested Heat file with one compute, one port and two subinterface resource groups with
397      * 1. Port connected to network
398      * 2. Sub-interfaces with same nested files
399      */
400     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanSameFile");
401   }
402
403   @Test
404   public void testSubInterfaceRegularNestedPattern4() throws IOException {
405     /*
406      * Nested Heat file with one compute, one port and one subinterface resource represented
407      * through a regular nested resource and not using a resource group
408      */
409     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "regularNestedSubInterface");
410   }
411
412   @Test
413   public void testSubInterfaceGetAttrInOutPattern4() throws IOException {
414     /*
415      * Nested Heat file with one compute, one port and one subinterface resource group with
416      * 1. Port connected to network
417      * 2. Sub-interface connected to different network
418      * 3. Sub-interface has get attribute (in) connectivity from network resource
419      * 4. Sub-interface has get attribute (out) connectivity to second network resource
420      * 5. Sub-interface has get attribute (in) connectivity from output param
421      */
422     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
423   }
424
425   @Test
426   public void testSubInterfaceNodesConnectedInPattern4() throws IOException {
427     /*
428      * Nested Heat file with one compute, one port and one subinterface resource group with
429      * 1. Port connected to network
430      * 2. Sub-interface connected to different network
431      * 3. Sub-interface has depends on (in) connectivity from network resource
432      */
433     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
434   }
435
436   @Test
437   public void testSubInterfaceNodesConnectedOutPattern4() throws IOException {
438     /*
439      * Nested Heat file with one compute, one port and one subinterface resource group with
440      * 1. Port connected to network
441      * 2. Sub-interface connected to same network
442      * 3. Sub-interface has depends on (out) connectivity with network resource
443      */
444     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
445   }
446
447
448   //****************** VFC Instance Group Tests ***************************
449
450   @Test
451   public void testGroupingOneSubInterfaceTypeOneAbstractNode() throws IOException {
452     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "oneSubInterfaceNetworkRole");
453   }
454
455   @Test
456   public void testGroupingOneSubInterfaceTypeAndTwoAbstractNodes() throws IOException {
457     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "oneSubInterfaceNetworkRoleAndTwoAbstractNodes");
458   }
459
460   @Test
461   public void testGroupingTwoSubInterfaceTypeAndTwoAbstractNodes() throws IOException {
462     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "twoSubInterfaceNetworkRoleAndTwoAbstractNodes");
463   }
464
465   @Test
466   public void testSubInterfacePattern4WithGroup() throws IOException {
467     /*
468      * Nested Heat file with one compute, one port and one subinterface resource group with
469      * 1. Port connected to network
470      * 2. Sub-interface connected to same network
471      * 3. Sub-interface has depends on (out) connectivity with network resource
472      */
473     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "pattern4SubInterfaceNodesConnectedOut");
474   }
475
476 }