1 package vid.automation.test.test;
3 import com.google.common.collect.ImmutableMap;
4 import java.util.HashMap;
6 import org.junit.Assert;
7 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
8 import org.openqa.selenium.WebElement;
9 import org.testng.annotations.Test;
10 import vid.automation.test.Constants;
11 import vid.automation.test.Constants.RegisterToSimulator.CreateNewServiceInstance;
12 import vid.automation.test.infra.Exists;
13 import vid.automation.test.infra.Features;
14 import vid.automation.test.infra.Get;
15 import vid.automation.test.infra.Wait;
16 import vid.automation.test.sections.CreateConfigurationPage;
17 import vid.automation.test.sections.ServiceProxyPage;
18 import vid.automation.test.sections.VidBasePage;
19 import vid.automation.test.sections.ViewEditPage;
20 import vid.automation.test.services.BulkRegistration;
21 import vid.automation.test.services.SimulatorApi;
22 import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
24 public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
26 private ViewEditPage viewEditPage = new ViewEditPage();
27 private CreateConfigurationPage createConfigurationPage = new CreateConfigurationPage();
28 private ServiceProxyPage serviceProxyPage = new ServiceProxyPage();
29 private String serviceInstanceId = "c187e9fe-40c3-4862-b73e-84ff056205f6";
30 private String serviceInstanceId_vidTest444 = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
31 private String policyConfigurationModelName_0 = "Port Mirroring Configuration 0";
32 private String policyConfigurationModelName_1 = "Port Mirroring Configuration By Policy 1";
33 private String pnfInstanceName = "AS-pnf2-10219--as988q";
34 private String pnfServiceType = "DARREN MCGEE";
35 private String vnfServiceType = "TYLER SILVIA";
36 private String sourceSubscriberName = "SILVIA ROBBINS";
37 private String sourceServiceTypeFromCar2020 = "MSO-dev-service-type";
38 private String sourceSubscriberNameCar2020 = "CAR_2020_ER";
40 private String defaultCollectorServiceType = "TYLER SILVIA";
41 private String vnfInstanceName = "zhvf6aepdg01";
42 private String active = "Active";
43 private String desiredCloudRegionId = "mdt1";
46 private boolean featureFlagLetsSelectingCollector() {
47 return Features.FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY.isActive();
50 private boolean featureFlagLetSelectingSourceSubscriber() {
51 return Features.FLAG_2006_PORT_MIRRORING_LET_SELECTING_SOURCE_SUBSCRIBER.isActive();
54 private String expectedPnfCollectorServiceType() {
55 return (featureFlagLetsSelectingCollector() ? pnfServiceType : defaultCollectorServiceType).replace(" ", "%20");
59 public void testCreatePolicyConfiguration() {
60 SimulatorApi.clearAll();
61 BulkRegistration.searchExistingServiceInstancePortMirroring("Active", "mdt1");
62 BulkRegistration.getNetworkNodeFormData();
63 BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType());
65 navigateToViewEditPageOf_test_sssdad();
66 selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
68 createConfigurationPage.clickNextButton();
69 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
71 createConfigurationPage.clickBackButton();
73 createConfigurationPage.clickNextButton();
75 //assert service proxy models (circles) names
76 serviceProxyPage.assertSourceModelName("vflorenceService2 Service Proxy");
77 serviceProxyPage.assertCollectorModelName("pProbeService Service Proxy");
79 //assert service proxy models metadata
80 assertMetadataModal(Constants.ConfigurationCreation.SOURCE_INFO_BUTTON_TEST_ID, getSourceServiceProxyExpectedMetadata());
81 assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, getCollectorServiceProxyExpectedMetadata());
83 //select source & collector
84 if (featureFlagLetsSelectingCollector()) {
85 serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
86 serviceProxyPage.chooseCollectorServiceType(pnfServiceType);
88 serviceProxyPage.chooseCollector(pnfInstanceName);
89 serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID);
91 serviceProxyPage.chooseSourceServiceType(vnfServiceType);
92 serviceProxyPage.chooseSource(vnfInstanceName);
93 serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.SOURCE_INSTANCE_SELECTED_ICON_TEST_ID);
95 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
96 serviceProxyPage.clickCreateButton();
97 serviceProxyPage.assertButtonStateEvenIfButtonNotVisible(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
98 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
99 serviceProxyPage.clickCloseButton();
101 //assert redirect back to view/edit
102 GeneralUIUtils.ultimateWait();
103 Assert.assertTrue(Exists.byTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID));
108 public void testDeletePolicyConfiguration() {
109 SimulatorApi.clearAll();
110 BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
111 BulkRegistration.getNetworkNodeFormData();
112 BulkRegistration.deletePolicyConfiguration(true);
113 navigateToViewEditPageOf_test_sssdad();
114 serviceProxyPage.clickDeleteConfigurationButton();
115 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
119 public void testConfigurationCreatedPortEnabled(){
120 SimulatorApi.clearAll();
121 BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
122 BulkRegistration.getNetworkNodeFormData();
123 BulkRegistration.activateDeactivateConfiguration("deactivate");
124 navigateToViewEditPageOf_test_sssdad();
125 WebElement isPortEnableButtonExists = Get.byTestId("enableDisableButton");
126 Assert.assertNull(isPortEnableButtonExists);
130 public void testDisablePort() {
131 enableDisablePortPresets(active, true);
132 BulkRegistration.enableDisablePort("disablePort");
133 navigateToViewEditPageOf_test_sssdad();
134 serviceProxyPage.clickEnableDisableButton();
135 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
139 public void testEnablePort() {
140 enableDisablePortPresets(active, false);
141 BulkRegistration.enableDisablePort("enablePort");
142 navigateToViewEditPageOf_test_sssdad();
143 serviceProxyPage.clickEnableDisableButton();
144 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
150 private void enableDisablePortPresets(String orchStatus, boolean isMirrored){
151 SimulatorApi.clearAll();
152 BulkRegistration.searchExistingServiceInstancePortMirroring(orchStatus, isMirrored, desiredCloudRegionId);
153 BulkRegistration.getNetworkNodeFormData();
159 public void testActivateConfigurationTest(){
160 SimulatorApi.clearAll();
161 BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
162 BulkRegistration.getNetworkNodeFormData();
163 BulkRegistration.activateDeactivateConfiguration("activate");
164 navigateToViewEditPageOf_test_sssdad();
165 serviceProxyPage.assertDeleteConfigurationButtonExists(true);
166 serviceProxyPage.clickActivateDeactivateButton();
167 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
172 public void testDeleteConfigurationTest(){
173 SimulatorApi.clearAll();
174 BulkRegistration.searchExistingServiceInstancePortMirroring("Created", desiredCloudRegionId);
175 BulkRegistration.getNetworkNodeFormData();
176 BulkRegistration.deleteConfiguration();
177 navigateToViewEditPageOf_test_sssdad();
178 serviceProxyPage.clickDeleteConfigurationButton();
179 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
184 public void testDeactivateConfigurationTest(){
185 SimulatorApi.clearAll();
186 BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
187 BulkRegistration.getNetworkNodeFormData();
188 BulkRegistration.activateDeactivateConfiguration("deactivate");
189 navigateToViewEditPageOf_test_sssdad();
190 serviceProxyPage.assertDeleteConfigurationButtonExists(false);
191 serviceProxyPage.clickActivateDeactivateButton();
192 serviceProxyPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
198 public void testCreatePortMirroringConfiguration() {
199 SimulatorApi.clearAll();
200 BulkRegistration.searchExistingServiceInstance();
201 BulkRegistration.getNetworkNodeFormData();
202 BulkRegistration.createPolicyConfiguration(true, expectedPnfCollectorServiceType());
203 BulkRegistration.createConfiguration(
204 "model-version-id=7482279e-5901-492f-a963-6331aa6b995e&model-invariant-id=f2ae9911-95c4-40d0-8908-0175c206ab2d");
206 String alternateVnfInstanceName = "andromeda";
208 if (featureFlagLetSelectingSourceSubscriber()) {
209 SimulatorApi.registerExpectation(
210 CreateNewServiceInstance.GET_SUBSCRIBERS_FOR_CUSTOMER_CAR_2020_ER, RegistrationStrategy.APPEND);
212 SimulatorApi.registerExpectation(
213 Constants.RegisterToSimulator.createConfiguration.GET_VNF_INSTANCES,
215 "e433710f-9217-458d-a79d-1c7aff376d89", sourceSubscriberNameCar2020,
216 "TYLER%20SILVIA", sourceServiceTypeFromCar2020,
217 "model-version-id=2a2ea15f-07c6-4b89-bfca-e8aba39a34d6", "model-version-id=7482279e-5901-492f-a963-6331aa6b995e",
218 "model-invariant-id=a7eac2b3-8444-40ee-92e3-b3359b32445c", "model-invariant-id=f2ae9911-95c4-40d0-8908-0175c206ab2d",
219 vnfInstanceName, alternateVnfInstanceName
221 RegistrationStrategy.APPEND
225 navigateToViewEditPageOfuspVoiceVidTest444("240376de-870e-48df-915a-31f140eedd2c");
226 selectConfigurationNode(policyConfigurationModelName_0, ImmutableMap.<String, String>builder()
227 .put(Constants.ServiceModelInfo.SERVIICE_NAME_KEY, "Demo Service 1")
228 .put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration")
229 .put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "vid-test-444")
230 .put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "5dd839fa-5e09-47d4-aa5c-5ba62161b569")
231 .put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS")
232 .put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0")
233 .put(Constants.ServiceModelInfo.MODEL_UUID, "9d6b09b1-7527-49b1-b6cf-398cb67c5523")
234 .put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "3db39baa-35bc-4b97-b199-44e758823502")
235 .put(Constants.ServiceModelInfo.RESOURCE_NAME, policyConfigurationModelName_0)
238 createConfigurationPage.clickNextButton();
239 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
241 createConfigurationPage.clickBackButton();
243 createConfigurationPage.clickNextButton();
245 //assert service proxy models (circles) names
246 serviceProxyPage.assertSourceModelName("Service 1 Service Proxy");
247 serviceProxyPage.assertCollectorModelName("Service 1 Service Proxy");
249 //assert service proxy models metadata
250 final ImmutableMap<String, String> expectedMetadata = ImmutableMap.<String, String>builder()
251 .put(Constants.ServiceProxyModelInfo.MODEL_NAME, "Service 1 Service Proxy")
252 .put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "2.0")
253 .put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service Service 1")
254 .put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy")
255 .put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "0aaefad3-9409-4ab1-be00-a1571e8a0545")
256 .put(Constants.ServiceProxyModelInfo.MODEL_UUID, "8685fd6a-c0b1-40f7-be94-ab232e4424c1")
257 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "7482279e-5901-492f-a963-6331aa6b995e")
258 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "f2ae9911-95c4-40d0-8908-0175c206ab2d")
259 .put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "Service 1")
261 assertMetadataModal(Constants.ConfigurationCreation.SOURCE_INFO_BUTTON_TEST_ID, expectedMetadata);
262 assertMetadataModal(Constants.ConfigurationCreation.COLLECTOR_INFO_BUTTON_TEST_ID, expectedMetadata);
264 //select source & collector
265 serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
266 if(featureFlagLetSelectingSourceSubscriber()){
267 //assert default Source Subscriber Name, choose another Source Subscriber, choose Source Service Type for chosen subscriber
268 serviceProxyPage.assertSourceSubscriberName(sourceSubscriberName);
269 serviceProxyPage.chooseSourceSubscriberName(sourceSubscriberNameCar2020);
270 serviceProxyPage.chooseSourceServiceType(sourceServiceTypeFromCar2020);
271 serviceProxyPage.chooseSource(alternateVnfInstanceName);
272 serviceProxyPage.chooseSourceSubscriberName(sourceSubscriberName);
274 serviceProxyPage.chooseCollectorServiceType(vnfServiceType);
275 serviceProxyPage.chooseCollector(vnfInstanceName);
276 serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID);
278 serviceProxyPage.chooseSourceServiceType(vnfServiceType);
279 serviceProxyPage.chooseSource(vnfInstanceName);
280 serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.SOURCE_INSTANCE_SELECTED_ICON_TEST_ID);
282 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
286 public void testRainyCreatePolicyConfiguration() {
288 SimulatorApi.clearAll();
289 BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
290 BulkRegistration.getNetworkNodeFormData();
291 BulkRegistration.createPolicyConfiguration(false, expectedPnfCollectorServiceType());
293 navigateToViewEditPageOf_test_sssdad();
294 selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
296 createConfigurationPage.clickNextButton();
297 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
299 //select source & collector
300 if (featureFlagLetsSelectingCollector()) {
301 serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
302 serviceProxyPage.chooseCollectorServiceType(pnfServiceType);
304 serviceProxyPage.chooseCollector(pnfInstanceName);
305 serviceProxyPage.chooseSourceServiceType(vnfServiceType);
306 serviceProxyPage.chooseSource(vnfInstanceName);
307 serviceProxyPage.clickCreateButton();
308 serviceProxyPage.assertMsoRequestModal("Error");
309 serviceProxyPage.clickCloseButton();
310 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,true);
314 public void testRainyNoResultsInDropdowns(){
315 SimulatorApi.clearAll();
316 BulkRegistration.searchExistingServiceInstancePortMirroring("Active", desiredCloudRegionId);
317 BulkRegistration.getNetworkNodeFormData();
318 //not register createPolicyConfiguration for no results in DDLs
320 navigateToViewEditPageOf_test_sssdad();
321 selectConfigurationNode(policyConfigurationModelName_1, getConfigurationExpectedMetadata());
323 createConfigurationPage.clickNextButton();
324 serviceProxyPage.assertButtonState(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID,false);
325 //source & collector should be empty
326 serviceProxyPage.chooseSourceServiceType(vnfServiceType);
327 serviceProxyPage.noOptionDropdownByTestId(Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
328 serviceProxyPage.noOptionDropdownByTestId(Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID);
329 //error message no instance found
330 serviceProxyPage.assertNoResultRequirementsDropDown(Constants.ConfigurationCreation.COLLECTOR_NO_RESULT_MSG_TEST_ID,"pnf");
331 serviceProxyPage.assertNoResultRequirementsDropDown(Constants.ConfigurationCreation.SOURCE_NO_RESULT_MSG_TEST_ID,"vnf");
334 private void selectConfigurationNode(String name, Map<String, String> configurationExpectedMetadata){
335 viewEditPage.selectNodeInstanceToAdd(name);
336 assertModelInfo(configurationExpectedMetadata,true);
337 createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID, false);
341 public void assertMetadataModal(String btnTestId, Map<String, String> expectedMetadata) {
342 serviceProxyPage.clickInfoButton(btnTestId);
343 assertModelInfo(expectedMetadata, true);
344 serviceProxyPage.clickCloseButton();
345 Wait.modalToDisappear();
348 private void fillAllFormFields() {
349 createConfigurationPage.setInstanceName("dummy_instance");
350 createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.TENANT_DROPDOWN_TEST_ID,false);
351 VidBasePage vidBasePage = new VidBasePage();
352 vidBasePage.selectLcpRegion("AAIAIC25", "AIC");
353 GeneralUIUtils.ultimateWait();
354 createConfigurationPage.chooseTenant("USP-SIP-IC-24335-T-01");
355 createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID,true);
357 private void assertFormFields() {
358 Assert.assertEquals("dummy_instance",createConfigurationPage.getInstanceName());
359 Assert.assertEquals("AAIAIC25 (AIC)", createConfigurationPage.getRegion());
360 Assert.assertEquals("USP-SIP-IC-24335-T-01",createConfigurationPage.getTenant());
362 createConfigurationPage.assertButtonState(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID,true);
365 private Map<String, String> getConfigurationExpectedMetadata() {
366 return new HashMap<String, String>(){
368 put(Constants.ServiceModelInfo.SERVIICE_NAME_KEY, "ServiceContainerMultiplepProbes");
369 put(Constants.ServiceModelInfo.MODEL_NAME, "Port Mirroring Configuration By Policy");
370 put(Constants.ServiceModelInfo.SERVICE_INSTANCE_NAME, "test_sssdad");
371 put(Constants.ServiceModelInfo.MODEL_INVARIANT_UUID, "c30a024e-a6c6-4670-b73c-3df64eb57ff6");
372 put(Constants.ServiceModelInfo.SUBSCRIBER_NAME_KEY, "SILVIA ROBBINS");
373 put(Constants.ServiceModelInfo.MODEL_VERSION, "1.0");
374 put(Constants.ServiceModelInfo.MODEL_UUID, "f58d039d-4cfc-40ec-bd75-1f05f0458a6c");
375 put(Constants.ServiceModelInfo.MODEL_CUSTOMIZATION_UUID, "4b7ebace-bad6-4526-9be6-bf248e20fc5f");
376 put(Constants.ServiceModelInfo.RESOURCE_NAME, policyConfigurationModelName_1);
381 private Map<String, String> getSourceServiceProxyExpectedMetadata() {
382 return new HashMap<String, String>(){
384 put(Constants.ServiceProxyModelInfo.MODEL_NAME, "vflorenceService2 Service Proxy");
385 put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "1.0");
386 put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service vflorenceService2");
387 put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy");
388 put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "2933b574-d28d-45ea-bf22-4df2907e4a10");
389 put(Constants.ServiceProxyModelInfo.MODEL_UUID, "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee");
390 put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "060be63d-5f9c-4fd0-8ef7-830d5e8eca17");
391 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6");
392 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "a7eac2b3-8444-40ee-92e3-b3359b32445c");
393 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "vflorenceService2");
398 private Map<String, String> getCollectorServiceProxyExpectedMetadata() {
399 return new HashMap<String, String>(){
401 put(Constants.ServiceProxyModelInfo.MODEL_NAME, "pProbeService Service Proxy");
402 put(Constants.ServiceProxyModelInfo.MODEL_VERSION, "1.0");
403 put(Constants.ServiceProxyModelInfo.MODEL_DESCRIPTION, "A Proxy for Service pProbeService");
404 put(Constants.ServiceProxyModelInfo.MODEL_TYPE, "Service Proxy");
405 put(Constants.ServiceProxyModelInfo.MODEL_INVARIANT_UUID, "2933b574-d28d-45ea-bf22-4df2907e4a10");
406 put(Constants.ServiceProxyModelInfo.MODEL_UUID, "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee");
407 put(Constants.ServiceProxyModelInfo.MODEL_CUSTOMIZATION_UUID, "d64623ae-5935-4afd-803e-c86e94d8e740");
408 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_UUID, "8a84e59b-45fe-4851-8ff1-34225a0b32c3");
409 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_INVARIANT, "83b458fd-5dd3-419b-a9e3-7335814a0911");
410 put(Constants.ServiceProxyModelInfo.SOURCE_MODEL_NAME, "pProbeService");