TestVerifyJob.java revision 8ac57ee1cd50fcc3d02b36bea4ab1335924f1d7a
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
@SuppressWarnings("javadoc")
public class TestVerifyJob extends JebTestCase
{
/** Root suffix for verify backend. */
private EntryContainer eContainer;
private Index id2subtree;
private Transaction txn;
/** Some DNs needed mostly for DN2ID tests. */
/** This DN has no parent. */
/** Bad DN. */
/** This index file should not exist. */
return new Object[][] {
{ "telephoneNumber"},
{"givenName"},
{ "id2subtree"},
{"id2children"},
{"dn2id"}
};
}
"define suffix="+suffix,
"define maildomain=example.com",
"define numusers= #numEntries#",
"",
"branch: [suffix]",
"",
"branch: " + vBranch,
"subordinateTemplate: person:[numusers]",
"",
"template: person",
"rdnAttr: uid",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"givenName: ABOVE LIMIT",
"sn: <last>",
"cn: {givenName} {sn}",
"initials: {givenName:1}<random:chars:" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>{sn:1}",
"employeeNumber: <sequential:0>",
"uid: user.{employeeNumber}",
"mail: {uid}@[maildomain]",
"userPassword: password",
"telephoneNumber: <random:telephone>",
"homePhone: <random:telephone>",
"pager: <random:telephone>",
"mobile: <random:telephone>",
"street: <random:numeric:5> <file:streets> Street",
"l: <file:cities>",
"st: <file:states>",
"postalCode: <random:numeric:5>",
"postalAddress: {cn}${street}${l}, {st} {postalCode}",
"description: This is the description for {cn}.",
""};
};
}
}
/**
* Performs a complete verify against a backend using the entries loaded in
* the setup initializer.
*
* @throws Exception
* if error count is not equal to 0.
*/
@Test
public void testCompleteVerifyJob() throws Exception {
cleanAndLoad(9);
}
/**
* Adds more than "entry limit" number of entries and runs clean
* verify against two indexes.
*
* @throws Exception if error count is not equal to 0.
*/
@Test
public void testEntryLimitVerifyJob() throws Exception {
cleanAndLoad(25);
}
/**
* Runs clean verify jobs against a set of indexes (defined in
* indexes array).
* @param index An element of the indexes array.
* @throws Exception if the error count is not equal to 0.
*/
cleanAndLoad(9);
}
/*
* Begin Clean index tests. These are tests that cursor through an index
* file and validate it's keys and idlists against the id2entry database entries.
* The complete index tests go the other way. They cursor the id2entry database
* and validate each entry against the various index files.
*/
/**
* Runs clean verify against the dn2id index after adding
* various errors in that index file.
*
* @throws Exception if the error count is not equal to 5.
*/
@Test
public void testCleanDN2ID() throws Exception {
preTest(3);
try
{
//Add a junk DN and non-existent entry id to DN2ID index
//Make two DN keys point at same entry.
//Add badDN key with bad entry id
//Add DN key with malformed entryID
//Try to break JebFormat version
}
finally
{
}
}
/**
* Runs clean verify against the id2children index after adding
* various errors in that index file.
*
* @throws Exception if the error count is not equal to 6.
*/
@Test
public void testCleanID2Children() throws Exception {
preTest(3);
try
{
//Add malformed key
byte[] shortBytes = new byte[3];
//Try to break JebFormat version of key entry
//put invalid key -- no EntryID matches
//invalid ids in id list
byte[] idBytes=new byte[24];
//doesn't exist
//not a child
//bad jeb format
}
finally
{
}
}
/**
* Runs clean verify against the id2subtree index after adding
* various errors in that index file.
*
* @throws Exception if the error count is not equal to 7.
*/
@Test
public void testCleanID2Subtree() throws Exception {
preTest(4);
try
{
//break key
byte[] shortBytes = new byte[3];
//put invalid ids into entry 3 idlist
byte[] idBytes=new byte[16];
//invalid id
//non-subordinate
//Try to break JebFormat version of key entry
//put invalid key -- no EntryID matches
}
finally
{
}
}
/**
* Runs clean verify against the telephoneNumber.equality index
* after adding various errors in that index file.
*
* @throws Exception if the error count is not equal to 4.
*/
@Test
public void testCleanAttrIndex() throws Exception {
preTest(3);
try
{
//Add entry with bad JEB format Version
//Add phone number with various bad id list entryIDs
byte[] dataBytes=new byte[32];
//put duplicate ids in list
//put id that doesn't exist
//point to bad entry added above
//really 5 errors, but duplicate reference doesn't increment error
//count for some reason
}
finally
{
}
}
/**
* Runs clean verify against the testvlvindex VLV index
* after adding various errors to each of these index files.
* @throws Exception if the error count is not equal to 6.
*/
@Test
public void testCleanVLV() throws Exception {
preTest(4);
try
{
// Add an incorrectly ordered values.
// Add an invalid ID
// Muck up the values of another ID
}
finally
{
}
}
/*
* Begin complete verify index tests. As described above, these are
* tests that cursor through the id2entry database and validate
* each entry against the various index files.
*
*/
/**
* Runs complete verify against the telephoneNumber index
* after adding various errors in the id2entry file.
*
* @throws Exception if the error count is not equal to 3.
*/
@Test
public void testVerifyID2Entry() throws Exception {
preTest(3);
try
{
//Add entry with short id
byte[] shortBytes = new byte[3];
// add entry with random bytes
byte []eBytes = new byte[459];
for(int i=0;i<459;i++) {
eBytes[i]=(byte) (i*2);
}
//set version correctly
}
finally
{
}
}
/**
*
* Runs complete verify against the dn2id index
* after adding various errors in the dn2id file.
*
* @throws Exception if the error count is not equal to 3.
*/
@Test
public void testVerifyDN2ID() throws Exception {
preTest(9);
try
{
//add entry but no corresponding dn2id key
//entry has dn2id key but its entryID -- don't need key
//insert key with bad entry id (45 instead of 10)
//entry has no parent in dn2id
}
finally
{
}
}
/**
*
* Runs complete verify against the id2children index
* after adding various errors in the id2children file.
*
* @throws Exception if the error count is not equal to 3.
*/
@Test
public void testVerifyID2Children() throws Exception {
preTest(9);
try
{
//Add dn with no parent
byte[] idBytes=new byte[16];
//Add child entry - don't worry about key
//Add its parent entry -- need the key
byte[] idBytesp=new byte[16];
}
finally
{
}
}
/**
*
* Runs complete verify against the id2children index
* after adding various errors in the id2children file.
* This is a second test because the key needed to have
* null idlist. This test is really just for coverage and
* should have a 0 error count.
*
* @throws Exception if the error count is not equal to 0.
*/
@Test
public void testVerifyID2Children1() throws Exception {
preTest(2);
try
{
//Add child entry - don't worry about key
}
finally
{
}
}
/**
*
* Runs complete verify against the id2subtree index
* after adding various errors in the id2subtree file.
*
* @throws Exception if the error count is not equal to 3.
*/
@Test
public void testVerifyID2Subtree() throws Exception {
preTest(2);
try
{
//Add entry with no parent
}
finally
{
}
}
/**
*
* Runs complete verify against the id2subtree index
* after adding various errors in the id2subtree file.
* This is a second test because the key needed to have
* null idlist.
*
* @throws Exception if the error count is not equal to 1.
*/
@Test
public void testVerifyID2Subtree1() throws Exception {
preTest(2);
try
{
//Add child entry - don't worry about key
}
finally
{
}
}
/**
* Runs complete verify against the mail indexes
* (equality, presence, substring, ordering)
* after adding various errors to each of these index files.
* @throws Exception if the error count is not equal to 6.
*/
@Test
public void testVerifyAttribute() throws Exception {
preTest(4);
try
{
//Get db handles to each index.
// Ordering is processed by equality since OPENDJ-1864
//Add invalid idlist ids to both equality and ordering indexes.
byte[] dataBytes=new byte[16];
//put duplicate ids in list
//Add null idlist to equality index.
//Add invalid idlist ids to presence index.
//Add invalid idlist ids to substring index.
}
finally
{
}
}
/**
* Runs complete verify against the testvlvindex VLV index
* after adding various errors to each of these index files.
* @throws Exception if the error count is not equal to 6.
*/
@Test
public void testVerifyVLV() throws Exception {
preTest(4);
try
{
// Remove an ID
// Add an incorrectly ordered values.
// Muck up the values of another ID
}
finally
{
}
}
{
}
/**
* Put a sort values set in this VLV index.
*
* @param txn
* The transaction to use when retrieving the set or NULL if it is
* not required.
* @param sortValuesSet
* The SortValuesSet to put.
* @return True if the sortValuesSet was put successfully or False otherwise.
* @throws JebException
* If an error occurs during an operation on a JE database.
* @throws DatabaseException
* If an error occurs during an operation on a JE database.
* @throws DirectoryException
* If a Directory Server error occurs.
*/
private void putSortValuesSet(VLVIndex vlvIndex, SortValuesSet sortValuesSet) throws JebException, DirectoryException
{
}
/* Various tests not either clean or complete */
/**
* Try to verify a non-indexed attribute.
* @throws Exception if error count is not equal to 0.
*/
public void testVerifyNotIndexed() throws Exception {
cleanAndLoad(2);
}
/**
* Try to verify an nonexistent attribute.
* @throws Exception if verify backend fails.
*/
public void testInvalidIndex() throws Exception {
cleanAndLoad(2);
}
/* end tests */
/**
* Adds an entry to the id2entry database with a dn and id passed into the
* method. Optional flag to set the Jeb version byte for those types of tests.
* @param dn the dn string to put in the entry.
* @param id to use as the id2entry key,
* @param trashFormat true if first byte should be changed to invalid value.
* @return Database entry key of the entry.
* @throws Exception if the entry is not added to the id2entry database.
*/
throws Exception {
if(trashFormat)
{
}
return key;
}
/**
* Wrapper to do a clean verify.
* @param indexToDo index file to run verify against.
* @param expectedErrors number of errors expected for this test.
* @throws Exception if the verify fails.
*/
int expectedErrors) throws Exception {
}
/**
* Wrapper to do a complete verify.
* @param indexToDo index file to run verify against.
* @param expectedErrors number of errors expected for this test.
* @throws Exception if the verify fails.
*/
int expectedErrors) throws Exception {
}
/**
* Performs either a clean or complete verify depending on
* flag passed in.
*
* @param indexToDo index file to run verify against.
* @param expectedErrors number of errors expected for this test.
* @param clean do clean verify if true.
* @throws Exception if the verify fails.
*/
if(!clean)
{
}
else
{
}
}
/**
* Does a pretest setup. Creates some number of entries, gets
* backend, rootcontainer, entryContainer objects, as well as
* various index objects.
* Also starts a transaction.
* @param numEntries number of entries to add to the verify backend.
* @throws Exception if entries cannot be loaded.
*/
}
/**
* Cleans verify backend and loads some number of entries.
* @param numEntries number of entries to load into the backend.
* @throws Exception if the entries are not loaded or created.
*/
template[2]=
}
/**
* Builds an entry.
*
* @param dn to put into the entry.
* @return a new entry.
* @throws DirectoryException if the entry cannot be created.
*/
}
if (extensibleObjectOC == null) {
}
}
}