Search in sources :

Example 21 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class PollServiceTest method testExecuteExternalTask.

@Test
public void testExecuteExternalTask() throws MsoException, IOException {
    String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
    Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
    Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
    Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
    Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
    Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
    Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
    // Mockito.doNothing().when(msoHeatUtils).postProcessStackCreate(Mockito.any(), Mockito.any(), Mockito.any(),
    // Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
    pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
    Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false));
    Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
Also used : Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 22 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class StackInfoMapperTest method checkOutputToMap.

@Test
public void checkOutputToMap() throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper jacksonMapper = new ObjectMapper();
    Stack sample = jacksonMapper.readValue(this.getJson("stack-example.json"), Stack.class);
    StackInfoMapper mapper = new StackInfoMapper(sample);
    StackInfo result = mapper.map();
    Map<String, Object> map = result.getOutputs();
    assertEquals(true, map.containsKey("key2"));
    assertEquals("value1", map.get("key1"));
}
Also used : StackInfo(org.onap.so.openstack.beans.StackInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 23 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class PollServiceTest method testExecuteExternalTask_rollback.

@Test
public void testExecuteExternalTask_rollback() throws MsoException, IOException {
    String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
    Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
    Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
    Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
    Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true))).thenReturn(new Stack());
    Mockito.doNothing().when(msoHeatUtils).postProcessStackDelete(Mockito.any());
    Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
    pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
    Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true));
    Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
Also used : Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 24 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class RollbackServiceTest method testExecuteExternalTask.

@Test
public void testExecuteExternalTask() throws VnfException, MsoException, IOException {
    String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
    Stack stack = new Stack();
    stack.setId("heatId");
    Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
    Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
    Mockito.doNothing().when(vnfAdapterImpl).deleteVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
    Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any());
    rollbackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
    Mockito.verify(vnfAdapterImpl, Mockito.times(1)).deleteVfModule(Mockito.eq("regionOne"), Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"), Mockito.eq("dummy_id"), Mockito.any(String.class), Mockito.any(), Mockito.any());
    Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.any());
}
Also used : Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 25 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class StackServiceTest method testExecuteExternalTask.

@Test
public void testExecuteExternalTask() throws VnfException, MsoException, IOException {
    String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
    Stack stack = new Stack();
    stack.setId("heatId");
    Mockito.when(vnfAdapterUtils.isMulticloudMode(Mockito.any(), Mockito.any())).thenReturn(false);
    Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
    Mockito.doNothing().when(vnfAdapterImpl).createVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
    Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any());
    stackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.put("vf_module_id", "985a468b-328b-4c2b-ad0e-b8f1e19501c4");
    paramsMap.put("vnf_id", "6640feba-55f6-4946-9694-4d9558c8870a");
    paramsMap.put("vnf_name", "Robot_VNF_For_Volume_Group");
    paramsMap.put("availability_zone_0", "AZ-MN02");
    paramsMap.put("environment_context", "General_Revenue-Bearing");
    paramsMap.put("user_directives", "{}");
    paramsMap.put("workload_context", "");
    paramsMap.put("vf_module_name", "dummy_id");
    paramsMap.put("vf_module_index", "0");
    paramsMap.put("sdnc_directives", "{ \"attributes\": [ {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"AZ-MN02\"}] }");
    Map<String, Object> variables = new HashMap<>();
    variables.put("backout", true);
    variables.put("OpenstackInvokeSuccess", true);
    variables.put("stackId", null);
    variables.put("openstackAdapterErrorMessage", "");
    variables.put("PollRollbackStatus", false);
    variables.put("rollbackPerformed", false);
    variables.put("OpenstackRollbackSuccess", false);
    variables.put("OpenstackPollSuccess", false);
    variables.put("os3Nw", false);
    Mockito.verify(vnfAdapterImpl, Mockito.times(1)).createVfModule(Mockito.eq("regionOne"), Mockito.eq("CloudOwner"), Mockito.eq("0422ffb57ba042c0800a29dc85ca70f8"), Mockito.eq("Vf zrdm5bpxmc02092017-Service/Vf zrdm5bpxmc02092017-VF 0::VfZrdm5bpxmc02092017Vf..pxmc_base..module-0"), Mockito.eq("1.0"), Mockito.eq("6640feba-55f6-4946-9694-4d9558c8870a"), Mockito.eq("dummy_id"), Mockito.eq("985a468b-328b-4c2b-ad0e-b8f1e19501c4"), Mockito.eq(null), Mockito.eq(null), Mockito.eq(null), Mockito.eq("074c64d0-7e13-4bcc-8bdb-ea922331102d"), Mockito.eq(paramsMap), Mockito.eq(false), Mockito.eq(false), Mockito.eq(null), Mockito.any(), Mockito.any());
    Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.eq(variables));
}
Also used : HashMap(java.util.HashMap) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Aggregations

Stack (com.woorea.openstack.heat.model.Stack)41 Test (org.junit.Test)26 CreateStack (com.woorea.openstack.heat.StackResource.CreateStack)15 DeleteStack (com.woorea.openstack.heat.StackResource.DeleteStack)15 CreateStackParam (com.woorea.openstack.heat.model.CreateStackParam)10 Heat (com.woorea.openstack.heat.Heat)9 StackInfo (org.onap.so.openstack.beans.StackInfo)9 StackInfoMapper (org.onap.so.openstack.mappers.StackInfoMapper)7 MsoException (org.onap.so.openstack.exceptions.MsoException)5 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)3 File (java.io.File)3 HashMap (java.util.HashMap)3 CloudSite (org.onap.so.db.catalog.beans.CloudSite)3 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RequestProcessingData (org.onap.so.db.request.beans.RequestProcessingData)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)1 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1