Skip to content

Commit 4e3483f

Browse files
kousenclaude
andcommitted
Fix flaky CustomerServiceTest timing and migrate Sonar action
- Relax the virtual-threads timing assertion from 1.5s to 5s: the point is concurrent (~1s) vs sequential (~500s), and the tight bound failed intermittently on Windows CI runners - Replace deprecated SonarSource/sonarcloud-github-action@master with SonarSource/sonarqube-scan-action@v8 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d9fbe12 commit 4e3483f

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/sonar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
restore-keys: ${{ runner.os }}-gradle
3333
- name: Build
3434
run: ./gradlew build jacocoTestReport --info
35-
- name: SonarCloud Scan
36-
uses: SonarSource/sonarcloud-github-action@master
35+
- name: SonarQube Scan
36+
uses: SonarSource/sonarqube-scan-action@v8
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

src/test/java/com/kousenit/virtualthreads/CustomerServiceTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ void testFetchCustomerData() {
3737
assertEquals("Customer 500", lastCustomer.name(), "Last customer name should match");
3838
assertEquals("customer500@example.com", lastCustomer.email(), "Last customer email should match");
3939

40-
// Check if the execution time is close to 1 second (allowing some margin)
40+
// 500 concurrent 1-second calls should take about 1 second total,
41+
// not the ~500 seconds a sequential version would need. The generous
42+
// upper bound keeps this stable on slow CI runners.
4143
long executionTime = endTime - startTime;
42-
assertTrue(executionTime >= 1000 && executionTime < 1500,
43-
"Execution time should be close to 1 second, but was " + executionTime + " ms");
44+
assertTrue(executionTime >= 1000 && executionTime < 5000,
45+
"Execution time should be ~1 second (concurrent), but was " + executionTime + " ms");
4446
System.out.println("Execution time: " + executionTime + " ms");
4547
}
4648

0 commit comments

Comments
 (0)