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