@Test public void testNotifyAcquiredNode() throws ProActiveException, RMException { when(nodeSource.getName()).thenReturn("Node source Name"); vmwareInfrastructure.nodeSource = nodeSource; vmwareInfrastructure.configure( "username", "password", "endpoint", "test.activeeon.com", "http://localhost:8088/connector-iaas", "vmware-image", "1", "512", "vmUsername", "vmPassword", "2", "3", "wget -nv test.activeeon.com/rest/node.jar", "-Dnew=value"); vmwareInfrastructure.connectorIaasController = connectorIaasController; when(node.getProperty(VMWareInfrastructure.INSTANCE_ID_NODE_PROPERTY)).thenReturn("123"); when(node.getNodeInformation()).thenReturn(nodeInformation); when(nodeInformation.getName()).thenReturn("nodename"); vmwareInfrastructure.notifyAcquiredNode(node); assertThat(vmwareInfrastructure.nodesPerInstances.get("123").isEmpty(), is(false)); assertThat(vmwareInfrastructure.nodesPerInstances.get("123").size(), is(1)); assertThat(vmwareInfrastructure.nodesPerInstances.get("123").contains("nodename"), is(true)); }
@Test public void testRemoveNode() throws ProActiveException, RMException { when(nodeSource.getName()).thenReturn("Node source Name"); vmwareInfrastructure.nodeSource = nodeSource; vmwareInfrastructure.configure( "username", "password", "endpoint", "test.activeeon.com", "http://localhost:8088/connector-iaas", "vmware-image", "1", "512", "vmUsername", "vmPassword", "2", "3", "wget -nv test.activeeon.com/rest/node.jar", "-Dnew=value"); vmwareInfrastructure.connectorIaasController = connectorIaasController; when(node.getProperty(VMWareInfrastructure.INSTANCE_ID_NODE_PROPERTY)).thenReturn("123"); when(node.getNodeInformation()).thenReturn(nodeInformation); when(node.getProActiveRuntime()).thenReturn(proActiveRuntime); when(nodeInformation.getName()).thenReturn("nodename"); vmwareInfrastructure.nodesPerInstances.put("123", Sets.newHashSet("nodename")); vmwareInfrastructure.removeNode(node); verify(proActiveRuntime).killNode("nodename"); verify(connectorIaasController).terminateInstance("node_source_name", "123"); assertThat(vmwareInfrastructure.nodesPerInstances.isEmpty(), is(true)); }