ProtocolCompatibilityTest.java revision e371bf13d3f899f1de594880fafe67b990d65899
/*
* 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
* 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 2009-2010 Sun Microsystems, Inc.
* Portions copyright 2011-2013 ForgeRock AS
*/
/**
* Test the conversions between the various protocol versions.
*/
@SuppressWarnings("javadoc")
public class ProtocolCompatibilityTest extends ReplicationTestCase {
/**
* Set up the environment for performing the tests in this Class.
*
* @throws Exception
* If the environment could not be set up.
*/
{
super.setUp();
}
/**
* Clean up the environment.
*
* @throws Exception If the environment could not be set up.
*/
public void classCleanUp() throws Exception
{
super.classCleanUp();
}
{
baseDN = "dc=example,dc=com";
state = new ServerState();
}
/**
* Test that various combinations of ReplServerStartMsg encoding and decoding
* using protocol VLAST and V2 are working.
*/
{
// TODO: replServerStartMsgTestV3V2 as soon as V3 will have any incompatibility with V2
}
{
// Create message with no version.
// Serialize in V1
// Un-serialize V1 message
// Check original version of message
// Check fields common to both versions
// Check default value for only post V1 fields
// Set again only post V1 fields
// Serialize in VLAST msg
// Check original version of message
// Check we retrieve original V3 message (V3 fields)
}
public Object[][] createAddData()
{
// Entry attributes
return new Object[][] {
}
throws Exception
{
// TODO: addMsgTest as soon as V3 will have any incompatibility with V2
}
throws Exception
{
// Create VLAST message
.getObjectClassAttributeType(), "organization");
"organization");
HashMap<AttributeType, List<Attribute>> userAttList = new HashMap<AttributeType, List<Attribute>>();
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Check version of message
// Serialize in V1
// Un-serialize V1 message
// Check original version of message
// Check fields common to both versions
// Create an add operation from each message to compare attributes (kept encoded in messages)
// Check default value for only VLAST fields
// Set again only VLAST fields
if (entryAttrList != null)
{
}
// Serialize in VLAST msg
// Check original version of message
// Check we retrieve original VLAST message (VLAST fields)
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create an add operation from each message to compare attributes (kept encoded in messages)
}
/**
* Build some data for the DeleteMsg test below.
*/
public Object[][] createDeleteData()
{
// Entry attributes
return new Object[][] {
{"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn", true, AssuredMode.SAFE_READ_MODE, (byte)1, entryAttrList},
}
/**
* Test that various combinations of DeleteMsg encoding and decoding
* using protocol V2 and VLAST are working.
*/
throws Exception
{
// TODO: deleteMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
}
/**
* Test that various combinations of DeleteMsg encoding and decoding
* using protocol V1 and VLAST are working.
*/
throws Exception
{
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Check version of message
// Serialize in V1
// Un-serialize V1 message
// Check original version of message
// Check fields common to both versions
// Check default value for only VLAST fields
// Set again only VLAST fields
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Serialize in VLAST msg
// Check original version of message
// Check we retrieve original VLAST message (VLAST fields)
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
}
/**
* Build some data for the ModifyMsg test below.
*/
public Object[][] createModifyData() {
for (int i = 0; i < 10; i++)
{
}
// Entry attributes
return new Object[][] {
{ csn2, "dc=test with a much longer dn in case this would "
{ csn2, "dc=test, cn=with a, o=more complex, ou=dn", mods1, false, AssuredMode.SAFE_READ_MODE, (byte) 5, entryAttrList },
{ csn2, "dc=test with several mod", mods2, false, AssuredMode.SAFE_DATA_MODE, (byte) 16, entryAttrList },
{ csn2, "dc=test with long mod", mods4, true, AssuredMode.SAFE_READ_MODE, (byte) 120, entryAttrList },
};
}
/**
* Test that various combinations of ModifyMsg encoding and decoding
* using protocol V1 and V2 are working.
*/
byte safeDataLevel,
throws Exception
{
// TODO: modifyMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
}
/**
* Test that various combinations of ModifyMsg encoding and decoding
* using protocol V1 and VLAST are working.
*/
byte safeDataLevel,
throws Exception
{
// Create VLAST message
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Check version of message
// Serialize in V1
// Un-serialize V1 message
// Check original version of message
// Check fields common to both versions
// Create a modify operation from each message to compare mods (kept encoded in messages)
// Check default value for only VLAST fields
// Set again only VLAST fields
if (entryAttrList != null)
{
}
// Serialize in VLAST msg
// Check original version of message
// Check we retrieve original VLAST message (VLAST fields)
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create a modify operation from each message to compare mods (kept encoded in messages)
}
public Object[][] createModifyDnData() {
for (int i = 0; i < 10; i++)
{
}
// Entry attributes
return new Object[][] {
{"dc=test,dc=com", "dc=new", "11111111-1111-1111-1111-111111111111", "22222222-2222-2222-2222-222222222222", false, "dc=change", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte)0, null},
{"dc=test,dc=com", "dc=new", "33333333-3333-3333-3333-333333333333", "44444444-4444-4444-4444-444444444444", true, "dc=change", mods2, true, AssuredMode.SAFE_READ_MODE, (byte)1, entryAttrList},
{"dc=test,dc=com", "dc=new", "55555555-5555-5555-5555-555555555555", "66666666-6666-6666-6666-666666666666", false, null, mods3, true, AssuredMode.SAFE_READ_MODE, (byte)3, null},
{"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn",
"dc=new", "77777777-7777-7777-7777-777777777777", "88888888-8888-8888-8888-888888888888",true, null, mods4, true, AssuredMode.SAFE_DATA_MODE, (byte)99, entryAttrList},
};
}
/**
* Test that various combinations of ModifyDnMsg encoding and decoding
* using protocol VLAST and V2 are working.
*/
throws Exception
{
// TODO: modifyMsgTestVLASTV2 as soon as V3 will have any incompatibility with V2
}
/**
* Test that various combinations of ModifyDnMsg encoding and decoding
* using protocol VLAST and V1 are working.
*/
throws Exception
{
// Create VLAST message
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Check version of message
// Serialize in V1
// Un-serialize V1 message
// Check original version of message
// Check fields common to both versions
// Create a modDn operation from each message to compare fields)
// Check default value for only VLAST fields
// Set again only VLAST fields
// Set ECL entry attributes
if (entryAttrList != null)
{
}
// Serialize in VLAST msg
// Check original version of message
// Check we retrieve original VLAST message (VLAST fields)
// Get ECL entry attributes
if (entryAttrList==null)
else
{
int i=0;
{
i++;
}
}
// Create a modDn operation from each message to compare mods (kept encoded in messages)
}
private static byte[] hexStringToByteArray(String s)
{
{
data[i / 2] =
}
return data;
}
public Object[][] createOldUpdateData()
{
return new Object[][] {
{"1603303030303030303030303030303030313030303130303030303030300064633" +
"d746573740066616b65756e69717565696400000200301f0a0102301a040b646573" +
"6372697074696f6e310b04096e65772076616c756500",
{"1803303030303031323366313238343132303030326430303030303037620064633" +
"d636f6d00756e69717565696400000201",
{"1803303030303031323366313238343132303030326430303030303037620064633" +
"d64656c6574652c64633d616e2c64633d656e7472792c64633d776974682c64633d" +
"612c64633d6c6f6e6720646e00756e69717565696400000201",
"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn"},
{"1903303030303031323366313238613762333030326430303030303037620064633" +
"d746573742c64633d636f6d00756e6971756569640000020164633d6e6577006463" +
"3d6368616e6765006e6577706172656e7449640000301f0a0102301a040b6465736" +
"372697074696f6e310b04096e65772076616c756500",
{"1703303030303031323366313239333431323030326430303030303037620064633" +
"d6578616d706c652c64633d636f6d0074686973497361556e697175654944000002" +
"00706172656e74556e69717565496400301d040b6f626a656374436c617373310e0" +
"40c6f7267616e697a6174696f6e300a04016f31050403636f6d301c040c63726561" +
"746f72736e616d65310c040a64633d63726561746f72",
};
}
/**
* The goal of this test is to verify that we keep the compatibility with
* older version of the replication protocol when doing new developments.
*
* This test checks that the current code is able to decode
* ReplicationMessages formatted by the older versions of the code
* and is able to format PDU in the same way.
*
* The data provider generates arguments containing a pre-formatted
* UpdateMsg and the corresponding data.
*
*/
public void createOldUpdate(
{
}
public Object[][] createOldServerStartData()
{
return new Object[][] { {
"14"
+ "31323438001f6f3d74657374003136006675726f6e0030003000"
+ "300030003130300031303000747275650032363300303030303030303030303030303034"
+ "623031303730303030303030350000", 16, "o=test", (byte) 31, } };
}
public void oldServerStartPDUs(
{
// This test only checks serverId dn and groupId
// It would be nice to complete it with checks for ServerState and other
// parameters
}
public Object[][] createOldReplServerStartData()
{
return new Object[][] {
{"15033132343500196f3d7465737400313600616e6f74686572486f73" +
"743a31303235003130300074727565003334353600323633003030303030303030303030" +
"30303034623031303730303030303030350000",
16, "o=test", (byte) 25}
};
}
public void oldReplServerStartPDUs(
{
// This is a ServerStartMSg with ServerId=16, baseDn=o=test and groupID=31
// For now this test only checks those parameters.
// It would be nice to complete it with checks for ServerState and other
// parameters.
}
public Object[][] createoldAckMsgData()
{
return new Object[][] {
{"05303030303031323366316535383832383030326430303030303037" +
"6200010101313030003230303000333030303000",
};
}
{
// We use V4 here because these PDU have not changed since 2.0.
//BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V4));
//assertEquals(bi.toString(16), oldPdu);
}
public Object[][] createStartSessionData()
{
return new Object[][] {
{"1b010102016c6461703a2f2f6c6461702e69706c616e65742e636f6d2f6f3d74657" +
"3743f3f7375623f28736e3d4a656e73656e29006c646170733a2f2f6c6461702e69" +
"706c616e65742e636f6d3a343034312f7569643d626a656e73656e2c6f753d50656" +
"f706c652c6f3d746573743f636e2c6d61696c2c74656c6570686f6e654e756d62657200",
{ "1b0200017b6c6461703a2f2f6c6461702e6578616d706c652e636f6d2f6f3d7465" +
"73743f6f626a656374436c6173733f6f6e65006c6461703a2f2f686f73742e6578" +
"616d706c652e636f6d2f6f753d70656f706c652c6f3d746573743f3f3f28736e3d612a2900",
};
}
throws Exception
{
}
{
false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>(), new HashSet<String>(), (short)-1);
true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>(), new HashSet<String>(), (short)-1);
false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>(), new HashSet<String>(), (short)-1);
true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>(), new HashSet<String>(), (short)-1);
return new Object [][] {
{"1a01313300323600313534363331000300020c84026c6461703a2f2f6c6461702e697" +
"06c616e65742e636f6d2f6f3d746573743f3f7375623f28736e3d4a656e73656e2900" +
"6c646170733a2f2f6c6461702e69706c616e65742e636f6d3a343034312f7569643d6" +
"26a656e73656e2c6f753d50656f706c652c6f3d746573743f636e2c6d61696c2c7465" +
{"1a0434313500313436003000040102020f026c646170733a2f2f686f73743a706f727" +
"42f64633d666f6f626172313f3f7375623f28736e3d416e6f7468657220456e747279" +
"203129006c646170733a2f2f686f73743a706f72742f64633d666f6f626172323f3f7" +
"375623f28736e3d416e6f7468657220456e7472792032290032343336003539310030" +
"000100011100016c646170733a2f2f686f73743a706f72742f64633d666f6f3f3f737" +
"5623f28736e3d4f6e6520456e74727929002d34333600343933002d32323738393600" +
"020101f9f700313300323600313534363331000300020c84026c6461703a2f2f6c646" +
"1702e69706c616e65742e636f6d2f6f3d746573743f3f7375623f28736e3d4a656e73" +
"656e29006c646170733a2f2f6c6461702e69706c616e65742e636f6d3a343034312f7" +
"569643d626a656e73656e2c6f753d50656f706c652c6f3d746573743f636e2c6d6169" +
"6c2c74656c6570686f6e654e756d62657200033435323700343533313600673435323" +
};
}
throws Exception
{
}
{
int sid = 1;
int dest = 2;
int pos = 0;
int length = 2;
int msgid = 14;
}
/**
* Test that various combinations of EntryMsg encoding and decoding
* using protocol VLAST and V3 are working.
*/
{
// Create VLAST message
// Serialize in V3
// Un-serialize V3 message
// Check fields common to both versions
// Check default value for only post V3 fields
// Set again only post V3 fields
// Serialize in VLAST
// Check we retrieve original VLAST message (VLAST fields)
}
{
int sender = 1;
int dest = 2;
}
/**
* Test that various combinations of ErrorMsg encoding and decoding
* using protocol VLAST and V3 are working.
*/
throws Exception
{
// Create VLAST message
// Serialize in V3
// Un-serialize V3 message
// Check fields common to both versions
// Set again only post V3 fields
// Serialize in VLAST
// Check we retrieve original VLAST message (VLAST fields)
}
{
int sender = 1;
int dest = 2;
int initWindow = 22;
}
/**
* Test that various combinations of ErrorMsg encoding and decoding
* using protocol VLAST and V3 are working.
*/
throws Exception
{
// Create VLAST message
// Serialize in V3
// Un-serialize V3 message
InitializeRequestMsg newMsg = new InitializeRequestMsg(v3MsgBytes, ProtocolVersion.REPLICATION_PROTOCOL_V3);
// Check fields common to both versions
// Check default value for only post V3 fields
// Set again only post V3 fields
// Serialize in VLAST
// Check we retrieve original VLAST message (VLAST fields)
}
{
int sender = 1;
int dest = 2;
int initiator = 3;
int entryCount = 56;
int initWindow = 22;
entryCount, initWindow };
}
/**
* Test that various combinations of ErrorMsg encoding and decoding
* using protocol VLAST and V3 are working.
*/
throws Exception
{
// Create VLAST message
// Serialize in V3
// Un-serialize V3 message
InitializeTargetMsg newMsg = new InitializeTargetMsg(v3MsgBytes, ProtocolVersion.REPLICATION_PROTOCOL_V3);
// Check fields common to both versions
// Check default value for only post V3 fields
// Set again only post V3 fields
// Serialize in VLAST
// Check we retrieve original VLAST message (VLAST fields)
}
public Object[][] createEntryMsgV3()
{
return new Object[][] {
{"0c32003100646e3a206f753d50656f706c652c64633d6578616d706c652c64633d636f6d0a6f626a656374436c6173733a20746f700a6f626a656374436c6173733a206f7267616e697a6174696f6e616c556e69740a6f753a2050656f706c650a656e747279555549443a2032313131313131312d313131312d313131312d313131312d3131313131313131313131320a0a00",
1, 2}};
}
public void entryMsgPDUV3(
{
// this msg is changed by V4, so we want to test that V>3 server can
// build a V>3 version when it receives a V3 PDU from a V3 server.
// we should test EntryBytes
}
public Object[][] createErrorMsgV3()
{
return new Object[][] {
{"0e380039003135313338383933004f6e207375666669782064633d6578616d706c652c64633d636f6d2c207265706c69636174696f6e2073657276657220392070726573656e7465642067656e65726174696f6e2049443d2d31207768656e2065787065637465642067656e65726174696f6e2049443d343800",
9, 8, "On suffix dc=example,dc=com, replication server 9 presented generation ID=-1 when expected generation ID=48"}};
}
public void errorMsgPDUV3(
{
// this msg is changed by V4, so we want to test that V>3 server can
// build a V>3 version when it receives a V3 PDU from a V3 server.
}
public Object[][] createInitializeTargetMsgV3()
{
return new Object[][] {
{"0b320064633d6578616d706c652c64633d636f6d00310032003400",
"dc=example,dc=com", 2, 1, 4}};
}
public void initializeTargetMsgPDUV3(
{
// this msg is changed by V4, so we want to test that V>3 server can
// build a V>3 version when it receives a V3 PDU from a V3 server.
}
public Object[][] createInitializeRequestMsgV3()
{
return new Object[][] {
{"0a64633d6578616d706c652c64633d636f6d0032003100",
"dc=example,dc=com", 1, 2}};
}
public void initializeRequestMsgPDUV3(
{
// this msg is changed by V4, so we want to test that V>3 server can
// build a V>3 version when it receives a V3 PDU from a V3 server.
}
}