From 40343586b01deb1251f02f01e839ab3895fc3275 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Fri, 4 Sep 2026 04:12:23 -0700 Subject: [PATCH] test(amber): restore the pgroonga global WorkflowResourceSpec clobbers WorkflowResourceSpec.beforeAll forces FulltextSearchQueryUtils.usePgroonga false and never puts it back. amber runs its suites serialized in one unforked JVM, so every suite scheduled after it renders the to_tsvector/to_tsquery fallback instead of production's pgroonga arm. The suite does need the false arm: its embedded Postgres has no pgroonga extension, and with the flag left true 11 of its 78 tests fail with "function pgroonga_condition(...) does not exist". So capture the live value in beforeAll immediately before the write and put exactly that back as the first statement of afterAll, rather than deleting the write. Also correct the clause in DatasetSearchQueryBuilderSpec's header comment that this change falsifies -- WorkflowResourceSpec no longer leaves the global false, so DatasetResourceSpec is the only unrestored writer left. --- .../dashboard/file/WorkflowResourceSpec.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala index 1816ce9cd84..88f429a3e69 100644 --- a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala +++ b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala @@ -160,8 +160,22 @@ class WorkflowResourceSpec new DashboardResource() } + // `FulltextSearchQueryUtils.usePgroonga` is a JVM-global `var` and amber's tests are + // unforked, so every suite in one `test` invocation shares it. This spec must force it + // `false` — its embedded Postgres has no pgroonga extension, and the `true` arm fails 11 + // of the search tests with `function pgroonga_condition(...) does not exist`. Capture the + // live value in `beforeAll` right before the write, so what is put back is exactly the + // value this suite clobbered. Capturing at construction instead would put back whatever + // the flag held when sbt instantiated this class; under sbt today that is the same value, + // since a suite is constructed immediately before it runs and nothing touches the flag in + // between — but that is a property of sbt's scheduling, not of this suite, and it stops + // holding under eager construction (a nesting `Suites`, `OneInstancePerTest`, forking). + // The initialiser below is only so the field never holds an invented default. + private var pgroongaBeforeWrite: Boolean = FulltextSearchQueryUtils.usePgroonga + override protected def beforeAll(): Unit = { initializeDBAndReplaceDSLContext() + pgroongaBeforeWrite = FulltextSearchQueryUtils.usePgroonga FulltextSearchQueryUtils.usePgroonga = false // disable pgroonga // add test user directly val userDao = new UserDao(getDSLContext.configuration()) @@ -195,6 +209,9 @@ class WorkflowResourceSpec } override protected def afterAll(): Unit = { + // Restore before the teardown below, so this does not depend on `closeConnectionPool` + // staying non-throwing (today it swallows any `Exception` itself). + FulltextSearchQueryUtils.usePgroonga = pgroongaBeforeWrite closeConnectionPool() }