parent
f04ece804e
commit
e595b24920
@ -1,92 +0,0 @@
|
||||
package org.wso2.iot.integration.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
||||
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
|
||||
import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
|
||||
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
|
||||
import org.wso2.carbon.logging.view.stub.LogViewerLogViewerException;
|
||||
import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
|
||||
import org.wso2.iot.integration.common.TestBase;
|
||||
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class RestartTest extends TestBase {
|
||||
|
||||
private Log log = LogFactory.getLog(RestartTest.class);
|
||||
private LogViewerClient logViewerClient;
|
||||
|
||||
@BeforeClass
|
||||
public void initTest() throws Exception {
|
||||
super.init(TestUserMode.SUPER_TENANT_ADMIN);
|
||||
logViewerClient = new LogViewerClient(getBackendHTTPSURL(), getSessionCookie());
|
||||
}
|
||||
|
||||
@Test(description = "Test restarting the server")
|
||||
public void serverRestartTest() {
|
||||
ServerConfigurationManager serverManager;
|
||||
try {
|
||||
serverManager = new ServerConfigurationManager(automationContext);
|
||||
log.info("Restart Triggered -------------------------------------------------------------------");
|
||||
serverManager.restartGracefully();
|
||||
logViewerClient.getAllRemoteSystemLogs();
|
||||
waitForRestart();
|
||||
} catch (AutomationUtilException | XPathExpressionException | MalformedURLException e) {
|
||||
log.error("Restart failed due to : " + e.getLocalizedMessage());
|
||||
} catch (RemoteException | LogViewerLogViewerException e) {
|
||||
log.error("Cannot get server log due to : " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the server restarts.
|
||||
* This method looks for "Mgt console URL:" to be appeared in the terminal.
|
||||
* If it does not appear within the given timeout an Exception will be thrown.
|
||||
*/
|
||||
private void waitForRestart() {
|
||||
ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
try {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
|
||||
for (LogEvent event : logEvents) {
|
||||
log.info(event.getMessage() + " @ " + event.getLogTime());
|
||||
if (event.getMessage().contains("Mgt Console URL : " )){
|
||||
log.info("Server restarted successfully");
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
||||
} catch (RemoteException | LogViewerLogViewerException e) {
|
||||
log.error("Error reading logs. \n" + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Future<?> f = service.submit(r);
|
||||
|
||||
f.get(30, TimeUnit.MINUTES);
|
||||
} catch (final InterruptedException e) {
|
||||
log.error("Interrupted "+e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} catch (final TimeoutException e) {
|
||||
log.error("Timeout " + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} catch (final ExecutionException e) {
|
||||
log.error("Execution failed " + e.getMessage());
|
||||
Assert.assertTrue(false);
|
||||
} finally {
|
||||
service.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,92 +1,186 @@
|
||||
{
|
||||
"id": 101234,
|
||||
"name": "androiddevice1234",
|
||||
"type": "android",
|
||||
"description": "this is an android device",
|
||||
"deviceIdentifier": "d24f870f390352a41234",
|
||||
"enrolmentInfo": {
|
||||
"POST": {
|
||||
"id": 101234,
|
||||
"device": {
|
||||
"name": "androiddevice1234",
|
||||
"type": "android",
|
||||
"description": "this is an android device",
|
||||
"deviceIdentifier": "d24f870f390352a41234",
|
||||
"enrolmentInfo": {
|
||||
"id": 101234,
|
||||
"device": {
|
||||
},
|
||||
"dateOfEnrolment": 0,
|
||||
"dateOfLastUpdate": 0,
|
||||
"ownership": "BYOD",
|
||||
"status": "CREATED",
|
||||
"owner": "admin"
|
||||
},
|
||||
"dateOfEnrolment": 0,
|
||||
"dateOfLastUpdate": 0,
|
||||
"ownership": "BYOD",
|
||||
"status": "CREATED",
|
||||
"owner": "admin"
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"id": 10,
|
||||
"code": "aaaa1111",
|
||||
"name": "newfeature1",
|
||||
"description": "this is the new feature 1",
|
||||
"deviceType": "android",
|
||||
"metadataEntries": [
|
||||
{
|
||||
"id": 10,
|
||||
"value": {
|
||||
"features": [
|
||||
{
|
||||
"id": 10,
|
||||
"code": "aaaa1111",
|
||||
"name": "newfeature1",
|
||||
"description": "this is the new feature 1",
|
||||
"deviceType": "android",
|
||||
"metadataEntries": [
|
||||
{
|
||||
"id": 10,
|
||||
"value": {
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "property1",
|
||||
"value": "value1"
|
||||
}
|
||||
],
|
||||
"deviceInfo": {
|
||||
"deviceModel": "S8",
|
||||
"vendor": "SAMSUNG",
|
||||
"osVersion": "5.1",
|
||||
"batteryLevel": 1,
|
||||
"internalTotalMemory": 32,
|
||||
"internalAvailableMemory": 24,
|
||||
"externalTotalMemory": 64,
|
||||
"externalAvailableMemory": 60,
|
||||
"operator": "dialog",
|
||||
"connectionType": "GSM",
|
||||
"mobileSignalStrength": 1,
|
||||
"ssid": "picassowifi",
|
||||
"cpuUsage": 0,
|
||||
"totalRAMMemory": 2,
|
||||
"availableRAMMemory": 1,
|
||||
"pluggedIn": false,
|
||||
"location": {
|
||||
"deviceId": 0,
|
||||
"deviceIdentifier": {
|
||||
"id": "string",
|
||||
"type": "string"
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "property1",
|
||||
"value": "value1"
|
||||
}
|
||||
],
|
||||
"deviceInfo": {
|
||||
"deviceModel": "S8",
|
||||
"vendor": "SAMSUNG",
|
||||
"osVersion": "5.1",
|
||||
"batteryLevel": 1,
|
||||
"internalTotalMemory": 32,
|
||||
"internalAvailableMemory": 24,
|
||||
"externalTotalMemory": 64,
|
||||
"externalAvailableMemory": 60,
|
||||
"operator": "dialog",
|
||||
"connectionType": "GSM",
|
||||
"mobileSignalStrength": 1,
|
||||
"ssid": "picassowifi",
|
||||
"cpuUsage": 0,
|
||||
"totalRAMMemory": 2,
|
||||
"availableRAMMemory": 1,
|
||||
"pluggedIn": false,
|
||||
"location": {
|
||||
"deviceId": 0,
|
||||
"deviceIdentifier": {
|
||||
"id": "string",
|
||||
"type": "string"
|
||||
},
|
||||
"latitude": 0,
|
||||
"longitude": 0,
|
||||
"street1": "string",
|
||||
"street2": "string",
|
||||
"city": "string",
|
||||
"state": "string",
|
||||
"zip": "string",
|
||||
"country": "string"
|
||||
},
|
||||
"latitude": 0,
|
||||
"longitude": 0,
|
||||
"street1": "string",
|
||||
"street2": "string",
|
||||
"city": "string",
|
||||
"state": "string",
|
||||
"zip": "string",
|
||||
"country": "string"
|
||||
},
|
||||
"deviceDetailsMap": {
|
||||
"deviceDetailsMap": {
|
||||
},
|
||||
"imei": "string",
|
||||
"imsi": "string"
|
||||
},
|
||||
"imei": "string",
|
||||
"imsi": "string"
|
||||
"applications": [
|
||||
{
|
||||
"id": 0,
|
||||
"platform": "string",
|
||||
"category": "string",
|
||||
"name": "string",
|
||||
"locationUrl": "string",
|
||||
"imageUrl": "string",
|
||||
"version": "string",
|
||||
"type": "string",
|
||||
"appProperties": {
|
||||
},
|
||||
"applicationIdentifier": "string",
|
||||
"memoryUsage": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"applications": [
|
||||
{
|
||||
"id": 0,
|
||||
"platform": "string",
|
||||
"category": "string",
|
||||
"name": "string",
|
||||
"locationUrl": "string",
|
||||
"imageUrl": "string",
|
||||
"version": "string",
|
||||
"type": "string",
|
||||
"appProperties": {
|
||||
"PUT": {
|
||||
"id": 101234,
|
||||
"name": "androiddevice1234",
|
||||
"type": "android",
|
||||
"description": "this is an android device",
|
||||
"deviceIdentifier": "d24f870f390352a41234",
|
||||
"enrolmentInfo": {
|
||||
"id": 101234,
|
||||
"device": {
|
||||
},
|
||||
"applicationIdentifier": "string",
|
||||
"memoryUsage": 0
|
||||
}
|
||||
]
|
||||
"dateOfEnrolment": 0,
|
||||
"dateOfLastUpdate": 0,
|
||||
"ownership": "BYOD",
|
||||
"status": "CREATED",
|
||||
"owner": "admin"
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"id": 10,
|
||||
"code": "aaaa1111",
|
||||
"name": "newfeature2",
|
||||
"description": "this is the new feature 2",
|
||||
"deviceType": "android",
|
||||
"metadataEntries": [
|
||||
{
|
||||
"id": 10,
|
||||
"value": {
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "property2",
|
||||
"value": "value2"
|
||||
}
|
||||
],
|
||||
"deviceInfo": {
|
||||
"deviceModel": "S8",
|
||||
"vendor": "SAMSUNG",
|
||||
"osVersion": "5.1",
|
||||
"batteryLevel": 1,
|
||||
"internalTotalMemory": 32,
|
||||
"internalAvailableMemory": 24,
|
||||
"externalTotalMemory": 64,
|
||||
"externalAvailableMemory": 60,
|
||||
"operator": "dialog",
|
||||
"connectionType": "GSM",
|
||||
"mobileSignalStrength": 1,
|
||||
"ssid": "picassowifi",
|
||||
"cpuUsage": 0,
|
||||
"totalRAMMemory": 2,
|
||||
"availableRAMMemory": 1,
|
||||
"pluggedIn": false,
|
||||
"location": {
|
||||
"deviceId": 0,
|
||||
"deviceIdentifier": {
|
||||
"id": "string",
|
||||
"type": "string"
|
||||
},
|
||||
"latitude": 0,
|
||||
"longitude": 0,
|
||||
"street1": "string",
|
||||
"street2": "string",
|
||||
"city": "string",
|
||||
"state": "string",
|
||||
"zip": "string",
|
||||
"country": "string"
|
||||
},
|
||||
"deviceDetailsMap": {
|
||||
},
|
||||
"imei": "string",
|
||||
"imsi": "string"
|
||||
},
|
||||
"applications": [
|
||||
{
|
||||
"id": 0,
|
||||
"platform": "string",
|
||||
"category": "string",
|
||||
"name": "string",
|
||||
"locationUrl": "string",
|
||||
"imageUrl": "string",
|
||||
"version": "string",
|
||||
"type": "string",
|
||||
"appProperties": {
|
||||
},
|
||||
"applicationIdentifier": "string",
|
||||
"memoryUsage": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,4 +1,19 @@
|
||||
{
|
||||
"responseCode": "OK",
|
||||
"responseMessage": "Android device, which carries the id \u0027d24f870f390352a41\u0027 has successfully been enrolled"
|
||||
"POST": {
|
||||
"responseCode": "OK",
|
||||
"responseMessage": "Android device, which carries the id \u0027d24f870f390352a41234\u0027 has successfully been enrolled"
|
||||
},
|
||||
"GET": {
|
||||
"responseCode": "OK",
|
||||
"responseMessage": "Android device that carries the id \u0027d24f870f390352a41234\u0027 is enrolled"
|
||||
},
|
||||
"PUT": {
|
||||
"responseCode": "Accepted",
|
||||
"responseMessage": "Enrollment of Android device that carries the id \u0027d24f870f390352a41234\u0027 has successfully updated"
|
||||
},
|
||||
"DELETE" : {
|
||||
"responseCode":"OK",
|
||||
"responseMessage":"Android device that carries id \u0027d24f870f390352a41234\u0027 has successfully dis-enrolled"
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue