Search in sources :

Example 1 with TcpProxy

use of com.novell.ldapchai.tests.util.TcpProxy in project ldapchai by ldapchai.

the class FailOverTester method testSingleServerRestart.

public void testSingleServerRestart() throws Exception {
    TestHelper.configureLogging();
    final InetSocketAddress destinationAddress = figureDestSocketAddress();
    final TcpProxy proxy1 = new TcpProxy(basePort + 1, destinationAddress);
    proxy1.start();
    final ChaiConfiguration testConfig = makeChaiConfig(figureUrlForProxy(proxy1));
    final ChaiProvider testProvider = ChaiProviderFactory.createProvider(testConfig);
    final ChaiEntry testContainer = TestHelper.createTestContainer(testProvider);
    final ChaiUser testUser = TestHelper.createNewTestUser(testContainer);
    TestHelper.doBasicNonDestructiveUserTest(testUser);
    proxy1.stop();
    TestHelper.pause(1000);
    // test to make sure we get errors
    boolean gotError = false;
    try {
        TestHelper.doBasicNonDestructiveUserTest(testUser);
    } catch (ChaiUnavailableException e) {
        System.out.println("got expected unavailable error: " + e.getMessage());
        gotError = true;
    }
    Assert.assertTrue(gotError);
    proxy1.start();
    TestHelper.pause(1000);
    TestHelper.doBasicNonDestructiveUserTest(testUser);
}
Also used : ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) ChaiUser(com.novell.ldapchai.ChaiUser) InetSocketAddress(java.net.InetSocketAddress) ChaiEntry(com.novell.ldapchai.ChaiEntry) TcpProxy(com.novell.ldapchai.tests.util.TcpProxy) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration)

Example 2 with TcpProxy

use of com.novell.ldapchai.tests.util.TcpProxy in project ldapchai by ldapchai.

the class FailOverTester method figureUrlForProxy.

private static String figureUrlForProxy(final TcpProxy... proxies) throws Exception {
    final URI bindURL = new URI(TestHelper.bindURL);
    final StringBuilder sb = new StringBuilder();
    for (final TcpProxy loopProxy : proxies) {
        sb.append(bindURL.getScheme());
        sb.append("://");
        sb.append(loopProxy.getListenInfo().getHostName());
        sb.append(":");
        sb.append(loopProxy.getListenInfo().getPort());
        sb.append(",");
    }
    sb.deleteCharAt(sb.length() - 1);
    return sb.toString();
}
Also used : TcpProxy(com.novell.ldapchai.tests.util.TcpProxy) URI(java.net.URI)

Example 3 with TcpProxy

use of com.novell.ldapchai.tests.util.TcpProxy in project ldapchai by ldapchai.

the class FailOverTester method testMultiServerFailover.

public void testMultiServerFailover() throws Exception {
    TestHelper.configureLogging();
    final InetSocketAddress destinationAddress = figureDestSocketAddress();
    final TcpProxy proxy1 = new TcpProxy(basePort + 1, destinationAddress);
    final TcpProxy proxy2 = new TcpProxy(basePort + 2, destinationAddress);
    final TcpProxy proxy3 = new TcpProxy(basePort + 3, destinationAddress);
    proxy2.start();
    final ChaiConfiguration testConfig = makeChaiConfig(figureUrlForProxy(proxy1, proxy2, proxy3));
    final ChaiProvider testProvider = ChaiProviderFactory.createProvider(testConfig);
    final ChaiEntry testContainer = TestHelper.createTestContainer(testProvider);
    final ChaiUser testUser = TestHelper.createNewTestUser(testContainer);
    TestHelper.doBasicNonDestructiveUserTest(testUser);
    proxy2.stop();
    TestHelper.pause(1000);
    {
        // test to make sure we get unavailable error
        boolean gotError = false;
        try {
            TestHelper.doBasicNonDestructiveUserTest(testUser);
        } catch (ChaiUnavailableException e) {
            System.out.println("got expected unavailable error: " + e.getMessage());
            gotError = true;
        }
        Assert.assertTrue(gotError);
    }
    proxy1.start();
    TestHelper.pause(1000);
    TestHelper.doBasicNonDestructiveUserTest(testUser);
    proxy1.stop();
    proxy3.start();
    TestHelper.pause(1000);
    TestHelper.doBasicNonDestructiveUserTest(testUser);
}
Also used : ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) ChaiUser(com.novell.ldapchai.ChaiUser) InetSocketAddress(java.net.InetSocketAddress) ChaiEntry(com.novell.ldapchai.ChaiEntry) TcpProxy(com.novell.ldapchai.tests.util.TcpProxy) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration)

Aggregations

TcpProxy (com.novell.ldapchai.tests.util.TcpProxy)3 ChaiEntry (com.novell.ldapchai.ChaiEntry)2 ChaiUser (com.novell.ldapchai.ChaiUser)2 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)2 ChaiConfiguration (com.novell.ldapchai.provider.ChaiConfiguration)2 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)2 InetSocketAddress (java.net.InetSocketAddress)2 URI (java.net.URI)1