You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/07/31 19:42:34 UTC

[PR] test(amber): add unit test coverage for UserConfigResource [texera]

mengw15 opened a new pull request, #7181:
URL: https://github.com/apache/texera/pull/7181

   ### What changes were proposed in this PR?
   
   Adds `UserConfigResourceSpec` for `UserConfigResource` (previously ~0% coverage,
   no spec) — the small jOOQ-backed per-user key/value config store. The suite runs
   against embedded Postgres via `MockTexeraDB` and seeds users through the
   generated `UserDao`.
   
   11 tests, each starting from a clean slate (so they are order-independent),
   cover the full CRUD round-trip through the resource's own API:
   
   - `getEntry` — returns `null` for a key that was never set.
   - `setEntry` — stores a value that `getEntry` then returns; overwriting the same key updates the value (and leaves a single entry, not two).
   - `getAllDict` — empty map when the user has no entries; every key/value pair after N sets; and it is **scoped to the requesting user** (a second user's entries are not returned, and the same key set by two users stays independent).
   - `deleteEntry` — removes the key so `getEntry`/`getAllDict` no longer show it; a delete of a non-existent key is a no-op (no error).
   - Key validation — `getEntry` / `setEntry` / `deleteEntry` reject a blank key with a `BadRequestException`.
   
   No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7176
   
   ### How was this PR tested?
   
   New unit tests, run locally against embedded Postgres:
   
   ```
   sbt "WorkflowExecutionService/testOnly org.apache.texera.web.resource.UserConfigResourceSpec"
   # Tests: succeeded 11, failed 0
   sbt "WorkflowExecutionService/Test/scalafmtCheck" "WorkflowExecutionService/Test/scalafix --check"   # clean
   ```
   
   The failure path was verified by deliberately breaking an assertion and
   confirming the suite goes red.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 merged PR #7181:
URL: https://github.com/apache/texera/pull/7181


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7181:
URL: https://github.com/apache/texera/pull/7181#issuecomment-5146812013

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - No candidates found from `git blame` history.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7181:
URL: https://github.com/apache/texera/pull/7181#issuecomment-5146848699

   <!-- texera-benchmarks-comment -->
   ## ✅ No material benchmark regressions detected
   
   🟢 2 better · 🔴 0 worse · ⚪ 13 noise (<±5%) · 0 without baseline
   
   > Compared against main `9fa6124` benchmarked on **this same runner**, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.
   
   [Dashboard](https://apache.github.io/texera/dev/bench/) · [Run](https://github.com/apache/texera/actions/runs/30660130930)
   
   | | config | throughput | MB/s | latency | max Δ latest / 7d |
   |---|---|---:|---:|---:|---:|
   | ⚪ | bs=10 sw=10 sl=64 | 520 | 0.317 | 19,082/24,907/24,907 us | ⚪ within ±5% / 🔴 +53.8% |
   | 🟢 | bs=100 sw=10 sl=64 | 1,172 | 0.716 | 82,405/108,593/108,593 us | 🟢 -17.6% / 🟢 +21.5% |
   | ⚪ | bs=1000 sw=10 sl=64 | 1,440 | 0.879 | 696,719/734,945/734,945 us | ⚪ within ±5% / 🟢 +45.1% |
   
   <details><summary>Baseline details</summary>
   
   Latest main `9fa6124` from same runner
   
   | config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
   |---|---|---:|---:|---:|---:|---:|
   | bs=10 sw=10 sl=64 | throughput | 520 tuples/sec | 542 tuples/sec | 765.25 tuples/sec | -4.1% | -32.0% |
   | bs=10 sw=10 sl=64 | MB/s | 0.317 MB/s | 0.331 MB/s | 0.467 MB/s | -4.2% | -32.1% |
   | bs=10 sw=10 sl=64 | p50 | 19,082 us | 18,512 us | 12,703 us | +3.1% | +50.2% |
   | bs=10 sw=10 sl=64 | p95 | 24,907 us | 25,839 us | 16,199 us | -3.6% | +53.8% |
   | bs=10 sw=10 sl=64 | p99 | 24,907 us | 25,839 us | 19,557 us | -3.6% | +27.4% |
   | bs=100 sw=10 sl=64 | throughput | 1,172 tuples/sec | 1,159 tuples/sec | 965.22 tuples/sec | +1.1% | +21.4% |
   | bs=100 sw=10 sl=64 | MB/s | 0.716 MB/s | 0.707 MB/s | 0.589 MB/s | +1.3% | +21.5% |
   | bs=100 sw=10 sl=64 | p50 | 82,405 us | 82,435 us | 103,830 us | -0.0% | -20.6% |
   | bs=100 sw=10 sl=64 | p95 | 108,593 us | 131,809 us | 110,778 us | -17.6% | -2.0% |
   | bs=100 sw=10 sl=64 | p99 | 108,593 us | 131,809 us | 118,713 us | -17.6% | -8.5% |
   | bs=1000 sw=10 sl=64 | throughput | 1,440 tuples/sec | 1,434 tuples/sec | 992.33 tuples/sec | +0.4% | +45.1% |
   | bs=1000 sw=10 sl=64 | MB/s | 0.879 MB/s | 0.875 MB/s | 0.606 MB/s | +0.5% | +45.1% |
   | bs=1000 sw=10 sl=64 | p50 | 696,719 us | 694,709 us | 1,016,959 us | +0.3% | -31.5% |
   | bs=1000 sw=10 sl=64 | p95 | 734,945 us | 749,105 us | 1,062,501 us | -1.9% | -30.8% |
   | bs=1000 sw=10 sl=64 | p99 | 734,945 us | 749,105 us | 1,082,611 us | -1.9% | -32.1% |
   
   </details>
   
   <details><summary>Raw CSV</summary>
   
   ```csv
   config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
   0,10,10,64,20,384.60,200,128000,520,0.317,19082.07,24906.84,24906.84
   1,100,10,64,20,1705.77,2000,1280000,1172,0.716,82405.33,108592.56,108592.56
   2,1000,10,64,20,13884.78,20000,12800000,1440,0.879,696718.68,734944.77,734944.77
   ```
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7181:
URL: https://github.com/apache/texera/pull/7181#discussion_r3692975847


##########
amber/src/test/scala/org/apache/texera/web/resource/UserConfigResourceSpec.scala:
##########
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.web.resource
+
+import org.apache.texera.auth.SessionUser
+import org.apache.texera.dao.MockTexeraDB
+import org.apache.texera.dao.jooq.generated.Tables.{USER, USER_CONFIG}
+import org.apache.texera.dao.jooq.generated.tables.daos.UserDao
+import org.apache.texera.dao.jooq.generated.tables.pojos.User
+import org.scalatest.BeforeAndAfterAll
+import org.scalatest.flatspec.AnyFlatSpec
+
+import javax.ws.rs.BadRequestException
+
+class UserConfigResourceSpec extends AnyFlatSpec with BeforeAndAfterAll with MockTexeraDB {
+
+  private val testUid = 4000 + scala.util.Random.nextInt(1000)
+  private val otherUid = testUid + 1
+
+  private var userDao: UserDao = _
+  private var testUser: User = _
+  private var otherUser: User = _
+  private val resource = new UserConfigResource
+
+  override protected def beforeAll(): Unit = {
+    initializeDBAndReplaceDSLContext()
+    userDao = new UserDao(getDSLContext.configuration())
+  }
+
+  override protected def afterAll(): Unit = shutdownDB()
+
+  // Each test starts from a clean slate for the ids under test, then seeds only
+  // the two users it needs, so tests are order-independent.
+  private def resetFixtures(): Unit = {
+    getDSLContext.deleteFrom(USER_CONFIG).where(USER_CONFIG.UID.in(testUid, otherUid)).execute()
+    getDSLContext.deleteFrom(USER).where(USER.UID.in(testUid, otherUid)).execute()

Review Comment:
   `resetFixtures()` is invoked manually at the start of every test. This is easy to forget when adding new cases and can lead to order-dependent failures or leftover DB state. Consider mixing in `BeforeAndAfterEach` and calling `resetFixtures()` from `beforeEach()` so every test automatically starts from a clean slate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #7181:
URL: https://github.com/apache/texera/pull/7181#issuecomment-5146884914

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/7181?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 80.51%. Comparing base ([`9fa6124`](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`49b6abb`](https://app.codecov.io/gh/apache/texera/commit/49b6abb90cf764e0259ef2218b5b01f6a75ab1c2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #7181      +/-   ##
   ============================================
   + Coverage     80.43%   80.51%   +0.07%     
   - Complexity     3875     3892      +17     
   ============================================
     Files          1160     1160              
     Lines         46189    46189              
     Branches       5145     5145              
   ============================================
   + Hits          37154    37190      +36     
   + Misses         7374     7336      -38     
   - Partials       1661     1663       +2     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.42% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `75.53% <ø> (+0.21%)` | :arrow_up: | |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `20.49% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `65.97% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.80% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.15% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.89% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `97.32% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/7181/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.31% <ø> (ø)` | | Carriedforward from [9fa6124](https://app.codecov.io/gh/apache/texera/commit/9fa612401790f866d1e58a94f70744c996a2f696?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/7181?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for UserConfigResource [texera]

Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 commented on code in PR #7181:
URL: https://github.com/apache/texera/pull/7181#discussion_r3693014304


##########
amber/src/test/scala/org/apache/texera/web/resource/UserConfigResourceSpec.scala:
##########
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.web.resource
+
+import org.apache.texera.auth.SessionUser
+import org.apache.texera.dao.MockTexeraDB
+import org.apache.texera.dao.jooq.generated.Tables.{USER, USER_CONFIG}
+import org.apache.texera.dao.jooq.generated.tables.daos.UserDao
+import org.apache.texera.dao.jooq.generated.tables.pojos.User
+import org.scalatest.BeforeAndAfterAll
+import org.scalatest.flatspec.AnyFlatSpec
+
+import javax.ws.rs.BadRequestException
+
+class UserConfigResourceSpec extends AnyFlatSpec with BeforeAndAfterAll with MockTexeraDB {
+
+  private val testUid = 4000 + scala.util.Random.nextInt(1000)
+  private val otherUid = testUid + 1
+
+  private var userDao: UserDao = _
+  private var testUser: User = _
+  private var otherUser: User = _
+  private val resource = new UserConfigResource
+
+  override protected def beforeAll(): Unit = {
+    initializeDBAndReplaceDSLContext()
+    userDao = new UserDao(getDSLContext.configuration())
+  }
+
+  override protected def afterAll(): Unit = shutdownDB()
+
+  // Each test starts from a clean slate for the ids under test, then seeds only
+  // the two users it needs, so tests are order-independent.
+  private def resetFixtures(): Unit = {
+    getDSLContext.deleteFrom(USER_CONFIG).where(USER_CONFIG.UID.in(testUid, otherUid)).execute()
+    getDSLContext.deleteFrom(USER).where(USER.UID.in(testUid, otherUid)).execute()

Review Comment:
   Adopted — mixed in `BeforeAndAfterEach` and moved `resetFixtures()` into `beforeEach()`, so every test (including any added later) starts from a clean slate automatically. Removed the manual per-test calls.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org