Evict the project cache for reloading the project.config Update Gerrit API to 3.3.0-SNAPSHOT and allow to reload the project config by evicting the project cache explicitly. Gerrit v3.3 introduces a new project cache and includes tha ability to serialize its state to a persistent storage. This allows to workaround the Issue 13754 and still being able to add commentLink for being used in the tests. Change-Id: I0404376a778b375d4f607a86068001f49ff391ad
diff --git a/build.sbt b/build.sbt index 8bb7715..74e189c 100644 --- a/build.sbt +++ b/build.sbt
@@ -1,6 +1,6 @@ enablePlugins(GitVersioning) -val gerritApiVersion = "3.2.5.1" +val gerritApiVersion = "3.3.0-SNAPSHOT" val pluginName = "analytics"
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala index d7f37f3..c02cb0c 100644 --- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala +++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala
@@ -22,6 +22,8 @@ import org.eclipse.jgit.lib.Repository import org.scalatest.{FlatSpec, Inside, Matchers} +import scala.collection.JavaConverters._ + @UseLocalDisk class CommitStatisticsCommentLinkSpec extends FlatSpec with GerritTestDaemon with TestCommitStatisticsNoCache with Matchers with Inside { @@ -47,6 +49,7 @@ |[commentlink "link2"] | match = "([Bb]ug:\\s+)(\\d+)" | link = "http://trak.example.com/$2" """.stripMargin, branch = "refs/meta/config") + daemonTest.reloadProject(fileRepositoryName) } it should "collect no commentslink if no matching" in new TestEnvironment {
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala index c1d0409..332c733 100644 --- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala +++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala
@@ -23,6 +23,7 @@ import com.google.gerrit.extensions.client.SubmitType import com.google.gerrit.acceptance._ import com.google.gerrit.extensions.restapi.RestApiModule +import com.google.gerrit.server.project.{ProjectConfig, ProjectState} import com.google.gerrit.server.project.ProjectResource.PROJECT_KIND import com.google.inject.AbstractModule import com.googlesource.gerrit.plugins.analytics.{AnalyticsConfig, ContributorsResource} @@ -155,6 +156,11 @@ super.createProjectOverAPI(nameSuffix, allProjects, false, SubmitType.MERGE_IF_NECESSARY) } + def reloadProject(projectName: Project.NameKey): Option[ProjectState] = { + projectCache.evict(projectName) + Option(projectCache.get(projectName).orElse(null)) + } + def getRepository(projectName: Project.NameKey): FileRepository = repoManager.openRepository(projectName).asInstanceOf[FileRepository]