use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class UniqueIndexNodeStoreCheckerTest method noConflict.
@Test
public void noConflict() throws Exception {
MemoryNodeStore globalStore = new MemoryNodeStore();
MemoryNodeStore mountedStore = new MemoryNodeStore();
populateStore(globalStore, b -> b.child("first").setProperty("foo", "baz"));
populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
Context ctx = checker.createContext(globalStore, mip);
ErrorHolder error = new ErrorHolder();
checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
error.end();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class UniqueIndexNodeStoreCheckerTest method noConflict_globalMountHasDuplicateOutsideOfPath.
/**
* Tests that if a mount has an index clash but the path does not belog to the global mount no error is reported
*/
@Test
public void noConflict_globalMountHasDuplicateOutsideOfPath() throws Exception {
MemoryNodeStore globalStore = new MemoryNodeStore();
MemoryNodeStore mountedStore = new MemoryNodeStore();
populateStore(globalStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
populateStore(mountedStore, b -> b.child("libs").child("second").setProperty("foo", "bar"));
UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
Context ctx = checker.createContext(globalStore, mip);
ErrorHolder error = new ErrorHolder();
checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
error.end();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class UniqueIndexNodeStoreCheckerTest method noConflict_mountHasDuplicateOutsideOfPath.
/**
* Tests that if a mount has an index clash but the path does not belong to the mount no error is reported
*/
@Test
public void noConflict_mountHasDuplicateOutsideOfPath() throws Exception {
MemoryNodeStore globalStore = new MemoryNodeStore();
MemoryNodeStore mountedStore = new MemoryNodeStore();
populateStore(globalStore, b -> b.child("first").setProperty("foo", "bar"));
populateStore(mountedStore, b -> b.child("second").setProperty("foo", "bar"));
UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
Context ctx = checker.createContext(globalStore, mip);
ErrorHolder error = new ErrorHolder();
checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
error.end();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class UniqueIndexNodeStoreCheckerTest method uuidConflict_twoStores.
@Test
public void uuidConflict_twoStores() throws Exception {
MemoryNodeStore globalStore = new MemoryNodeStore();
MemoryNodeStore mountedStore = new MemoryNodeStore();
populateStore(globalStore, b -> b.child("first").setProperty("foo", "bar"));
populateStore(mountedStore, b -> b.child("libs").child("first").setProperty("foo", "bar"));
UniqueIndexNodeStoreChecker checker = new UniqueIndexNodeStoreChecker();
Context ctx = checker.createContext(globalStore, mip);
exception.expect(IllegalRepositoryStateException.class);
exception.expectMessage("1 errors were found");
exception.expectMessage("clash for value bar: 'duplicate unique index entry'");
ErrorHolder error = new ErrorHolder();
checker.check(new MountedNodeStore(mip.getMountByName("libs"), mountedStore), TreeFactory.createReadOnlyTree(mountedStore.getRoot()), error, ctx);
error.end();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class IndexUpdateTest method testReindexAsync.
/**
* Async Reindex Test (OAK-2174)
* <ul>
* <li>Add some content</li>
* <li>Add an index definition with the reindex flag and the reindex-async flag set</li>
* <li>Run the background async job manually</li>
* <li>Search & verify</li>
* </ul>
*/
@Test
public void testReindexAsync() throws Exception {
IndexEditorProvider provider = new PropertyIndexEditorProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
NodeStore store = new MemoryNodeStore();
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(REINDEX_ASYNC_PROPERTY_NAME, true);
builder.child("testRoot").setProperty("foo", "abc");
// merge it back in
store.merge(builder, hook, CommitInfo.EMPTY);
// first check that the async flag exist
NodeState ns1 = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
assertTrue(ns1.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertTrue(ns1.getProperty(REINDEX_ASYNC_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertEquals(ASYNC_REINDEX_VALUE, ns1.getString(ASYNC_PROPERTY_NAME));
AsyncIndexUpdate async = new AsyncIndexUpdate(ASYNC_REINDEX_VALUE, store, provider, true);
int max = 5;
// same behaviour as PropertyIndexAsyncReindex mbean
boolean done = false;
int count = 0;
while (!done || count >= max) {
async.run();
done = async.isFinished();
count++;
}
// first check that the index content nodes exist
NodeState ns = checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex");
checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
assertFalse(ns.getProperty(REINDEX_PROPERTY_NAME).getValue(Type.BOOLEAN));
assertNull(ns.getProperty(ASYNC_PROPERTY_NAME));
// next, lookup
PropertyIndexLookup lookup = new PropertyIndexLookup(store.getRoot());
assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
}
Aggregations