/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE
* or https://OpenDS.dev.java.net/OpenDS.LICENSE.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.server;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.*;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.TestCaseUtils;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.*;
import org.opends.server.replication.plugin.MultimasterReplication;
import org.opends.server.replication.protocol.*;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.HostPort;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.testng.Assert.*;
/**
* Test Server part of the assured feature in both safe data and
* safe read modes.
*/
@SuppressWarnings("javadoc")
public class AssuredReplicationServerTest
extends ReplicationTestCase
{
private String testName = this.getClass().getSimpleName();
/** The tracer object for the debug logger */
private static final DebugTracer TRACER = getTracer();
private int rs1Port = -1;
private int rs2Port = -1;
private int rs3Port = -1;
private int rs4Port = -1;
private static final int FDS1_ID = 1;
private static final int FDS2_ID = 2;
private static final int FDS3_ID = 3;
private static final int FDS4_ID = 4;
private static final int FDS5_ID = 5;
private static final int FDS6_ID = 6;
private static final int FDS7_ID = 7;
private static final int FDS8_ID = 8;
private static final int FDS9_ID = 9;
private static final int FDS10_ID = 10;
private static final int FDS11_ID = 11;
private static final int FDS12_ID = 12;
private static final int FRS1_ID = 51;
private static final int FRS2_ID = 52;
private static final int FRS3_ID = 53;
private static final int DS_FRS2_ID = FRS2_ID + 10;
private static final int RS1_ID = 101;
private static final int RS2_ID = 102;
private static final int RS3_ID = 103;
private static final int RS4_ID = 104;
private FakeReplicationDomain fakeRd1 = null;
private FakeReplicationDomain fakeRd2 = null;
private FakeReplicationDomain fakeRd3 = null;
private FakeReplicationDomain fakeRd4 = null;
private FakeReplicationDomain fakeRd5 = null;
private FakeReplicationDomain fakeRd6 = null;
private FakeReplicationDomain fakeRd7 = null;
private FakeReplicationDomain fakeRd8 = null;
private FakeReplicationDomain fakeRd9 = null;
private FakeReplicationDomain fakeRd10 = null;
private FakeReplicationDomain fakeRd11 = null;
private FakeReplicationDomain fakeRd12 = null;
private FakeReplicationServer fakeRs1 = null;
private FakeReplicationServer fakeRs2 = null;
private FakeReplicationServer fakeRs3 = null;
private ReplicationServer rs1 = null;
private ReplicationServer rs2 = null;
private ReplicationServer rs3 = null;
private ReplicationServer rs4 = null;
/**
* Small assured timeout value (timeout to be used in first RS receiving an
* assured update from a DS)
*/
private static final int SMALL_TIMEOUT = 3000;
/**
* Long assured timeout value (timeout to use in DS when sending an assured
* update)
*/
private static final int LONG_TIMEOUT = 5000;
/**
* Expected max time for sending an assured update and receive its ack
* (without errors)
*/
private static final int MAX_SEND_UPDATE_TIME = 2000;
/** Default group id */
private static final int DEFAULT_GID = 1;
/** Other group ids */
private static final int OTHER_GID = 2;
private static final int OTHER_GID_BIS = 3;
/** Default generation id */
private static long DEFAULT_GENID = EMPTY_DN_GENID;
/** Other generation id */
private static long OTHER_GENID = 500L;
/*
* Definitions for the scenario of the fake DS
*/
/** DS receives updates and replies acks with no errors to every updates */
private static final int REPLY_OK_DS_SCENARIO = 1;
/** DS receives updates but does not respond (makes timeouts) */
private static final int TIMEOUT_DS_SCENARIO = 2;
/** DS receives updates and replies ack with replay error flags */
private static final int REPLAY_ERROR_DS_SCENARIO = 3;
/*
* Definitions for the scenario of the fake RS
*/
/** RS receives updates and replies acks with no errors to every updates */
private static final int REPLY_OK_RS_SCENARIO = 11;
/** RS receives updates but does not respond (makes timeouts) */
private static final int TIMEOUT_RS_SCENARIO = 12;
/**
* RS is used for sending updates (with sendNewFakeUpdate()) and receive acks,
* synchronously
*/
private static final int SENDER_RS_SCENARIO = 13;
// Scenarios only used in safe read tests:
/**
* RS receives updates and replies ack error as if a DS was connected to it
* and timed out
*/
private static final int DS_TIMEOUT_RS_SCENARIO_SAFE_READ = 14;
/**
* RS receives updates and replies ack error as if a DS was connected to it
* and was wrong status
*/
private static final int DS_WRONG_STATUS_RS_SCENARIO_SAFE_READ = 15;
/**
* RS receives updates and replies ack error as if a DS was connected to it
* and had a replay error
*/
private static final int DS_REPLAY_ERROR_RS_SCENARIO_SAFE_READ = 16;
private void debugInfo(String s)
{
logError(Message.raw(Category.SYNC, Severity.NOTICE, s));
if (debugEnabled())
{
TRACER.debugInfo("** TEST **" + s);
}
}
/**
* Before starting the tests configure some stuff
*/
@BeforeClass
@Override
public void setUp() throws Exception
{
super.setUp();
int[] ports = TestCaseUtils.findFreePorts(4);
int i = 0;
rs1Port = ports[i++];
rs2Port = ports[i++];
rs3Port = ports[i++];
rs4Port = ports[i++];
}
private void initTest()
{
fakeRd1 = null;
fakeRd2 = null;
fakeRd3 = null;
fakeRd4 = null;
fakeRd5 = null;
fakeRd6 = null;
fakeRd7 = null;
fakeRd8 = null;
fakeRd9 = null;
fakeRd10 = null;
fakeRd11 = null;
fakeRd12 = null;
fakeRs1 = null;
fakeRs2 = null;
fakeRs3 = null;
rs1 = null;
rs2 = null;
rs3 = null;
rs4 = null;
}
private void endTest()
{
// Shutdown fake DSs
if (fakeRd1 != null)
{
fakeRd1.disableService();
fakeRd1 = null;
}
if (fakeRd2 != null)
{
fakeRd2.disableService();
fakeRd2 = null;
}
if (fakeRd3 != null)
{
fakeRd3.disableService();
fakeRd3 = null;
}
if (fakeRd4 != null)
{
fakeRd4.disableService();
fakeRd4 = null;
}
if (fakeRd5 != null)
{
fakeRd5.disableService();
fakeRd5 = null;
}
if (fakeRd6 != null)
{
fakeRd6.disableService();
fakeRd6 = null;
}
if (fakeRd7 != null)
{
fakeRd7.disableService();
fakeRd7 = null;
}
if (fakeRd8 != null)
{
fakeRd8.disableService();
fakeRd8 = null;
}
if (fakeRd9 != null)
{
fakeRd9.disableService();
fakeRd9 = null;
}
if (fakeRd10 != null)
{
fakeRd10.disableService();
fakeRd10 = null;
}
if (fakeRd11 != null)
{
fakeRd11.disableService();
fakeRd11 = null;
}
if (fakeRd12 != null)
{
fakeRd12.disableService();
fakeRd12 = null;
}
// Shutdown fake RSs
if (fakeRs1 != null)
{
fakeRs1.shutdown();
fakeRs1 = null;
}
if (fakeRs2 != null)
{
fakeRs2.shutdown();
fakeRs2 = null;
}
if (fakeRs3 != null)
{
fakeRs3.shutdown();
fakeRs3 = null;
}
// Shutdown RSs
if (rs1 != null)
{
rs1.clearDb();
rs1.remove();
StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
rs1.getDbDirName()));
rs1 = null;
}
if (rs2 != null)
{
rs2.clearDb();
rs2.remove();
StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
rs2.getDbDirName()));
rs2 = null;
}
if (rs3 != null)
{
rs3.clearDb();
rs3.remove();
StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
rs3.getDbDirName()));
rs3 = null;
}
if (rs4 != null)
{
rs4.clearDb();
rs4.remove();
StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
rs4.getDbDirName()));
rs4 = null;
}
}
/**
* Creates and connects a new fake replication domain, using the passed scenario
* (no server state constructor version)
*/
private FakeReplicationDomain createFakeReplicationDomain(int serverId,
int groupId, int rsId, long generationId, boolean assured,
AssuredMode assuredMode, int safeDataLevel, long assuredTimeout,
int scenario)
throws Exception
{
return createFakeReplicationDomain(serverId, groupId, rsId, generationId, assured,
assuredMode, safeDataLevel, assuredTimeout, scenario, new ServerState(), true, 100);
}
/**
* Creates and connects a new fake replication domain, using the passed scenario.
*/
private FakeReplicationDomain createFakeReplicationDomain(int serverId,
int groupId, int rsId, long generationId, boolean assured,
AssuredMode assuredMode, int safeDataLevel, long assuredTimeout,
int scenario, ServerState serverState)
throws Exception
{
return createFakeReplicationDomain(serverId, groupId, rsId, generationId, assured,
assuredMode, safeDataLevel, assuredTimeout, scenario, serverState, true, 100);
}
private int getRsPort(int rsId)
{
int rsPort = -1;
switch (rsId)
{
case RS1_ID:
rsPort = rs1Port;
break;
case RS2_ID:
rsPort = rs2Port;
break;
case RS3_ID:
rsPort = rs3Port;
break;
case RS4_ID:
rsPort = rs4Port;
break;
default:
fail("Unknown RS id: " + rsId);
}
return rsPort;
}
/**
* Creates a new fake replication domain, using the passed scenario.
*
* @param serverId
* The server ID for the replication domain.
* @param groupId
* The group ID for the replication domain.
* @param rsId
* The replication server ID.
* @param generationId
* The generationID associated with data in the domain.
* @param assured
* Is this domain using assured replication.
* @param assuredMode
* The mode if assured replication is enabled.
* @param safeDataLevel
* The
* @param assuredTimeout
* The timeout for acks in assured mode.
* @param scenario
* The scenario identifier
* @param serverState
* The state of the server to start with
* @param startListen
* If true, we start the listen service. In all cases, the publish
* service gets started.
* @param window
* The window size for replication
* @return
* The FakeReplicationDomain, a mock-up of a Replication Domain
* for tests
* @throws Exception
*
*/
private FakeReplicationDomain createFakeReplicationDomain(int serverId,
int groupId, int rsId, long generationId, boolean assured,
AssuredMode assuredMode, int safeDataLevel, long assuredTimeout,
int scenario, ServerState serverState, boolean startListen, int window)
throws Exception
{
// Set port to right real RS according to its id
int rsPort = getRsPort(rsId);
FakeReplicationDomain fakeReplicationDomain = new FakeReplicationDomain(
DN.decode(TEST_ROOT_DN_STRING), serverId, generationId,
(byte)groupId, assured, assuredMode, (byte)safeDataLevel, assuredTimeout,
scenario, serverState);
List replicationServers = new ArrayList();
replicationServers.add("localhost:" + rsPort);
fakeReplicationDomain.startPublishService(replicationServers, window, 1000, 500);
if (startListen)
fakeReplicationDomain.startListenService();
// Test connection
assertTrue(fakeReplicationDomain.isConnected());
// Check connected server port
HostPort rd =
HostPort.valueOf(fakeReplicationDomain.getReplicationServer());
assertEquals(rd.getPort(), rsPort);
return fakeReplicationDomain;
}
/**
* Creates and connects a new fake replication server, using the passed scenario.
*/
private FakeReplicationServer createFakeReplicationServer(int serverId,
int groupId, int rsId, long generationId, boolean assured,
AssuredMode assuredMode, int safeDataLevel, ServerState serverState,
int scenario) throws Exception
{
// Set port to right real RS according to its id
int rsPort = getRsPort(rsId);
FakeReplicationServer fakeReplicationServer = new FakeReplicationServer(
rsPort, serverId, assured, assuredMode, (byte)safeDataLevel, (byte)groupId,
TEST_ROOT_DN_STRING, generationId);
// Connect fake RS to the real RS
fakeReplicationServer.connect(serverState);
// Start wished scenario
fakeReplicationServer.start(scenario);
return fakeReplicationServer;
}
/**
* Creates a new real replication server (one which is to be tested).
*/
private ReplicationServer createReplicationServer(int serverId, int groupId,
long assuredTimeout, String testCase, int nbRS) throws ConfigException
{
int port = getRsPort(serverId);
SortedSet otherRsUrls =
generateOtherReplicationServerUrls(port, nbRS);
String dir = testName + serverId + testCase + "Db";
ReplServerFakeConfiguration conf =
new ReplServerFakeConfiguration(port, dir, 0, serverId, 0, 100,
otherRsUrls, groupId, assuredTimeout, 5000);
// No monitoring publisher to not interfere with some SocketTimeoutException
// expected at some points in these tests
conf.setMonitoringPeriod(0L);
return new ReplicationServer(conf);
}
/**
* Returns a Set containing the URLs for the real Replication Servers
* (RS for short) for the specified number of RSs excluding the URL for the
* excludedRsPort. The returned Set size is nbRS - 1 (for the excluded port).
*
* @param excludedRsPort
* the RS port to exclude
* @param totalNbRS
* the total number of real RSs that will be part of the topology.
* @return a SortedSet containing the RS URLs.
*/
private SortedSet generateOtherReplicationServerUrls(
int excludedRsPort, int totalNbRS)
{
SortedSet replServers = new TreeSet();
if (totalNbRS >= 2)
{
addIfNotSame(replServers, rs1Port, excludedRsPort);
addIfNotSame(replServers, rs2Port, excludedRsPort);
if (totalNbRS >= 3)
{
addIfNotSame(replServers, rs3Port, excludedRsPort);
if (totalNbRS >= 4)
{
addIfNotSame(replServers, rs4Port, excludedRsPort);
}
}
}
return replServers;
}
private void addIfNotSame(Set replServers, int rsPort,
int excludedRsPort)
{
if (rsPort != excludedRsPort)
{
replServers.add("localhost:" + rsPort);
}
}
/**
* Fake replication domain implementation to test the replication server
* regarding the assured feature.
* According to the configured scenario, it will answer to updates with acks
* as the scenario is requesting.
*/
public class FakeReplicationDomain extends ReplicationDomain
{
/** The scenario this DS is expecting */
private int scenario = -1;
private long generationId = -1;
private CSNGenerator gen = null;
/** False if a received update had assured parameters not as expected */
private boolean everyUpdatesAreOk = true;
/** Number of received updates */
private int nReceivedUpdates = 0;
private int nWrongReceivedUpdates = 0;
/**
* Creates a fake replication domain (DS)
* @param baseDN The base dn used at connection to RS
* @param serverID our server id
* @param generationId the generation id we use at connection to real RS
* @param groupId our group id
* @param assured do we expect incoming assured updates (also used for outgoing updates)
* @param assuredMode the expected assured mode of the incoming updates (also used for outgoing updates)
* @param safeDataLevel the expected safe data level of the incoming updates (also used for outgoing updates)
* @param assuredTimeout the assured timeout used when sending updates
* @param scenario the scenario we are creating for (implies particular
* behavior upon reception of updates)
* @throws org.opends.server.config.ConfigException
*/
public FakeReplicationDomain(
DN baseDN,
int serverID,
long generationId,
byte groupId,
boolean assured,
AssuredMode assuredMode,
byte safeDataLevel,
long assuredTimeout,
int scenario,
ServerState serverState) throws ConfigException
{
super(baseDN, serverID, serverState);
this.generationId = generationId;
setGroupId(groupId);
setAssured(assured);
setAssuredMode(assuredMode);
setAssuredSdLevel(safeDataLevel);
setAssuredTimeout(assuredTimeout);
this.scenario = scenario;
gen = new CSNGenerator(serverID, 0L);
}
public boolean receivedUpdatesOk()
{
return everyUpdatesAreOk;
}
public int getReceivedUpdates()
{
return nReceivedUpdates;
}
public int getWrongReceivedUpdates()
{
return nWrongReceivedUpdates;
}
/**
* To get the session reference to be able to send our own acks
*/
@Override
public void sessionInitiated(
ServerStatus initStatus,
ServerState replicationServerState,
long generationId,
Session session)
{
super.sessionInitiated(initStatus, replicationServerState, generationId, session);
}
@Override
public long countEntries() throws DirectoryException
{
// Not needed for this test
return -1;
}
@Override
protected void exportBackend(OutputStream output) throws DirectoryException
{
// Not needed for this test
}
@Override
public long getGenerationID()
{
return generationId;
}
@Override
protected void importBackend(InputStream input) throws DirectoryException
{
// Not needed for this test
}
@Override
public boolean processUpdate(UpdateMsg updateMsg, AtomicBoolean shutdown)
{
checkUpdateAssuredParameters(updateMsg);
nReceivedUpdates++;
// Now execute the requested scenario
switch (scenario)
{
case REPLY_OK_DS_SCENARIO:
// Send the ack without errors
// Call processUpdateDone and update the server state is what needs to
// be done when using asynchronous process update mechanism
// (see processUpdate javadoc)
processUpdateDone(updateMsg, null);
getServerState().update(updateMsg.getCSN());
break;
case TIMEOUT_DS_SCENARIO:
// Let timeout occur
break;
case REPLAY_ERROR_DS_SCENARIO:
// Send the ack with replay error
// Call processUpdateDone and update the server state is what needs to
// be done when using asynchronous process update mechanism
// (see processUpdate javadoc)
processUpdateDone(updateMsg, "This is the replay error message generated from fake DS " +
getServerId() + " for update with CSN " + updateMsg.getCSN());
getServerState().update(updateMsg.getCSN());
break;
default:
fail("Unknown scenario: " + scenario);
}
// IMPORTANT: return false so that we use the asynchronous processUpdate mechanism
// (see processUpdate javadoc)
return false;
}
/**
* Check that received update assured parameters are as defined at DS start
*/
private void checkUpdateAssuredParameters(UpdateMsg updateMsg)
{
boolean ok = true;
if (updateMsg.isAssured() != isAssured())
{
debugInfo("Fake DS " + getServerId() + " received update assured flag is wrong: " + updateMsg);
ok = false;
}
if (updateMsg.getAssuredMode() != getAssuredMode())
{
debugInfo("Fake DS " + getServerId() + " received update assured mode is wrong: " + updateMsg);
ok = false;
}
if (updateMsg.getSafeDataLevel() != getAssuredSdLevel())
{
debugInfo("Fake DS " + getServerId() + " received update assured sd level is wrong: " + updateMsg);
ok = false;
}
if (ok)
debugInfo("Fake DS " + getServerId() + " received update assured parameters are ok: " + updateMsg);
else
{
everyUpdatesAreOk = false;
nWrongReceivedUpdates++;
}
}
/**
* Sends a new update from this DS
* @throws TimeoutException If timeout waiting for an assured ack
*/
public void sendNewFakeUpdate() throws TimeoutException
{
sendNewFakeUpdate(true);
}
/**
* Sends a new update from this DS using configured assured parameters or not
* @throws TimeoutException If timeout waiting for an assured ack
*/
public void sendNewFakeUpdate(boolean useAssured) throws TimeoutException
{
// Create a new delete update message (the simplest to create)
DeleteMsg delMsg =
new DeleteMsg(getBaseDNString(), gen.newCSN(),
UUID.randomUUID().toString());
// Send it (this uses the defined assured conf at constructor time)
if (useAssured)
prepareWaitForAckIfAssuredEnabled(delMsg);
publish(delMsg);
if (useAssured)
waitForAckIfAssuredEnabled(delMsg);
}
}
/**
* The fake replication server used to emulate RS behavior the way we want
* for assured features test.
* This fake replication server is able to receive another RS connection only.
* According to the configured scenario, it will answer to updates with acks
* as the scenario is requesting.
*/
private static int fakePort = 0;
private class FakeReplicationServer extends Thread
{
private boolean shutdown = false;
private Session session = null;
/** Parameters given at constructor time */
private int port;
private int serverId = -1;
boolean isAssured = false; // Default value for config
AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config
byte safeDataLevel = (byte) 1; // Default value for config
private String baseDn = null;
private long generationId = -1L;
private byte groupId = (byte) -1;
private boolean sslEncryption = false;
/** The scenario this RS is expecting */
private int scenario = -1;
private CSNGenerator gen = null;
/** False if a received update had assured parameters not as expected */
private boolean everyUpdatesAreOk = true;
/** Number of received updates */
private int nReceivedUpdates = 0;
/**
* True if an ack has been replied to a received assured update (in assured
* mode of course) used in reply scenario
*/
private boolean ackReplied = false;
/**
* Creates a fake replication server
* @param port port of the real RS we will connect to
* @param serverId our server id
* @param assured do we expect incoming assured updates (also used for outgoing updates)
* @param assuredMode the expected assured mode of the incoming updates (also used for outgoing updates)
* @param safeDataLevel the expected safe data level of the incoming updates (also used for outgoing updates)
* @param groupId our group id
* @param baseDn the basedn we connect with, to the real RS
* @param generationId the generation id we use at connection to real RS
*/
public FakeReplicationServer(int port, int serverId, boolean assured,
AssuredMode assuredMode, int safeDataLevel,
byte groupId, String baseDn, long generationId)
{
this.port = port;
this.serverId = serverId;
this.baseDn = baseDn;
this.generationId = generationId;
this.groupId = groupId;
this.isAssured = assured;
this.assuredMode = assuredMode;
this.safeDataLevel = (byte) safeDataLevel;
gen = new CSNGenerator(serverId + 10, 0L);
}
/**
* Make the RS send an assured message and return the ack message it
* receives from the RS
*/
public AckMsg sendNewFakeUpdate() throws Exception
{
// Create a new delete update message (the simplest to create)
DeleteMsg delMsg = new DeleteMsg(baseDn, gen.newCSN(),
UUID.randomUUID().toString());
// Send del message in assured mode
delMsg.setAssured(isAssured);
delMsg.setAssuredMode(assuredMode);
delMsg.setSafeDataLevel(safeDataLevel);
session.publish(delMsg);
// Read and return matching ack
ReplicationMsg replMsg = session.receive();
if (replMsg instanceof ErrorMsg)
{
// Support for connection done with bad gen id : we receive an error
// message that we must throw away before reading our ack.
replMsg = session.receive();
}
return (AckMsg)replMsg;
}
/**
* Connect to RS
*/
public void connect(ServerState serverState) throws Exception
{
// Create and connect socket
InetSocketAddress serverAddr =
new InetSocketAddress("localhost", port);
Socket socket = new Socket();
socket.setTcpNoDelay(true);
int timeoutMS = MultimasterReplication.getConnectionTimeoutMS();
socket.connect(serverAddr, timeoutMS);
// Create client session
fakePort++;
String fakeUrl = "localhost:" + fakePort;
ReplSessionSecurity replSessionSecurity = new ReplSessionSecurity();
session = replSessionSecurity.createClientSession(socket, timeoutMS);
// Send our repl server start msg
ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId,
fakeUrl, baseDn, 100, serverState,
generationId, sslEncryption,
groupId, 5000);
session.publish(replServerStartMsg);
// Read repl server start msg
ReplServerStartMsg inReplServerStartMsg = (ReplServerStartMsg) session.
receive();
sslEncryption = inReplServerStartMsg.getSSLEncryption();
if (!sslEncryption)
{
session.stopEncryption();
}
// Send our topo mesg
RSInfo rsInfo = new RSInfo(serverId, fakeUrl, generationId, groupId, 1);
List rsInfos = new ArrayList();
rsInfos.add(rsInfo);
TopologyMsg topoMsg = new TopologyMsg(null, rsInfos);
session.publish(topoMsg);
// Read topo msg
TopologyMsg inTopoMsg = (TopologyMsg) session.receive();
debugInfo("Fake RS " + serverId + " handshake received the following info:" + inTopoMsg);
}
/**
* Starts the fake RS, expecting and testing the passed scenario.
*/
public void start(int scenario)
{
// Store expected test case
this.scenario = scenario;
if (scenario == SENDER_RS_SCENARIO)
{
// Do not start the listening thread and let the main thread receive
// receive acks in sendNewFakeUpdate()
return;
}
// Start listening
start();
}
/**
* Wait for DS connections
*/
@Override
public void run()
{
try
{
// Loop receiving and treating updates
while (!shutdown)
{
try
{
ReplicationMsg replicationMsg = session.receive();
if (!(replicationMsg instanceof UpdateMsg))
{
debugInfo("Fake RS " + serverId + " received non update message: " +
replicationMsg);
continue;
}
UpdateMsg updateMsg = (UpdateMsg) replicationMsg;
checkUpdateAssuredParameters(updateMsg);
nReceivedUpdates++;
// Now execute the requested scenario
switch (scenario)
{
case REPLY_OK_RS_SCENARIO:
if (updateMsg.isAssured())
{
// Send the ack without errors
AckMsg ackMsg = new AckMsg(updateMsg.getCSN());
session.publish(ackMsg);
ackReplied = true;
}
break;
case TIMEOUT_RS_SCENARIO:
// Let timeout occur
break;
case DS_TIMEOUT_RS_SCENARIO_SAFE_READ:
if (updateMsg.isAssured())
{
// Emulate RS waiting for virtual DS ack
sleep(MAX_SEND_UPDATE_TIME);
// Send the ack with timeout error from a virtual DS with id (ours + 10)
AckMsg ackMsg = new AckMsg(updateMsg.getCSN());
ackMsg.setHasTimeout(true);
List failedServers = new ArrayList();
failedServers.add(serverId + 10);
ackMsg.setFailedServers(failedServers);
session.publish(ackMsg);
ackReplied = true;
}
break;
case DS_WRONG_STATUS_RS_SCENARIO_SAFE_READ:
if (updateMsg.isAssured())
{
// Send the ack with wrong status error from a virtual DS with id (ours + 10)
AckMsg ackMsg = new AckMsg(updateMsg.getCSN());
ackMsg.setHasWrongStatus(true);
List failedServers = new ArrayList();
failedServers.add(serverId + 10);
ackMsg.setFailedServers(failedServers);
session.publish(ackMsg);
ackReplied = true;
}
break;
case DS_REPLAY_ERROR_RS_SCENARIO_SAFE_READ:
if (updateMsg.isAssured())
{
// Send the ack with replay error from a virtual DS with id (ours + 10)
AckMsg ackMsg = new AckMsg(updateMsg.getCSN());
ackMsg.setHasReplayError(true);
List failedServers = new ArrayList();
failedServers.add(serverId + 10);
ackMsg.setFailedServers(failedServers);
session.publish(ackMsg);
ackReplied = true;
}
break;
default:
fail("Unknown scenario: " + scenario);
}
} catch (SocketTimeoutException toe)
{
// We may timeout reading, in this case just re-read
debugInfo("Fake RS " + serverId + " : " + toe.
getMessage() + " (this is normal)");
}
}
} catch (Throwable th)
{
debugInfo("Terminating thread of fake RS " + serverId + " :" + th.
getMessage());
// Probably thread closure from main thread
}
}
/**
* Shutdown the Replication Server service and all its connections.
*/
public void shutdown()
{
if (shutdown)
{
return;
}
shutdown = true;
// Shutdown any current client handling code
if (session != null)
{
session.close();
}
try
{
join();
} catch (InterruptedException ignored)
{
}
}
/**
* Check that received update assured parameters are as defined at RS start
*/
private void checkUpdateAssuredParameters(UpdateMsg updateMsg)
{
boolean ok = true;
if (updateMsg.isAssured() != isAssured)
{
debugInfo("Fake RS " + serverId + " received update assured flag is wrong: " + updateMsg);
ok = false;
}
if (updateMsg.getAssuredMode() != assuredMode)
{
debugInfo("Fake RS " + serverId + " received update assured mode is wrong: " + updateMsg);
ok = false;
}
if (updateMsg.getSafeDataLevel() != safeDataLevel)
{
debugInfo("Fake RS " + serverId + " received update assured sd level is wrong: " + updateMsg);
ok = false;
}
if (ok)
debugInfo("Fake RS " + serverId + " received update assured parameters are ok: " + updateMsg);
else
everyUpdatesAreOk = false;
}
public boolean receivedUpdatesOk()
{
return everyUpdatesAreOk;
}
public int getReceivedUpdates()
{
return nReceivedUpdates;
}
/**
* Test if the last received updates was acknowledged (ack sent with or
* without errors).
*
* WARNING: this must be called once per update as it also immediately
* resets the status for a new test for the next update
*
*
* @return True if acknowledged
*/
public boolean ackReplied()
{
boolean result = ackReplied;
// reset ack replied status
ackReplied = false;
return result;
}
}
/**
* See testSafeDataLevelOne comment.
* This is a facility to run the testSafeDataLevelOne in precommit in simplest
* case, so that precommit run test something and is not long.
* testSafeDataLevelOne will run in nightly tests (groups = "slow")
*/
@Test(enabled = true)
public void testSafeDataLevelOnePrecommit() throws Exception
{
testSafeDataLevelOne(DEFAULT_GID, false, false, DEFAULT_GID, DEFAULT_GID);
}
/**
* Returns possible combinations of parameters for testSafeDataLevelOne test
*/
@DataProvider(name = "testSafeDataLevelOneProvider")
private Object[][] testSafeDataLevelOneProvider()
{
return new Object[][]
{
{ DEFAULT_GID, false, false, DEFAULT_GID, DEFAULT_GID},
{ DEFAULT_GID, false, false, OTHER_GID, DEFAULT_GID},
{ DEFAULT_GID, false, false, DEFAULT_GID, OTHER_GID},
{ DEFAULT_GID, false, false, OTHER_GID, OTHER_GID},
{ DEFAULT_GID, true, false, DEFAULT_GID, DEFAULT_GID},
{ DEFAULT_GID, true, false, OTHER_GID, DEFAULT_GID},
{ DEFAULT_GID, true, false, DEFAULT_GID, OTHER_GID},
{ DEFAULT_GID, true, false, OTHER_GID, OTHER_GID},
{ DEFAULT_GID, false, true, DEFAULT_GID, DEFAULT_GID},
{ DEFAULT_GID, false, true, OTHER_GID, DEFAULT_GID},
{ DEFAULT_GID, false, true, DEFAULT_GID, OTHER_GID},
{ DEFAULT_GID, false, true, OTHER_GID, OTHER_GID},
{ DEFAULT_GID, true, true, DEFAULT_GID, DEFAULT_GID},
{ DEFAULT_GID, true, true, OTHER_GID, DEFAULT_GID},
{ DEFAULT_GID, true, true, DEFAULT_GID, OTHER_GID},
{ DEFAULT_GID, true, true, OTHER_GID, OTHER_GID},
{ OTHER_GID, false, false, DEFAULT_GID, DEFAULT_GID},
{ OTHER_GID, false, false, OTHER_GID, DEFAULT_GID},
{ OTHER_GID, false, false, DEFAULT_GID, OTHER_GID},
{ OTHER_GID, false, false, OTHER_GID, OTHER_GID},
{ OTHER_GID, true, false, DEFAULT_GID, DEFAULT_GID},
{ OTHER_GID, true, false, OTHER_GID, DEFAULT_GID},
{ OTHER_GID, true, false, DEFAULT_GID, OTHER_GID},
{ OTHER_GID, true, false, OTHER_GID, OTHER_GID},
{ OTHER_GID, false, true, DEFAULT_GID, DEFAULT_GID},
{ OTHER_GID, false, true, OTHER_GID, DEFAULT_GID},
{ OTHER_GID, false, true, DEFAULT_GID, OTHER_GID},
{ OTHER_GID, false, true, OTHER_GID, OTHER_GID},
{ OTHER_GID, true, true, DEFAULT_GID, DEFAULT_GID},
{ OTHER_GID, true, true, OTHER_GID, DEFAULT_GID},
{ OTHER_GID, true, true, DEFAULT_GID, OTHER_GID},
{ OTHER_GID, true, true, OTHER_GID, OTHER_GID}
};
}
/**
* Test that the RS is able to acknowledge SD updates sent by SD, with level 1.
* - 1 main fake DS connected to 1 RS, with same GID as RS or not
* - 1 optional other fake DS connected to RS, with same GID as RS or not
* - 1 optional other fake RS connected to RS, with same GID as RS or not
* All possible combinations tested thanks to the provider
*/
@Test(dataProvider = "testSafeDataLevelOneProvider",
groups = { "slow", "opendj-256" },
enabled = true)
public void testSafeDataLevelOne(
int mainDsGid, boolean otherFakeDS, boolean fakeRS,
int otherFakeDsGid, int fakeRsGid) throws Exception
{
String testCase = "testSafeDataLevelOne";
debugInfo("Starting " + testCase);
initTest();
try
{
/*
* Start real RS (the one to be tested)
*/
// Create real RS 1
rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT,
testCase, 0);
assertNotNull(rs1);
/*
* Start main DS (the one which sends updates)
*/
// Create and connect fake domain 1 to RS 1
// Assured mode: SD, level 1
fakeRd1 = createFakeReplicationDomain(FDS1_ID, mainDsGid, RS1_ID,
DEFAULT_GENID, true, AssuredMode.SAFE_DATA_MODE, 1, LONG_TIMEOUT,
TIMEOUT_DS_SCENARIO);
assertNotNull(fakeRd1);
/*
* Start one other fake DS
*/
// Put another fake domain connected to real RS ?
if (otherFakeDS)
{
// Assured set to false as RS should forward change without assured requested
// Timeout scenario used so that no reply is made if however the real RS
// by mistake sends an assured error and expects an ack from this DS:
// this would timeout. If main DS group id is not the same as the real RS one,
// the update will even not come to real RS as assured
fakeRd2 = createFakeReplicationDomain(FDS2_ID, otherFakeDsGid, RS1_ID,
DEFAULT_GENID, false, AssuredMode.SAFE_DATA_MODE, 1, LONG_TIMEOUT,
TIMEOUT_DS_SCENARIO);
assertNotNull(fakeRd2);
}
/*
* Start 1 fake Rs
*/
// Put a fake RS connected to real RS ?
if (fakeRS)
{
// Assured set to false as RS should forward change without assured requested
// Timeout scenario used so that no reply is made if however the real RS
// by mistake sends an assured error and expects an ack from this fake RS:
// this would timeout. If main DS group id is not the same as the real RS one,
// the update will even not come to real RS as assured
fakeRs1 = createFakeReplicationServer(FRS1_ID, fakeRsGid, RS1_ID,
DEFAULT_GENID, false, AssuredMode.SAFE_DATA_MODE, 1, new ServerState(), TIMEOUT_RS_SCENARIO);
assertNotNull(fakeRs1);
}
// Send update from DS 1
long startTime = System.currentTimeMillis();
fakeRd1.sendNewFakeUpdate();
// Check call time (should have last a lot less than long timeout)
// (ack received if group id of DS and real RS are the same, no ack requested
// otherwise)
long sendUpdateTime = System.currentTimeMillis() - startTime;
assertTrue(sendUpdateTime < MAX_SEND_UPDATE_TIME);
Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked
if (mainDsGid == DEFAULT_GID)
{
// Check monitoring values (check that ack has been correctly received)
assertEquals(fakeRd1.getAssuredSdSentUpdates(), 1);
assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), 1);
assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), 0);
assertEquals(fakeRd1.getAssuredSdServerTimeoutUpdates().size(), 0);
} else
{
// Check monitoring values (DS group id (OTHER_GID) is not the same as RS one
// (DEFAULT_GID) so update should have been sent in normal mode
assertEquals(fakeRd1.getAssuredSdSentUpdates(), 0);
assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), 0);
assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), 0);
assertEquals(fakeRd1.getAssuredSdServerTimeoutUpdates().size(), 0);
}
// Sanity check
Thread.sleep(500); // Let time to update to reach other servers
assertEquals(fakeRd1.getReceivedUpdates(), 0);
assertTrue(fakeRd1.receivedUpdatesOk());
if (otherFakeDS)
{
assertEquals(fakeRd2.getReceivedUpdates(), 1);
assertTrue(fakeRd2.receivedUpdatesOk());
}
if (fakeRS)
{
assertEquals(fakeRs1.getReceivedUpdates(), 1);
assertTrue(fakeRs1.receivedUpdatesOk());
}
} finally
{
endTest();
}
}
/**
* Returns possible combinations of parameters for testSafeDataLevelHighPrecommit test
*/
@DataProvider(name = "testSafeDataLevelHighPrecommitProvider")
private Object[][] testSafeDataLevelHighPrecommitProvider()
{
return new Object[][]
{
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}
};
}
/**
* See testSafeDataLevelHigh comment.
*/
@Test(dataProvider = "testSafeDataLevelHighPrecommitProvider", groups = "slow", enabled = true)
public void testSafeDataLevelHighPrecommit(int sdLevel, boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId,
int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen,
int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) throws Exception
{
testSafeDataLevelHigh(sdLevel, otherFakeDS, otherFakeDsGid, otherFakeDsGenId,
fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen,
fakeRs3Gid, fakeRs3GenId, fakeRs3Scen);
}
/**
* Returns possible combinations of parameters for testSafeDataLevelHighNightly test
*/
@DataProvider(name = "testSafeDataLevelHighNightlyProvider")
private Object[][] testSafeDataLevelHighNightlyProvider()
{
return new Object[][]
{
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO},
{ 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}
};
}
/**
* See testSafeDataLevelHigh comment.
*/
@Test(dataProvider = "testSafeDataLevelHighNightlyProvider", groups = "slow", enabled = true)
public void testSafeDataLevelHighNightly(int sdLevel, boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId,
int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen,
int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) throws Exception
{
testSafeDataLevelHigh(sdLevel, otherFakeDS, otherFakeDsGid, otherFakeDsGenId,
fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen,
fakeRs3Gid, fakeRs3GenId, fakeRs3Scen);
}
/**
* Returns possible combinations of parameters for testSafeDataLevelHigh test
*/
@DataProvider(name = "testSafeDataLevelHighProvider")
private Object[][] testSafeDataLevelHighProvider()
{
// Construct all possible combinations of parameters
List> objectArrayList = new ArrayList>();
// Safe Data Level
objectArrayList = addPossibleParameters(objectArrayList, 2, 3);
// Other fake DS
objectArrayList = addPossibleParameters(objectArrayList, true, false);
// Other fake DS group id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GID, OTHER_GID);
// Other fake DS generation id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID);
// Fake RS 1 group id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GID, OTHER_GID);
// Fake RS 1 generation id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID);
// Fake RS 1 scenario
objectArrayList = addPossibleParameters(objectArrayList, REPLY_OK_RS_SCENARIO, TIMEOUT_RS_SCENARIO);
// Fake RS 2 group id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GID, OTHER_GID);
// Fake RS 2 generation id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID);
// Fake RS 2 scenario
objectArrayList = addPossibleParameters(objectArrayList, REPLY_OK_RS_SCENARIO, TIMEOUT_RS_SCENARIO);
// Fake RS 3 group id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GID, OTHER_GID);
// Fake RS 3 generation id
objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID);
// Fake RS 3 scenario
objectArrayList = addPossibleParameters(objectArrayList, REPLY_OK_RS_SCENARIO, TIMEOUT_RS_SCENARIO);
Object[][] result = new Object[objectArrayList.size()][];
int i = 0;
for (List
*/
private List> addPossibleParameters(List> objectArrayList, Object... possibleParameters)
{
List> newObjectArrayList = new ArrayList>();
if (objectArrayList.size() == 0)
{
// First time we add some parameters, create first object arrays
// Add each possible parameter as initial parameter lists
for (Object possibleParameter : possibleParameters)
{
// Create new empty list
List