Search in sources :

Example 1 with SystemOperations

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?");
    }
}
Also used : SystemOperations(com.axway.ats.action.system.SystemOperations) RestResponse(com.axway.ats.action.rest.RestResponse) RestClient(com.axway.ats.action.rest.RestClient) FtpClient(com.axway.ats.core.filetransfer.FtpClient) IOException(java.io.IOException) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 2 with SystemOperations

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();
}
Also used : SystemOperations(com.axway.ats.action.system.SystemOperations) SystemMonitor(com.axway.ats.monitoring.SystemMonitor) Test(org.testng.annotations.Test)

Example 3 with SystemOperations

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();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 4 with SystemOperations

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();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) FileSystemFolderSearchTerm(com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 5 with SystemOperations

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();
}
Also used : FileSystemOperations(com.axway.ats.action.filesystem.FileSystemOperations) SystemOperations(com.axway.ats.action.system.SystemOperations) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) FileSystemFolderSearchTerm(com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

SystemOperations (com.axway.ats.action.system.SystemOperations)9 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)7 BaseTest (com.axway.ats.rbv.BaseTest)6 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)6 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 FileSystemFolderSearchTerm (com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm)4 FilePackage (com.axway.ats.action.objects.FilePackage)1 PackageException (com.axway.ats.action.objects.model.PackageException)1 RestClient (com.axway.ats.action.rest.RestClient)1 RestResponse (com.axway.ats.action.rest.RestResponse)1 FtpClient (com.axway.ats.core.filetransfer.FtpClient)1 SystemMonitor (com.axway.ats.monitoring.SystemMonitor)1 MetaData (com.axway.ats.rbv.MetaData)1 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)1 FileSystemStorage (com.axway.ats.rbv.filesystem.FileSystemStorage)1 IOException (java.io.IOException)1 Before (org.junit.Before)1 BeforeSuite (org.testng.annotations.BeforeSuite)1 Test (org.testng.annotations.Test)1