1 package vid.automation.test.test;
3 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
4 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_NAME;
5 import static org.testng.Assert.assertEquals;
6 import static org.testng.AssertJUnit.assertTrue;
7 import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON;
8 import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION;
10 import com.google.common.collect.ImmutableMap;
11 import java.util.Collections;
12 import org.junit.Assert;
13 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
14 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
15 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
16 import org.onap.vid.api.AsyncInstantiationBase;
17 import org.onap.vid.api.CreateServiceWithFailedVnf;
18 import org.onap.vid.api.TestUtils;
19 import org.openqa.selenium.By;
20 import org.openqa.selenium.WebElement;
21 import org.testng.annotations.AfterClass;
22 import org.testng.annotations.BeforeClass;
23 import org.testng.annotations.Test;
24 import vid.automation.test.Constants;
25 import vid.automation.test.infra.Click;
26 import vid.automation.test.infra.FeatureTogglingTest;
27 import vid.automation.test.infra.Features;
28 import vid.automation.test.infra.Get;
29 import vid.automation.test.infra.Wait;
30 import vid.automation.test.sections.DrawingBoardPage;
31 import vid.automation.test.sections.InstantiationStatusPage;
32 import vid.automation.test.sections.SideMenu;
33 import vid.automation.test.sections.VidBasePage;
34 import vid.automation.test.services.AsyncJobsService;
36 @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION)
37 public class InstantiationStatusTest extends VidBaseTestCase {
39 private final String serviceModelVersion = "5.1";
40 private final String regionId = "a93f8383-707e-43fa-8191-a6e69a1aab17";
41 final static String owningEntityName = "Lucine Sarika";
42 final static String subscriberName = "SILVIA ROBBINS";
43 private static final String COMPLETED = "COMPLETED";
44 private static final String CREATE_BULK_OF_ALACARTE_REQUEST = "asyncInstantiation/vidRequestCreateALaCarte.json";
45 private final VidBasePage vidBasePage = new VidBasePage();
47 private AsyncInstantiationBase asyncInstantiationBase;
50 protected void dropAllAsyncJobs() {
51 AsyncJobsService asyncJobsService = new AsyncJobsService();
52 asyncJobsService.dropAllAsyncJobs();
53 asyncInstantiationBase = new AsyncInstantiationBase();
54 asyncInstantiationBase.init();
55 UserCredentials userCredentials = getUserCredentials();
56 //login for API test (needed besides selenium test via browser)
57 asyncInstantiationBase.login(userCredentials);
61 protected void muteAllAsyncJobs() {
62 AsyncJobsService asyncJobsService = new AsyncJobsService();
63 asyncJobsService.muteAllAsyncJobs();
66 private String addOneJob() {
67 String serviceName = TestUtils.generateRandomAlphaNumeric(8);
68 final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names =
69 ImmutableMap.of(SERVICE_NAME, serviceName);
70 asyncInstantiationBase.createBulkOfInstances(false, 1, names, CREATE_BULK_OF_ALACARTE_REQUEST).get(0);
75 public void testServiceInfoIsPresentedInTable() {
76 String serviceName = addOneJob();
77 SideMenu.navigateToMacroInstantiationStatus();
78 InstantiationStatusPage.clickRefreshButton();
80 InstantiationStatusPage.assertInstantiationStatusRow(serviceName, ImmutableMap.of(
81 "subscriberName", subscriberName,
83 "serviceModelVersion", serviceModelVersion,
84 "owningEntityName", owningEntityName
89 public void testServiceInfoDataUpdatingAfterClickRefresh() {
91 SideMenu.navigateToMacroInstantiationStatus();
92 InstantiationStatusPage.clickRefreshButton();
93 long numberOfRows = InstantiationStatusPage.getNumberOfTableRows(60);
96 InstantiationStatusPage.clickRefreshButton();
97 int numberOfRowsAfterRefresh = InstantiationStatusPage.getNumberOfTableRows(60);
98 Assert.assertEquals(numberOfRows + 1 , numberOfRowsAfterRefresh);
102 @FeatureTogglingTest(Features.FLAG_1902_RETRY_JOB)
103 public void testRedeployFromDrawingBoardOfServiceWithFailedVnf() {
104 SideMenu.navigateToMacroInstantiationStatus();
106 CreateServiceWithFailedVnf createServiceWithFailedVnf = createServiceWithFailedVnfAssertStausAndSimulatorRegistration();
107 String originalServiceName = createServiceWithFailedVnf.getNames().get(SERVICE_NAME);
109 InstantiationStatusPage.clickRefreshButton();
112 InstantiationStatusPage.openDrawingBoardForRetry(originalServiceName);
113 DrawingBoardPage.goToIframe();
115 Wait.waitByTestId("error-msg-wrapper", 10);
116 boolean isErrorShown = Wait.waitByClassAndText("sub-title", "Attention: You are currently viewing instances from the MSO. 1 of the instances failed, please try again.", 10);
117 assertTrue(isErrorShown);
119 //validate audit info for failed vnf
120 String originalVnfName = createServiceWithFailedVnf.getNames().get(VNF_NAME);
121 hoverAndClickMenuByName(originalVnfName, "fe042c22-ba82-43c6-b2f6-8f1fc4164091-vSAMP12 1", Constants.DrawingBoard.CONTEXT_MENU_SHOW_AUDIT);
122 checkFailedAuditInfoOnRetry(originalVnfName, createServiceWithFailedVnf.getFirstIds().vnfReqId, "Vnf failed.");
124 Click.byTestId(DEPLOY_BUTTON);
125 VidBasePage.goOutFromIframe();
126 GeneralUIUtils.ultimateWait();
127 vidBasePage.goToIframe();
128 GeneralUIUtils.ultimateWait();
130 checkRetryRequestToBeComplete(createServiceWithFailedVnf, originalServiceName);
133 private void checkFailedAuditInfoOnRetry(String instanceName, String requestId, String message) {
134 WebElement webElement = Get.byTestId("model-item-value-instance_name");
135 assertEquals(webElement.getText(), instanceName, "Instance Name must be equal");
137 WebElement msoTableElement = Get.byId("service-instantiation-audit-info-mso");
138 assertEquals(3, msoTableElement.findElement(By.tagName("thead")).findElements(By.tagName("th")).size(), "Audit info MSO table must contain 3 columns");
139 assertEquals(requestId, msoTableElement.findElement(By.id("msoRequestId")).getText(), "Audit info Request Id is not equal");
140 assertEquals("Failed", msoTableElement.findElement(By.id("msoJobStatus")).getText(), "Audit info Job Status is not equal");
141 assertEquals(message, msoTableElement.findElement(By.id("msoAdditionalInfo")).getText(), "Audit info AdditionalInfo is not equal");
143 vidBasePage.screenshotDeployDialog("retry-audit-info-" + instanceName);
144 Click.byId(Constants.AuditInfoModal.CANCEL_BUTTON);
145 GeneralUIUtils.ultimateWait();
148 private CreateServiceWithFailedVnf createServiceWithFailedVnfAssertStausAndSimulatorRegistration() {
150 //CreateServiceWithFailedVnf is common for API test and UI test,
151 //so if you change it, make sure both test are compatible with your changes
152 CreateServiceWithFailedVnf createServiceWithFailedVnf = new CreateServiceWithFailedVnf(asyncInstantiationBase);
153 createServiceWithFailedVnf.createServicesWithVnfCompletedWithError();
154 createServiceWithFailedVnf.firstTimeAssertion();
155 createServiceWithFailedVnf.secondRegistration();
156 return createServiceWithFailedVnf;
159 private void checkRetryRequestToBeComplete(CreateServiceWithFailedVnf createServiceWithFailedVnf, String originalServiceName) {
160 DrawingBoardPage.ServiceStatusChecker serviceStatusChecker = new DrawingBoardPage.ServiceStatusChecker(originalServiceName, Collections.singleton(COMPLETED));
161 //there shall be 2 rows with same service name, one with completed with error and one completed
162 //so the following line might be buggy, and we need to improve it one day ...
163 boolean statusIsShown = Wait.waitFor(serviceStatusChecker, null, 30, 2);
164 assertTrue("service " + originalServiceName + " wasn't completed after in time", statusIsShown);
165 createServiceWithFailedVnf.simulatorCallsAssertion();