edu.sdsc.inca.agent
Class ReporterManagerControllerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.sdsc.inca.agent.ReporterManagerControllerTest
All Implemented Interfaces:
junit.framework.Test

public class ReporterManagerControllerTest
extends junit.framework.TestCase

Tests for ReporterManagerController (and ReporterManagerStarter).

Author:
Shava Smallen <ssmallen@sdsc.edu>

Nested Class Summary
static class ReporterManagerControllerTest.MockAgent
          Emulates the agent's tasks
 
Constructor Summary
ReporterManagerControllerTest()
           
 
Method Summary
 ReporterManagerController createRM(boolean secure, boolean repository, edu.sdsc.inca.util.ResourcesWrapper resources, java.lang.String resource)
          Create a reporter manager object using the specified uri as the contact to the agent.
static edu.sdsc.inca.util.SuiteWrapper createSampleSuite(java.lang.String resource)
          Create a sample suite document and create the reporter uris relative to the specified repository path.
static java.net.ServerSocket createSSLSocket(int port)
          Create a SSL server socket
 void runCreateAndSubscribe(boolean auth)
          Test the reporter manager's create and sendSuite functions.
 void setUp()
          Read properties, initialize member variables, and delete var directory
 void startAndRegisterRMC(boolean secure, boolean repository, edu.sdsc.inca.util.ResourcesWrapper resources, int numConnections, java.lang.String resource)
          Start up a remote reporter manager and a mock agent.
static java.util.Hashtable storeProxy(edu.sdsc.inca.util.ResourcesWrapper resources)
          Using the MyProxy server configuration in the resources file, store a proxy in the MyProxy server.
 void tearDown()
          Close reporter manager controller and mock agent if used in test
 void testCreateAndSuite()
          Test the reporter manager's create and sendSuite functions.
 void testCreateAndSuiteAuth()
          Same as testCreateAndSuite but with authentication turned on
 void testGetUris()
          Test the ability to get URIs from a suite
 void testInterrupt()
          Test that interrupts at different stages in the run function will cause the run thread to exit appropriately.
 void testIsRemoteManagerAlive()
          Test the reporter manager's isRemoteManagerAlive function
 void testManual()
          Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource.
 void testPackage()
          Test the reporter manager's addPackage function
 void testParseWorkingDir()
          Test the ability to parse the rm working dir correctly
 void testPasswordRegister()
          Test the reporter manager's register function when the reporter manager connects using a password
 void testPattern()
          Test the specified pattern to make sure it can parse out the string "inca" from a glob of text.
 void testProxy()
          Test the reporter manager's register function and proxy renewal info
 void testRegister()
          Test the reporter manager's register function
 void testRestart()
          Test the reporter manager's restart function.
 void testSendReporters()
          Test the ability to send reporters from a suite to a RM
 void testStage()
          Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource.
 void testStart()
          Test the reporter manager's start function.
 void testStartOnSecondTime()
          Test the reporter manager's start function.
 void testStartStops()
          Test the reporter manager's start function.
 void testUpgrade()
          Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReporterManagerControllerTest

public ReporterManagerControllerTest()
Method Detail

createSSLSocket

public static java.net.ServerSocket createSSLSocket(int port)
                                             throws java.lang.Exception
Create a SSL server socket

Parameters:
port - The port to open the socket on.
Returns:
A configured SSL ServerSocket.
Throws:
java.lang.Exception - if unable to create ssl socket

createSampleSuite

public static edu.sdsc.inca.util.SuiteWrapper createSampleSuite(java.lang.String resource)
                                                         throws org.apache.xmlbeans.XmlException
Create a sample suite document and create the reporter uris relative to the specified repository path.

Parameters:
resource - The name of a resource to schedule the suite to.
Returns:
A suite document.
Throws:
org.apache.xmlbeans.XmlException - if unable to parse sample suite

createRM

public ReporterManagerController createRM(boolean secure,
                                          boolean repository,
                                          edu.sdsc.inca.util.ResourcesWrapper resources,
                                          java.lang.String resource)
                                   throws java.lang.Exception
Create a reporter manager object using the specified uri as the contact to the agent.

Parameters:
secure - Whether the mock agent server should be secure or not
repository - Whether or not we need to setup a temporary repository
resources - The resources the agent should be configured with
resource - The name of the resource in resources we should use to start the reporter manager on.
Returns:
a new reporter mananger controller object
Throws:
java.lang.Exception - if trouble creating test reporter manager object

runCreateAndSubscribe

public void runCreateAndSubscribe(boolean auth)
                           throws java.lang.Exception
Test the reporter manager's create and sendSuite functions.

Parameters:
auth - whether to test with credentials or not
Throws:
java.lang.Exception - if error during send of sample subscription

setUp

public void setUp()
           throws java.lang.Exception
Read properties, initialize member variables, and delete var directory

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

startAndRegisterRMC

public void startAndRegisterRMC(boolean secure,
                                boolean repository,
                                edu.sdsc.inca.util.ResourcesWrapper resources,
                                int numConnections,
                                java.lang.String resource)
                         throws java.lang.Exception
Start up a remote reporter manager and a mock agent. Return when the remote reporter manager has checked in and registered.

Parameters:
secure - Whether the mock agent server should be secure or not
repository - Whether or not we need to setup a temporary repository
resources - The resources the agent should be configured with
numConnections - The number of connections the mock agent should expect before exitting.
resource - The name of the resource to start this reporter manager on.
Throws:
java.lang.Exception - If trouble starting up a remote reporter managers

storeProxy

public static java.util.Hashtable storeProxy(edu.sdsc.inca.util.ResourcesWrapper resources)
                                      throws java.lang.Exception
Using the MyProxy server configuration in the resources file, store a proxy in the MyProxy server.

Parameters:
resources - A resources configuration containing a resource with MyProxy server configuration information.
Returns:
The proxy configuration on the MyProxy server.
Throws:
java.lang.Exception - if trouble storing proxy

tearDown

public void tearDown()
              throws java.lang.Exception
Close reporter manager controller and mock agent if used in test

Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception

testCreateAndSuite

public void testCreateAndSuite()
                        throws java.lang.Exception
Test the reporter manager's create and sendSuite functions. The test emulates the real reporter agent's responses to PING, REGISTER and then sends the END statement to shutdown the reporter manager.

Throws:
java.lang.Exception - if trouble executing test

testCreateAndSuiteAuth

public void testCreateAndSuiteAuth()
                            throws java.lang.Exception
Same as testCreateAndSuite but with authentication turned on

Throws:
java.lang.Exception - if trouble executing test

testGetUris

public void testGetUris()
                 throws java.lang.Exception
Test the ability to get URIs from a suite

Throws:
java.lang.Exception - if trouble executing test

testInterrupt

public void testInterrupt()
                   throws java.lang.Exception
Test that interrupts at different stages in the run function will cause the run thread to exit appropriately.

Throws:
java.lang.Exception - if trouble executing test

testIsRemoteManagerAlive

public void testIsRemoteManagerAlive()
                              throws java.lang.Exception
Test the reporter manager's isRemoteManagerAlive function

Throws:
java.lang.Exception - if trouble executing test

testManual

public void testManual()
                throws java.lang.Exception
Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource. Tested with auth on.

Throws:
java.lang.Exception - if trouble executing test

testPackage

public void testPackage()
                 throws java.lang.Exception
Test the reporter manager's addPackage function

Throws:
java.lang.Exception - if trouble executing test

testParseWorkingDir

public void testParseWorkingDir()
                         throws java.lang.Exception
Test the ability to parse the rm working dir correctly

Throws:
java.lang.Exception - if trouble executing test

testPasswordRegister

public void testPasswordRegister()
                          throws java.lang.Exception
Test the reporter manager's register function when the reporter manager connects using a password

Throws:
java.lang.Exception - if trouble executing test

testPattern

public void testPattern()
Test the specified pattern to make sure it can parse out the string "inca" from a glob of text.


testProxy

public void testProxy()
               throws java.lang.Exception
Test the reporter manager's register function and proxy renewal info

Throws:
java.lang.Exception - if trouble executing test

testRegister

public void testRegister()
                  throws java.lang.Exception
Test the reporter manager's register function

Throws:
java.lang.Exception - if trouble executing test

testRestart

public void testRestart()
                 throws java.lang.Exception
Test the reporter manager's restart function. When manager checks in the first time, we kill it and expect the isReporterManagerAlive function to detect the kill. The manager is restarted and this time is sent a suite. During the sending of the suite, we kill the reporter manager again and expect those functions to detect the kill. When the manager is restarted for the second time, it should pick up a suite and execute it. It will start up 3 reporters which we wait for. Then we pick the manager 3 times and then properly shut it down.

Throws:
java.lang.Exception - if trouble executing test

testSendReporters

public void testSendReporters()
                       throws java.lang.Exception
Test the ability to send reporters from a suite to a RM

Throws:
java.lang.Exception - if trouble executing test

testStage

public void testStage()
               throws java.lang.Exception
Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource. Tested with auth on.

Throws:
java.lang.Exception - if trouble executing test

testStart

public void testStart()
               throws java.lang.Exception
Test the reporter manager's start function. Given a resource with 2 bad hosts and 1 good one

Throws:
java.lang.Exception - if trouble executing test

testStartOnSecondTime

public void testStartOnSecondTime()
                           throws java.lang.Exception
Test the reporter manager's start function. Given a resource which doesn't work. We then change the resource to work 10 seconds and expect start to pick it up after it's next iteration.

Throws:
java.lang.Exception - if trouble executing test

testStartStops

public void testStartStops()
                    throws java.lang.Exception
Test the reporter manager's start function. Given a resource that doesn't start the first time, and then the user realizes it's the wrong resources and decides to delete it. This thread should exit accordingly.

Throws:
java.lang.Exception - if trouble executing test

testUpgrade

public void testUpgrade()
                 throws java.lang.Exception
Test the reporter manager's stage function which installs a reporter manager distribution on a remote resource. Tested with auth on.

Throws:
java.lang.Exception - if trouble executing test