Skip to content

Commit 85f1ca2

Browse files
Copilotrpdome
andauthored
Remove TOTAL_TIMEOUT_SECONDS from public API; derive backstop internally in helper
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/950932aa-114e-4f33-ba7f-a6abd4506823 Co-authored-by: rpdome <19558668+rpdome@users.noreply.github.com>
1 parent 98d009a commit 85f1ca2

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/concurrent/ConcurrentAcquireTokenSilentHelper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,15 @@ public interface SilentTokenRequester {
139139
* that counts from {@code threadCount} down to zero, so callers must
140140
* still call {@code done.countDown()} exactly once per request.</p>
141141
*
142+
* <p>A safety backstop of {@code iterations × perWaveTimeoutSec} seconds is
143+
* enforced internally on the final {@link CountDownLatch#await} to guard
144+
* against unexpected hangs; in practice the per-wave timeout unblocks all
145+
* threads before this ceiling is reached.</p>
146+
*
142147
* @param threadCount number of concurrent threads
143148
* @param iterations number of iteration waves per thread
144149
* @param perWaveTimeoutSec maximum seconds for all {@code threadCount}
145150
* callbacks in one wave to complete
146-
* @param totalTimeoutSec seconds to wait for all threads to finish all
147-
* iterations (safety backstop)
148151
* @param requester supplies one MSAL call per (thread, iteration)
149152
* @return the {@link StressResult} containing the completion flag and any errors
150153
* @throws InterruptedException if the calling thread is interrupted while awaiting
@@ -154,7 +157,6 @@ public static StressResult run(
154157
final int threadCount,
155158
final int iterations,
156159
final long perWaveTimeoutSec,
157-
final long totalTimeoutSec,
158160
final SilentTokenRequester requester) throws InterruptedException {
159161

160162
final AtomicBoolean stopped = new AtomicBoolean(false);
@@ -224,7 +226,9 @@ public static StressResult run(
224226
}, "ConcurrentATS-" + threadIndex).start();
225227
}
226228

227-
final boolean allCompleted = allThreadsDone.await(totalTimeoutSec, TimeUnit.SECONDS);
229+
final boolean allCompleted =
230+
allThreadsDone.await(
231+
(long) iterations * perWaveTimeoutSec, TimeUnit.SECONDS);
228232
return new StressResult(allCompleted, errors);
229233
}
230234
}

msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/concurrent/TestCaseConcurrentAcquireTokenSilent.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ public class TestCaseConcurrentAcquireTokenSilent extends AbstractMsalBrokerTest
9898
*/
9999
private static final long PER_WAVE_TIMEOUT_SECONDS = 10;
100100

101-
/**
102-
* Overall test timeout (safety backstop): exactly
103-
* {@value #ITERATIONS_PER_THREAD} waves × {@value #PER_WAVE_TIMEOUT_SECONDS} s/wave = 1000 s.
104-
* The per-wave timeout already aborts the run on the first stuck wave,
105-
* so the total can never exceed this bound.
106-
*/
107-
private static final long TOTAL_TIMEOUT_SECONDS =
108-
ITERATIONS_PER_THREAD * PER_WAVE_TIMEOUT_SECONDS;
109-
110101
@Test
111102
public void test_concurrentAcquireTokenSilent_withBroker() throws Throwable {
112103
final String username = mLabAccount.getUsername();
@@ -167,7 +158,6 @@ public void handleUserInteraction() {
167158
CONCURRENT_THREADS,
168159
ITERATIONS_PER_THREAD,
169160
PER_WAVE_TIMEOUT_SECONDS,
170-
TOTAL_TIMEOUT_SECONDS,
171161
(threadIndex, iteration, done, errors) -> {
172162
final AcquireTokenSilentParameters silentParameters =
173163
new AcquireTokenSilentParameters.Builder()
@@ -203,9 +193,8 @@ public void onError(
203193
Assert.assertTrue(
204194
"Concurrent AcquireTokenSilent stress test got stuck – not all "
205195
+ CONCURRENT_THREADS + " threads completed "
206-
+ ITERATIONS_PER_THREAD + " iterations within "
207-
+ TOTAL_TIMEOUT_SECONDS + "s (per-wave timeout: "
208-
+ PER_WAVE_TIMEOUT_SECONDS + "s)",
196+
+ ITERATIONS_PER_THREAD + " iterations"
197+
+ " (per-wave timeout: " + PER_WAVE_TIMEOUT_SECONDS + "s)",
209198
result.allCompleted);
210199

211200
Assert.assertTrue(

0 commit comments

Comments
 (0)