7914f34adee9cbf6b54d46cf11cf27b3df2e230c
[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   @Test
137   public void testIfSubInfNotPresentPortPropShouldBeFalse() throws IOException {
138     /*
139      * Nested Heat file with one compute, two port and one subinterface resource group with
140      * 1. Port connected with compute
141      * 2. Sub-interface connected to only on Port
142      * 3. Need to verify if sub interface resource is not bind with Port then
143      * subinterface_indicator property under port value should be false
144      */
145     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "twoPortOnlyOneConnectedWithSubInf");
146   }
147
148   //Pattern 1B test
149   @Test
150   public void testDiffComputeSubInterface() throws IOException {
151     /*
152      * Heat file with one compute, one port and one subinterface resource group with
153      * 1. There are two compute both of different type
154      */
155     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "diffComputeSubInterface");
156   }
157
158   @Test
159   public void testOnePortIsConnectedWithSubInf() throws IOException {
160     /*
161      * Heat file with one compute, one port and one subinterface resource group with
162      * 1. Two compute of same type
163      * 2. Two port of same type but only one of them is having sub interface binding
164      */
165     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "onePortIsConnectedWithSubInf");
166   }
167
168   @Test
169   public void testRegularNestedSubInterface() throws IOException {
170     /*
171      * Heat file with one compute, one port and one sub interface without resource group
172      * 1. Two compute of same type
173      * 2. Two port are of different type
174      * 3. Sub interface properties are same in both port
175      */
176     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "regularNestedSubInterface");
177   }
178
179   @Test
180   public void testSameComputeDiffPortSubInterface() throws IOException {
181     /*
182      * Heat file with one compute, one port and one subinterface resource group with
183      * 1. Two compute of same type
184      * 2. Two port are of different type
185      * 3. Sub interface properties are same in both port
186      */
187     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeDiffPortSubInterface");
188   }
189
190   @Test
191   public void testSameComputeSamePortDiffSubInterfaceFile() throws IOException {
192     /*
193      * Heat file with one compute, one port and one subinterface resource group with
194      * 1. Two compute of same type
195      * 2. Two port are of same type connected with different sub interface nested file
196      * 3. Sub interface property are same for both port
197      */
198     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeSamePortDiffSubInterfaceFile");
199   }
200
201   //****************** PATTERN 1C1 Tests ***************************
202
203   @Test
204   public void testSubInterfaceScalingOnePortVlanSameType() throws IOException {
205     /*
206      * Heat file with two computes of same type, two ports of same type and two subinterface resource groups of same
207      * type with
208      * 1. Compute has one port each
209      * 2. Port has one sub-interface each
210      * 3. Port connected to network
211      * 3. Sub-interface not connected to network
212      */
213     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "onePortVlanSameType");
214   }
215
216   @Test
217   public void testSubInterfaceScalingMultiplePortsMultipleVlansWithGroup() throws IOException {
218     /*
219      * Heat file with two computes of different type, four ports of two types each and four subinterface resource groups
220      * of two types each
221      * 1. Each compute has two ports, one of each type
222      * 2. Port has one sub-interface each
223      * 3. Ports connected to different networks
224      * 4. Sub-interface of one type connected to network
225      */
226     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "multiplePortsMultipleVlans");
227   }
228
229   @Test
230   public void testSubInterfaceScalingOptionalPropertiesConsolidation() throws IOException {
231     /*
232      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
233      * of same type
234      * 1. Each compute has two ports, one of each type
235      * 2. One of the ports has a subinterface
236      * 3. Ports connected to network
237      * 4. Subinterfaces not connected to network
238      * 5. Optional properties contained in one subinterface and not in other
239      */
240     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "optionalPropertiesConsolidation");
241   }
242
243   @Test
244   public void testSubInterfaceScalingRegularNestedSubInterface() throws IOException {
245     /*
246      * Heat file with two computes, two ports of same type connected to network and two subinterface resource
247      * represented through a regular nested resource and not using a resource group not connected to network
248      */
249     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "regularNestedSubInterface");
250   }
251
252   @Test
253   public void testSubInterfaceScalingAllConnectivities() throws IOException {
254     /*
255      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
256      * of same type
257      * 1. Each compute has two ports, one of each type
258      * 2. One of the ports has a subinterface
259      * 3. Port connected to network
260      * 4. Both ports and subinterfaces connected to network
261      * 5. All connectivities including dependency, get attribute from nodes and output param
262      */
263     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "allConnectivities");
264   }
265
266   @Test
267   public void testSubInterfaceWithDifferentResourceGroupCount() throws IOException {
268     /*
269      * Heat file with two computes of the same type, each one has one port with one sub interface
270      * (from same type)
271      * resource group have a different count which creates a catalog instance
272      * */
273
274     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentResourceGroupCount");
275   }
276
277   @Test
278   public void testSubInterfaceDifferentNodesConnectedOutToResourceGroup() throws IOException {
279     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentNodesConnectedOut");
280   }
281
282   @Test
283   public void testSubInterfaceDifferentNetwork() throws IOException {
284     testTranslationWithInit(PATTERN_1C2_BASE_DIRECTORY + "differentNetwork");
285   }
286
287   //Pattern5 Test Cases
288   @Test
289   public void testBaseScenarioPattern5() throws IOException {
290     /*
291      * Base heat has only nested component and nested heat has reference to subinterface and
292      * two VFCs of different type
293      * 1. Each server connected with two port
294      * 2. One Port of each server connected to network
295      * 3. Only one port out of four is having sub interface connectivity
296      * 4. Sub-interface connected to different network then port
297      */
298     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "baseScenario");
299   }
300
301   @Test
302   public void testComplexVFCScalingScenarioPattern5() throws IOException {
303     /*
304      * 1. Base heat has only nested component and nested has reference to subinterface and
305      * two VFCs of same type
306      * 1. Each server connected with two port
307      * 2. One Port of each server connected to network
308      * 3. Only one port out of four is having sub interface
309      * 4. Sub-interface connected to different network then port
310      */
311     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCScalingScenario");
312   }
313
314   @Test
315   public void testComplexVFCMultiLevelNestedScenarioPattern5() throws IOException {
316     /*
317      * 1. First level nested is having one VFC and one Port with Sub interface
318      * 2. Second level nested is having one VFC and one Port with Sub interface which are of same
319      * type as parent heat file
320      */
321     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedScenario");
322   }
323
324   @Test
325   public void testComplexVFCMultiLevelNestedDiffComputeScenarioPattern5() throws
326       IOException {
327     /*
328      * 1. First level nested is having one VFC and one Port with Sub interface
329      * 2. Second level nested is having one VFC and one Port with Sub interface which are of
330      * different type as parent heat file
331      */
332     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedDiffComputeScenario");
333   }
334
335   @Test
336   public void testComplexVFCMultiComputeInAllHeatPattern5() throws
337       IOException {
338     /*
339      * 1. Main is having 4 VFC of 2 type and 2 port and all having sub interface
340      * 2. Second level nested is having 4 VFC of 2 type and 2 port and all having sub interface
341      */
342     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiVFCInAllHeatScalingScenario");
343   }
344
345   @Test
346   public void testComplexVFCMultiLevelNestedMultiComputeScenarioPattern5() throws
347       IOException {
348     /*
349      * 1. First level nested is having one VFC and one Port with Sub interface
350      * 2. Second level nested is having two VFC of same type and two Port with Sub interface
351      */
352     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCMultiLevelNestedMultiComputeScenario");
353   }
354
355   @Test
356   public void testComplexVFCWithDiffSubInfConnectivityScenarioPattern5() throws IOException {
357     /*
358      * 1. First level nested is having one VFC and one Port with Sub interface
359      * 2. Second level nested is having two VFC of same type and one Port with only one port
360      * connected to Sub interface
361      */
362     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCWithDiffSubInfConnectivityScenario");
363   }
364
365   @Test
366   public void testComplexVFCWithDiffSubInfCountScenarioPattern5() throws IOException {
367     /*
368      * 1. First level nested is having one VFC and one Port with Sub interface
369      * 2. Second level nested is having two VFC of same type and connected to Sub interface but
370      * having different count
371      */
372     testTranslationWithInit(PATTERN_5_BASE_DIRECTORY + "complexVFCWithDiffSubInfCountScenario");
373   }
374
375   //Pattern 4 Test Cases
376   @Test
377   public void testSubInterfaceComputePortNetworkPattern4() throws IOException {
378     /*
379      * Nested Heat file with one compute, one port and one subinterface resource group with only
380      * port connected to network
381      */
382     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "computePortNetworkSubInterface");
383   }
384
385   @Test
386   public void testSubInterfaceMultiplePortsMultipleVlansPattern4() throws IOException {
387     /*
388      * Nested Heat file with one compute, two ports and two subinterface resource groups with
389      * 1. Port connected to network
390      * 2. Sub-interfaces each with different nested files
391      */
392     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multiplePortsMultipleVlans");
393   }
394
395   @Test
396   public void testSubInterfaceMultipleVlanDiffFilePattern4() throws IOException {
397     /*
398      * Nested Heat file with one compute, one port and two subinterface resource groups with
399      * 1. Port connected to network
400      * 2. Sub-interfaces with different nested files
401      */
402     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanDiffFile");
403   }
404
405   @Test
406   public void testSubInterfaceMultipleVlanSameFilePattern4() throws IOException {
407     /*
408      * Nested Heat file with one compute, one port and two subinterface resource groups with
409      * 1. Port connected to network
410      * 2. Sub-interfaces with same nested files
411      */
412     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanSameFile");
413   }
414
415   @Test
416   public void testSubInterfaceRegularNestedPattern4() throws IOException {
417     /*
418      * Nested Heat file with one compute, one port and one subinterface resource represented
419      * through a regular nested resource and not using a resource group
420      */
421     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "regularNestedSubInterface");
422   }
423
424   @Test
425   public void testSubInterfaceGetAttrInOutPattern4() throws IOException {
426     /*
427      * Nested Heat file with one compute, one port and one subinterface resource group with
428      * 1. Port connected to network
429      * 2. Sub-interface connected to different network
430      * 3. Sub-interface has get attribute (in) connectivity from network resource
431      * 4. Sub-interface has get attribute (out) connectivity to second network resource
432      * 5. Sub-interface has get attribute (in) connectivity from output param
433      */
434     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
435   }
436
437   @Test
438   public void testSubInterfaceNodesConnectedInPattern4() throws IOException {
439     /*
440      * Nested Heat file with one compute, one port and one subinterface resource group with
441      * 1. Port connected to network
442      * 2. Sub-interface connected to different network
443      * 3. Sub-interface has depends on (in) connectivity from network resource
444      */
445     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
446   }
447
448   @Test
449   public void testSubInterfaceNodesConnectedOutPattern4() 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(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
457   }
458
459
460   //****************** VFC Instance Group Tests ***************************
461
462   @Test
463   public void testGroupingOneSubInterfaceTypeOneAbstractNode() throws IOException {
464     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "oneSubInterfaceNetworkRole");
465   }
466
467   @Test
468   public void testGroupingOneSubInterfaceTypeAndTwoAbstractNodes() throws IOException {
469     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "oneSubInterfaceNetworkRoleAndTwoAbstractNodes");
470   }
471
472   @Test
473   public void testGroupingTwoSubInterfaceTypeAndTwoAbstractNodes() throws IOException {
474     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "twoSubInterfaceNetworkRoleAndTwoAbstractNodes");
475   }
476
477   @Test
478   public void testSubInterfacePattern4WithGroup() throws IOException {
479     /*
480      * Nested Heat file with one compute, one port and one subinterface resource group with
481      * 1. Port connected to network
482      * 2. Sub-interface connected to same network
483      * 3. Sub-interface has depends on (out) connectivity with network resource
484      */
485     testTranslationWithInit(VFC_INSTANCE_GROUP_BASE_DIRECTORY + "pattern4SubInterfaceNodesConnectedOut");
486   }
487
488 }