Add test to ensure change details don't require an index

With the new URL schema (project name + change number) we don't rely on
a working change index for serving change details anymore. This has the
benefit that we can still serve change details pages in case of an index
failure.

This commit adds a test for this case to ensure this functionality is
working as intended.

Change-Id: Id34af71d218e98989709dd1e7baa409da6ff7200
This commit is contained in:
Patrick Hiesel
2017-10-13 11:11:29 +02:00
parent 6908a8945e
commit 7c8599ed29
4 changed files with 123 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.index;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.events.LifecycleListener;
import java.util.Collection;
@@ -37,8 +38,13 @@ public abstract class IndexCollection<K, V, I extends Index<K, V>> implements Li
}
public void setSearchIndex(I index) {
setSearchIndex(index, true);
}
@VisibleForTesting
public void setSearchIndex(I index, boolean closeOld) {
I old = searchIndex.getAndSet(index);
if (old != null && old != index && !writeIndexes.contains(old)) {
if (closeOld && old != null && old != index && !writeIndexes.contains(old)) {
old.close();
}
}