use of com.axway.ats.action.system.SystemOperations in project ats-framework by Axway.
the class BaseTestClass method beforeSuite.
@BeforeSuite
public void beforeSuite() {
boolean hasServiceException = false;
// quick sanity check if all servers are working properly
log.info("Running SANITY check for Example servers...");
// check agents
log.info("ATS Agents sanity check START");
try {
String agent1AtsVersion = new SystemOperations(configuration.getAgent1Address()).getAtsVersion();
log.info("Agent 1 is working and its version is: " + agent1AtsVersion);
String agent2AtsVersion = new SystemOperations(configuration.getAgent1Address()).getAtsVersion();
log.info("Agent 2 is working and its version is: " + agent2AtsVersion);
} catch (Exception e) {
hasServiceException = true;
log.error(e);
}
log.info("ATS Agents sanity check END");
log.info("HTTP Server sanity check START");
// check HTTP server
RestClient restClient = null;
try {
restClient = new RestClient("http://" + configuration.getServerIp() + ":" + configuration.getHttpServerPort());
RestResponse rr = restClient.get();
if (rr.getStatusCode() != 200) {
throw new RuntimeException("HTTP Server server maybe in trouble or not started properly. Status of HTTP sanity check response is :\n\tStatus Message: " + rr.getStatusMessage() + "\n\tBody: " + rr.getBodyAsString());
} else {
log.info("HTTP server working");
}
} catch (Exception e) {
hasServiceException = true;
log.error(e);
} finally {
if (restClient != null) {
restClient.disconnect();
restClient = null;
}
}
log.info("HTTP Server sanity check END");
log.info("FTP/FTPS Server sanity check START");
// check FTP/FTPS server (TODO)
FtpClient ftpClient = null;
try {
ftpClient = new FtpClient();
ftpClient.setCustomPort(configuration.getFtpServerPort());
ftpClient.connect(configuration.getServerIp(), configuration.getUserName(), configuration.getUserPassword());
} catch (Exception e) {
hasServiceException = true;
log.error(e);
} finally {
if (ftpClient != null) {
ftpClient.disconnect();
ftpClient = null;
}
}
log.info("FTP/FTPS Server sanity check END");
log.info("DONE running SANITY check for Examples servers");
if (hasServiceException) {
throw new RuntimeException("Not all servers started or working properly. Did you run 'Start servers' from the Desktop directory?");
}
}
use of com.axway.ats.action.system.SystemOperations in project ats-framework by Axway.
the class MonitoringTests method basicTest.
@Test
public void basicTest() throws Exception {
SystemOperations sysOps = new SystemOperations(AGENT1_ADDRESS);
log.info("Will start monitoring on host: " + sysOps.getHostname());
// the monitor is used to add some statistical info which helps understand about the loading of the server
// 1. Initialize the monitor
SystemMonitor systemMonitor = new SystemMonitor();
// 2. Add as many as needed statistics for as many as needed hosts(Note that a running ATS Agent is needed on each host)
// it is common to monitor the CPU, Memory and IO activity on the file system
systemMonitor.scheduleSystemMonitoring(AGENT1_ADDRESS, new String[] { SystemMonitor.MONITOR_CPU.ALL, SystemMonitor.MONITOR_MEMORY.ALL, SystemMonitor.MONITOR_IO.ALL });
// If you are dealing with a Java application, you can get some internal info.l It is important to note that JMX must be enabled.
// In our case we just monitor some ATS Agent, we have enabled JMX connection in the agent.sh
// but setting the flag "JMX=true"
systemMonitor.scheduleJvmMonitoring(AGENT1_ADDRESS, "1099", new String[] { SystemMonitor.MONITOR_JVM.CPU_USAGE, SystemMonitor.MONITOR_JVM.MEMORY_HEAP, SystemMonitor.MONITOR_JVM.THREADS_COUNT, SystemMonitor.MONITOR_JVM.CLASSES_COUNT });
// 3. Now is the moment when the monitoring actually starts
systemMonitor.startMonitoring(1);
// 4. here we just wait, but you should do some real work in your test
Thread.sleep(60 * 1000);
// 5. now is time to stop the monitoring
systemMonitor.stopMonitoring();
}
use of com.axway.ats.action.system.SystemOperations in project ats-framework by Axway.
the class Test_FileSystemFolder method getAllMetadataNoSuchEntity.
@Test
public void getAllMetadataNoSuchEntity() throws Exception {
// constructors
expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
expectNew(FileSystemOperations.class, "localhost:0000").andReturn(fileSystemOperations);
// open()
expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.SOLARIS);
// getAllMetaData()
expect(fileSystemOperations.findFiles("some.path/", ".*", true, true, false)).andReturn(new String[0]);
replayAll();
FileSystemFolder folder = new FileSystemFolder("localhost:0000", "some.path", null, true, false);
folder.open();
assertEquals(folder.getAllMetaData(), new ArrayList<MetaData>());
verifyAll();
}
use of com.axway.ats.action.system.SystemOperations in project ats-framework by Axway.
the class Test_FileSystemFolder method close.
@Test
public void close() throws Exception {
expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
replayAll();
FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(path, null, true, false));
folder.open();
folder.close();
verifyAll();
}
use of com.axway.ats.action.system.SystemOperations in project ats-framework by Axway.
the class Test_FileSystemFolder method openNegativeInvalidPath.
@Test
public void openNegativeInvalidPath() throws Exception {
expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
replayAll();
// should pass - only warning should be logged
FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(";;;", null, true));
folder.open();
verifyAll();
}
Aggregations