Skip to content

Commit

Permalink
remove flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Nov 11, 2024
1 parent 9697e8a commit 065b01f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ void retry() {
assertThat(callable.call(initialRequest)).isEqualTo(2);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(3);
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(4);
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isFalse();
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();

// Capture the argument passed to futureCall
Expand Down Expand Up @@ -193,7 +192,6 @@ void retryTotalTimeoutExceeded() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(1);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(0);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
verify(callInt, atLeastOnce()).futureCall(argumentCaptor.capture(), any(ApiCallContext.class));
Expand All @@ -217,7 +215,6 @@ void retryMaxAttemptsExceeded() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(2);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(2);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isTrue();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
verify(callInt, atLeastOnce()).futureCall(argumentCaptor.capture(), any(ApiCallContext.class));
Expand All @@ -241,7 +238,6 @@ void retryWithinMaxAttempts() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(3);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(2);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isFalse();
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
verify(callInt, atLeastOnce()).futureCall(argumentCaptor.capture(), any(ApiCallContext.class));
Expand Down Expand Up @@ -271,7 +267,6 @@ void retryOnStatusUnknown() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(4);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(3);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isFalse();
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
verify(callInt, atLeastOnce()).futureCall(argumentCaptor.capture(), any(ApiCallContext.class));
Expand All @@ -293,7 +288,6 @@ void retryOnUnexpectedException() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(1);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(0);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
assertThat(exception).hasCauseThat().isSameInstanceAs(throwable);
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
Expand Down Expand Up @@ -326,7 +320,6 @@ void retryNoRecover() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(1);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(0);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
assertThat(exception).isSameInstanceAs(apiException);
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
Expand Down Expand Up @@ -357,7 +350,6 @@ void retryKeepFailing() {
assertThat(tracerFactory.getInstance().getAttemptsFailed().get())
.isEqualTo(tracerFactory.getInstance().getAttemptsStarted().get());
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isTrue();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
assertThat(exception).hasCauseThat().isInstanceOf(ApiException.class);
assertThat(exception).hasCauseThat().hasMessageThat().contains("Unavailable");
// Capture the argument passed to futureCall
Expand Down Expand Up @@ -401,7 +393,6 @@ void testKnownStatusCode() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(1);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(0);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
assertThat(exception.getStatusCode().getTransportCode())
.isEqualTo(HTTP_CODE_PRECONDITION_FAILED);
assertThat(exception).hasMessageThat().contains("precondition failed");
Expand Down Expand Up @@ -429,7 +420,6 @@ void testUnknownStatusCode() {
assertThat(tracerFactory.getInstance().getAttemptsStarted().get()).isEqualTo(1);
assertThat(tracerFactory.getInstance().getAttemptsFailed().get()).isEqualTo(0);
assertThat(tracerFactory.getInstance().getRetriesExhausted().get()).isFalse();
assertThat(tracerFactory.getInstance().getOperationFailed().get()).isTrue();
// Capture the argument passed to futureCall
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
verify(callInt, atLeastOnce()).futureCall(argumentCaptor.capture(), any(ApiCallContext.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class TestApiTracer implements ApiTracer {

private final AtomicInteger attemptsStarted = new AtomicInteger();
private final AtomicInteger attemptsFailed = new AtomicInteger();
private final AtomicBoolean operationFailed = new AtomicBoolean(false);
private final AtomicBoolean retriesExhausted = new AtomicBoolean(false);

public TestApiTracer() {}
Expand All @@ -55,10 +54,6 @@ public AtomicInteger getAttemptsFailed() {
return attemptsFailed;
}

public AtomicBoolean getOperationFailed() {
return operationFailed;
}

public AtomicBoolean getRetriesExhausted() {
return retriesExhausted;
}
Expand All @@ -78,11 +73,6 @@ public void attemptFailed(Throwable error, Duration delay) {
attemptsFailed.incrementAndGet();
}

@Override
public void operationFailed(Throwable error) {
operationFailed.set(true);
}

@Override
public void attemptFailedRetriesExhausted(Throwable error) {
attemptsFailed.incrementAndGet();
Expand Down

0 comments on commit 065b01f

Please sign in to comment.