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