4b22e66f6b90d8f24bc67fabba4e343ca3756ab6
[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
33   @Test
34   public void testSubInterfaceComputePortNetwork() throws IOException {
35     /**
36      * Heat file with one compute, one port and one subinterface resource group with only port
37      * connected to network
38      */
39     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "computePortNetworkSubInterface");
40   }
41
42   @Test
43   public void testSubInterfaceNodesConnectedOut() throws IOException {
44     /**
45      * Heat file with one compute, one port and one subinterface resource group with
46      * 1. Port connected to network
47      * 2. Sub-interface connected to same network
48      * 3. Sub-interface has depends on (out) connectivity with network resource
49      */
50     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedOut");
51   }
52
53   @Test
54   public void testSubInterfaceNodesConnectedIn() throws IOException {
55     /**
56      * Heat file with one compute, one port and one subinterface resource group with
57      * 1. Port connected to network
58      * 2. Sub-interface connected to different network
59      * 3. Sub-interface has depends on (in) connectivity from network resource
60      */
61     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceNodesConnectedIn");
62   }
63
64   @Test
65   public void testSubInterfaceGetAttrInOut() throws IOException {
66     /**
67      * Heat file with one compute, one port and one subinterface resource group with
68      * 1. Port connected to network
69      * 2. Sub-interface connected to different network
70      * 3. Sub-interface has get attribute (in) connectivity from network resource
71      * 4. Sub-interface has get attribute (out) connectivity to second network resource
72      * 5. Sub-interface has get attribute (in) connectivity from output param
73      */
74     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "subInterfaceGetAttrInOut");
75   }
76
77   @Test
78   public void testSubInterfaceMultipleVlanSameNestedFile() throws IOException {
79     /**
80      * Heat file with one compute, one port and two subinterface resource groups with
81      * 1. Port connected to network
82      * 2. Sub-interfaces with same nested files
83      */
84     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanSameType");
85   }
86
87   @Test
88   public void testSubInterfaceMultipleVlanDiffNestedFile() throws IOException {
89     /**
90      * Heat file with one compute, one port and two subinterface resource groups with
91      * 1. Port connected to network
92      * 2. Sub-interfaces with different nested files
93      */
94     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multipleVlanDiffType");
95   }
96
97   @Test
98   public void testSubInterfaceMultiplePortsMultipleVlans() throws IOException {
99     /**
100      * Heat file with one compute, two ports and two subinterface resource groups with
101      * 1. Port connected to network
102      * 2. Sub-interfaces each with different nested files
103      */
104     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "multiplePortsMultipleVlans");
105   }
106
107   @Test
108   public void testSubInterfaceRegularNested() throws IOException {
109     /**
110      * Heat file with one compute, one port and one subinterface resource represented through a
111      * regular nested resource and not using a resource group
112      */
113     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "regularNestedSubInterface");
114   }
115
116   @Test
117   public void testSubInterfaceNotBoundToPort() throws IOException {
118     /**
119      * Heat file with one compute, one port and one subinterface resource group with
120      * 1. Resource group missing virtual_machine_interface_refs property
121      * 2. Resource group missing virtual_machine_interface_properties_sub_interface_vlan_tag
122      *    property
123      * 3. Resource group parent port as get_param
124      */
125     testTranslationWithInit(PATTERN_1A_BASE_DIRECTORY + "notBoundToParentPort");
126   }
127
128   //Pattern 1B test
129   @Test
130   public void testDiffComputeSubInterface() throws IOException {
131     /**
132      * Heat file with one compute, one port and one subinterface resource group with
133      * 1. There are two compute both of different type
134      */
135     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "diffComputeSubInterface");
136   }
137
138   @Test
139   public void testOnePortIsConnectedWithSubInf() throws IOException {
140     /**
141      * Heat file with one compute, one port and one subinterface resource group with
142      * 1. Two compute of same type
143      * 2. Two port of same type but only one of them is having sub interface binding
144      */
145     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "onePortIsConnectedWithSubInf");
146   }
147
148   @Test
149   public void testRegularNestedSubInterface() throws IOException {
150     /**
151      * Heat file with one compute, one port and one sub interface without resource group
152      * 1. Two compute of same type
153      * 2. Two port are of different type
154      * 3. Sub interface properties are same in both port
155      */
156     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "regularNestedSubInterface");
157   }
158
159   @Test
160   public void testSameComputeDiffPortSubInterface() throws IOException {
161     /**
162      * Heat file with one compute, one port and one subinterface resource group with
163      * 1. Two compute of same type
164      * 2. Two port are of different type
165      * 3. Sub interface properties are same in both port
166      */
167     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY + "sameComputeDiffPortSubInterface");
168   }
169
170   @Test
171   public void testSameComputeSamePortDiffSubInterfaceFile() throws IOException {
172     /**
173      * Heat file with one compute, one port and one subinterface resource group with
174      * 1. Two compute of same type
175      * 2. Two port are of same type connected with different sub interface nested file
176      * 3. Sub interface property are same for both port
177      */
178     testTranslationWithInit(PATTERN_1B_BASE_DIRECTORY
179         + "sameComputeSamePortDiffSubInterfaceFile");
180   }
181
182   //****************** PATTERN 1C1 Tests ***************************
183
184   @Test
185   public void testSubInterfaceScalingOnePortVlanSameType() throws IOException {
186     /**
187      * Heat file with two computes of same type, two ports of same type and two subinterface resource groups of same
188      * type with
189      * 1. Compute has one port each
190      * 2. Port has one sub-interface each
191      * 3. Port connected to network
192      * 3. Sub-interface not connected to network
193      */
194     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "onePortVlanSameType");
195   }
196
197   @Test
198   public void testSubInterfaceScalingMultiplePortsMultipleVlans() throws IOException {
199     /**
200      * Heat file with two computes of different type, four ports of two types each and four subinterface resource groups
201      * of two types each
202      * 1. Each compute has two ports, one of each type
203      * 2. Port has one sub-interface each
204      * 3. Ports connected to different networks
205      * 4. Sub-interface of one type connected to network
206      */
207     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "multiplePortsMultipleVlans");
208   }
209
210   @Test
211   public void testSubInterfaceScalingOptionalPropertiesConsolidation() throws IOException {
212     /**
213      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
214      * of same type
215      * 1. Each compute has two ports, one of each type
216      * 2. One of the ports has a subinterface
217      * 3. Ports connected to network
218      * 4. Subinterfaces not connected to network
219      * 5. Optional properties contained in one subinterface and not in other
220      */
221     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "optionalPropertiesConsolidation");
222   }
223
224   @Test
225   public void testSubInterfaceScalingRegularNestedSubInterface() throws IOException {
226     /**
227      * Heat file with two computes, two ports of same type connected to network and two subinterface resource
228      * represented through a regular nested resource and not using a resource group not connected to network
229      */
230     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "regularNestedSubInterface");
231   }
232
233   @Test
234   public void testSubInterfaceScalingAllConnectivities() throws IOException {
235     /**
236      * Heat file with two computes of same type, four ports of two types each and two subinterface resource groups
237      * of same type
238      * 1. Each compute has two ports, one of each type
239      * 2. One of the ports has a subinterface
240      * 3. Port connected to network
241      * 4. Both ports and subinterfaces connected to network
242      * 5. All connectivities including dependency, get attribute from nodes and output param
243      */
244     testTranslationWithInit(PATTERN_1C1_BASE_DIRECTORY + "allConnectivities");
245   }
246 }