860df69927d14db037d7c8fdd10c6839ca83cac6
[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
35   @Test
36   public void testSubInterfaceComputePortNetwork() throws IOException {
37     /**
38      * Heat file with one compute, one port and one subinterface resource group with only port
39      * connected to network
40      */
41     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "computePortNetworkSubInterface");
42   }
43
44   @Test
45   public void testSubInterfaceNodesConnectedOut() throws IOException {
46     /**
47      * Heat file with one compute, one port and one subinterface resource group with
48      * 1. Port connected to network
49      * 2. Sub-interface connected to same network
50      * 3. Sub-interface has depends on (out) connectivity with network resource
51      */
52     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
53   }
54
55   @Test
56   public void testSubInterfaceNodesConnectedIn() throws IOException {
57     /**
58      * Heat file with one compute, one port and one subinterface resource group with
59      * 1. Port connected to network
60      * 2. Sub-interface connected to different network
61      * 3. Sub-interface has depends on (in) connectivity from network resource
62      */
63     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
64   }
65
66   @Test
67   public void testSubInterfaceGetAttrInOut() throws IOException {
68     /**
69      * Heat file with one compute, one port and one subinterface resource group with
70      * 1. Port connected to network
71      * 2. Sub-interface connected to different network
72      * 3. Sub-interface has get attribute (in) connectivity from network resource
73      * 4. Sub-interface has get attribute (out) connectivity to second network resource
74      * 5. Sub-interface has get attribute (in) connectivity from output param
75      */
76     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
77   }
78
79   @Test
80   public void testSubInterfaceMultipleVlanSameNestedFile() throws IOException {
81     /**
82      * Heat file with one compute, one port and two subinterface resource groups with
83      * 1. Port connected to network
84      * 2. Sub-interfaces with same nested files
85      */
86     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanSameType");
87   }
88
89   @Test
90   public void testSubInterfaceMultipleVlanDiffNestedFile() throws IOException {
91     /**
92      * Heat file with one compute, one port and two subinterface resource groups with
93      * 1. Port connected to network
94      * 2. Sub-interfaces with different nested files
95      */
96     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanDiffType");
97   }
98
99   @Test
100   public void testSubInterfaceMultiplePortsMultipleVlans() throws IOException {
101     /**
102      * Heat file with one compute, two ports and two subinterface resource groups with
103      * 1. Port connected to network
104      * 2. Sub-interfaces each with different nested files
105      */
106     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multiplePortsMultipleVlans");
107   }
108
109   @Test
110   public void testSubInterfaceRegularNested() throws IOException {
111     /**
112      * Heat file with one compute, one port and one subinterface resource represented through a
113      * regular nested resource and not using a resource group
114      */
115     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "regularNestedSubInterface");
116   }
117
118   @Test
119   public void testSubInterfaceNotBoundToPort() throws IOException {
120     /**
121      * Heat file with one compute, one port and one subinterface resource group with
122      * 1. Resource group missing virtual_machine_interface_refs property
123      * 2. Resource group missing virtual_machine_interface_properties_sub_interface_vlan_tag
124      *    property
125      * 3. Resource group parent port as get_param
126      */
127     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "notBoundToParentPort");
128   }
129
130   //Pattern 1B test
131   @Test
132   public void testDiffComputeSubInterface() throws IOException {
133     /**
134      * Heat file with one compute, one port and one subinterface resource group with
135      * 1. There are two compute both of different type
136      */
137     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "diffComputeSubInterface");
138   }
139
140   @Test
141   public void testOnePortIsConnectedWithSubInf() throws IOException {
142     /**
143      * Heat file with one compute, one port and one subinterface resource group with
144      * 1. Two compute of same type
145      * 2. Two port of same type but only one of them is having sub interface binding
146      */
147     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "onePortIsConnectedWithSubInf");
148   }
149
150   @Test
151   public void testRegularNestedSubInterface() throws IOException {
152     /**
153      * Heat file with one compute, one port and one sub interface without resource group
154      * 1. Two compute of same type
155      * 2. Two port are of different type
156      * 3. Sub interface properties are same in both port
157      */
158     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "regularNestedSubInterface");
159   }
160
161   @Test
162   public void testSameComputeDiffPortSubInterface() throws IOException {
163     /**
164      * Heat file with one compute, one port and one subinterface resource group with
165      * 1. Two compute of same type
166      * 2. Two port are of different type
167      * 3. Sub interface properties are same in both port
168      */
169     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeDiffPortSubInterface");
170   }
171
172   @Test
173   public void testSameComputeSamePortDiffSubInterfaceFile() throws IOException {
174     /**
175      * Heat file with one compute, one port and one subinterface resource group with
176      * 1. Two compute of same type
177      * 2. Two port are of same type connected with different sub interface nested file
178      * 3. Sub interface property are same for both port
179      */
180     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY
181         + "sameComputeSamePortDiffSubInterfaceFile");
182   }
183
184   //****************** PATTERN 1C1 Tests ***************************
185
186   @Test
187   public void testSubInterfaceScalingOnePortVlanSameType() throws IOException {
188     /**
189      * Heat file with two computes of same type, two ports of same type and two subinterface resource groups of same
190      * type with
191      * 1. Compute has one port each
192      * 2. Port has one sub-interface each
193      * 3. Port connected to network
194      * 3. Sub-interface not connected to network
195      */
196     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "onePortVlanSameType");
197   }
198
199   @Test
200   public void testSubInterfaceScalingMultiplePortsMultipleVlans() throws IOException {
201     /**
202      * Heat file with two computes of different type, four ports of two types each and four subinterface resource groups
203      * of two types each
204      * 1. Each compute has two ports, one of each type
205      * 2. Port has one sub-interface each
206      * 3. Ports connected to different networks
207      * 4. Sub-interface of one type connected to network
208      */
209     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "multiplePortsMultipleVlans");
210   }
211
212   @Test
213   public void testSubInterfaceScalingOptionalPropertiesConsolidation() throws IOException {
214     /**
215      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
216      * of same type
217      * 1. Each compute has two ports, one of each type
218      * 2. One of the ports has a subinterface
219      * 3. Ports connected to network
220      * 4. Subinterfaces not connected to network
221      * 5. Optional properties contained in one subinterface and not in other
222      */
223     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "optionalPropertiesConsolidation");
224   }
225
226   @Test
227   public void testSubInterfaceScalingRegularNestedSubInterface() throws IOException {
228     /**
229      * Heat file with two computes, two ports of same type connected to network and two subinterface resource
230      * represented through a regular nested resource and not using a resource group not connected to network
231      */
232     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "regularNestedSubInterface");
233   }
234
235   @Test
236   public void testSubInterfaceScalingAllConnectivities() throws IOException {
237     /**
238      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
239      * of same type
240      * 1. Each compute has two ports, one of each type
241      * 2. One of the ports has a subinterface
242      * 3. Port connected to network
243      * 4. Both ports and subinterfaces connected to network
244      * 5. All connectivities including dependency, get attribute from nodes and output param
245      */
246     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "allConnectivities");
247   }
248
249   //Pattern 4 Test Cases
250   @Test
251   public void testSubInterfaceComputePortNetworkPattern4() throws IOException {
252     /**
253      * Nested Heat file with one compute, one port and one subinterface resource group with only
254      * port connected to network
255      */
256     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY +
257         "computePortNetworkSubInterface");
258   }
259
260   @Test
261   public void testSubInterfaceMultiplePortsMultipleVlansPattern4() throws IOException {
262     /**
263      * Nested Heat file with one compute, two ports and two subinterface resource groups with
264      * 1. Port connected to network
265      * 2. Sub-interfaces each with different nested files
266      */
267     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multiplePortsMultipleVlans");
268   }
269
270   @Test
271   public void testSubInterfaceMultipleVlanDiffFilePattern4() throws IOException {
272     /**
273      * Nested Heat file with one compute, one port and two subinterface resource groups with
274      * 1. Port connected to network
275      * 2. Sub-interfaces with different nested files
276      */
277     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanDiffFile");
278   }
279
280   @Test
281   public void testSubInterfaceMultipleVlanSameFilePattern4() throws IOException {
282     /**
283      * Nested Heat file with one compute, one port and two subinterface resource groups with
284      * 1. Port connected to network
285      * 2. Sub-interfaces with same nested files
286      */
287     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "multipleVlanSameFile");
288   }
289
290   @Test
291   public void testSubInterfaceRegularNestedPattern4() throws IOException {
292     /**
293      * Nested Heat file with one compute, one port and one subinterface resource represented
294      * through a regular nested resource and not using a resource group
295      */
296     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "regularNestedSubInterface");
297   }
298
299   @Test
300   public void testSubInterfaceGetAttrInOutPattern4() throws IOException {
301     /**
302      * Nested Heat file with one compute, one port and one subinterface resource group with
303      * 1. Port connected to network
304      * 2. Sub-interface connected to different network
305      * 3. Sub-interface has get attribute (in) connectivity from network resource
306      * 4. Sub-interface has get attribute (out) connectivity to second network resource
307      * 5. Sub-interface has get attribute (in) connectivity from output param
308      */
309     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
310   }
311
312   @Test
313   public void testSubInterfaceNodesConnectedInPattern4() throws IOException {
314     /**
315      * Nested Heat file with one compute, one port and one subinterface resource group with
316      * 1. Port connected to network
317      * 2. Sub-interface connected to different network
318      * 3. Sub-interface has depends on (in) connectivity from network resource
319      */
320     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
321   }
322
323   @Test
324   public void testSubInterfaceNodesConnectedOutPattern4() throws IOException {
325     /**
326      * Nested Heat file with one compute, one port and one subinterface resource group with
327      * 1. Port connected to network
328      * 2. Sub-interface connected to same network
329      * 3. Sub-interface has depends on (out) connectivity with network resource
330      */
331     testTranslationWithInit(PATTERN_4_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
332   }
333 }