Search in sources :

Example 1 with RouterServerTestFramework

use of com.github.ambry.server.RouterServerTestFramework in project ambry by linkedin.

the class RouterServerSSLTest method initializeTests.

@BeforeClass
public static void initializeTests() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    String sslEnabledDataCentersStr = "DC1,DC2,DC3";
    Properties serverSSLProps = new Properties();
    TestSSLUtils.addSSLProperties(serverSSLProps, sslEnabledDataCentersStr, SSLFactory.Mode.SERVER, trustStoreFile, "server");
    TestSSLUtils.addHttp2Properties(serverSSLProps, SSLFactory.Mode.SERVER, true);
    Properties routerProps = getRouterProperties("DC1");
    TestSSLUtils.addSSLProperties(routerProps, sslEnabledDataCentersStr, SSLFactory.Mode.CLIENT, trustStoreFile, "router-client");
    sslCluster = new MockCluster(serverSSLProps, false, SystemTime.getInstance());
    MockNotificationSystem notificationSystem = new MockNotificationSystem(sslCluster.getClusterMap());
    sslCluster.initializeServers(notificationSystem);
    sslCluster.startServers();
    MockClusterMap routerClusterMap = sslCluster.getClusterMap();
    // MockClusterMap returns a new registry by default. This is to ensure that each node (server, router and so on,
    // get a different registry. But at this point all server nodes have been initialized, and we want the router and
    // its components, which are going to be created, to use the same registry.
    routerClusterMap.createAndSetPermanentMetricRegistry();
    testFramework = new RouterServerTestFramework(routerProps, routerClusterMap, notificationSystem);
    routerMetricRegistry = routerClusterMap.getMetricRegistry();
}
Also used : Properties(java.util.Properties) File(java.io.File) RouterServerTestFramework(com.github.ambry.server.RouterServerTestFramework) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) BeforeClass(org.junit.BeforeClass)

Example 2 with RouterServerTestFramework

use of com.github.ambry.server.RouterServerTestFramework in project ambry by linkedin.

the class RouterServerPlaintextTest method initializeTests.

@BeforeClass
public static void initializeTests() throws Exception {
    Properties properties = getRouterProperties("DC1");
    Properties serverProperties = new Properties();
    TestSSLUtils.addHttp2Properties(serverProperties, SSLFactory.Mode.SERVER, true);
    plaintextCluster = new MockCluster(serverProperties, false, SystemTime.getInstance());
    MockNotificationSystem notificationSystem = new MockNotificationSystem(plaintextCluster.getClusterMap());
    plaintextCluster.initializeServers(notificationSystem);
    plaintextCluster.startServers();
    MockClusterMap routerClusterMap = plaintextCluster.getClusterMap();
    // MockClusterMap returns a new registry by default. This is to ensure that each node (server, router and so on,
    // get a different registry. But at this point all server nodes have been initialized, and we want the router and
    // its components, which are going to be created, to use the same registry.
    routerClusterMap.createAndSetPermanentMetricRegistry();
    testFramework = new RouterServerTestFramework(properties, routerClusterMap, notificationSystem);
    routerMetricRegistry = routerClusterMap.getMetricRegistry();
    refAccount = testFramework.accountService.createAndAddRandomAccount();
    Iterator<Container> allContainers = refAccount.getAllContainers().iterator();
    // container with null replication policy
    Container container = allContainers.next();
    container = testFramework.accountService.addReplicationPolicyToContainer(container, null);
    refContainers.add(container);
    // container with configured default replication policy
    container = allContainers.next();
    container = testFramework.accountService.addReplicationPolicyToContainer(container, MockClusterMap.DEFAULT_PARTITION_CLASS);
    refContainers.add(container);
    // container with a special replication policy
    container = allContainers.next();
    container = testFramework.accountService.addReplicationPolicyToContainer(container, MockClusterMap.SPECIAL_PARTITION_CLASS);
    refContainers.add(container);
}
Also used : Container(com.github.ambry.account.Container) Properties(java.util.Properties) RouterServerTestFramework(com.github.ambry.server.RouterServerTestFramework) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) BeforeClass(org.junit.BeforeClass)

Example 3 with RouterServerTestFramework

use of com.github.ambry.server.RouterServerTestFramework in project ambry by linkedin.

the class RouterServerHttp2Test method initializeTests.

@BeforeClass
public static void initializeTests() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    // Set up router properties
    Properties routerProps = getRouterProperties("DC1");
    TestSSLUtils.addSSLProperties(routerProps, "DC1,DC2,DC3", SSLFactory.Mode.CLIENT, trustStoreFile, "http2-router");
    TestSSLUtils.addHttp2Properties(routerProps, SSLFactory.Mode.CLIENT, false);
    routerProps.setProperty(RouterConfig.ROUTER_ENABLE_HTTP2_NETWORK_CLIENT, "true");
    // Set up server properties
    Properties serverSSLProps = new Properties();
    TestSSLUtils.addSSLProperties(serverSSLProps, "DC1,DC2,DC3", SSLFactory.Mode.SERVER, trustStoreFile, "http2-server");
    TestSSLUtils.addHttp2Properties(serverSSLProps, SSLFactory.Mode.SERVER, false);
    serverSSLProps.setProperty("server.enable.store.data.prefetch", "true");
    http2Cluster = new MockCluster(serverSSLProps, false, SystemTime.getInstance());
    MockNotificationSystem notificationSystem = new MockNotificationSystem(http2Cluster.getClusterMap());
    http2Cluster.initializeServers(notificationSystem);
    http2Cluster.startServers();
    MockClusterMap routerClusterMap = http2Cluster.getClusterMap();
    // MockClusterMap returns a new registry by default. This is to ensure that each node (server, router and so on,
    // get a different registry. But at this point all server nodes have been initialized, and we want the router and
    // its components, which are going to be created, to use the same registry.
    routerClusterMap.createAndSetPermanentMetricRegistry();
    testFramework = new RouterServerTestFramework(routerProps, routerClusterMap, notificationSystem);
}
Also used : Properties(java.util.Properties) File(java.io.File) RouterServerTestFramework(com.github.ambry.server.RouterServerTestFramework) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) BeforeClass(org.junit.BeforeClass)

Aggregations

MockClusterMap (com.github.ambry.clustermap.MockClusterMap)3 RouterServerTestFramework (com.github.ambry.server.RouterServerTestFramework)3 Properties (java.util.Properties)3 BeforeClass (org.junit.BeforeClass)3 File (java.io.File)2 Container (com.github.ambry.account.Container)1