Skip to content

Commit

Permalink
minor tweaks to make assertion failures easier to understand
Browse files Browse the repository at this point in the history
Change-Id: Icecb9f3c328e9305d66d0711cd242829a91aa770
  • Loading branch information
igorbernstein2 committed Jun 25, 2024
1 parent b89cf2b commit 7259558
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.google.cloud.bigtable.data.v2.it;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;
import static org.junit.Assert.assertThrows;

Expand All @@ -30,7 +32,6 @@
import com.google.cloud.bigtable.test_helpers.env.PrefixGenerator;
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule;
import com.google.common.base.Stopwatch;
import com.google.common.truth.Truth;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
Expand Down Expand Up @@ -120,7 +121,7 @@ public void testRetryInfo() throws IOException {
.readRows(Query.create(testEnvRule.env().getTableId()).limit(1))
.iterator()
.hasNext());
Truth.assertThat(e.getMessage()).contains("SPUs");
assertThat(e).hasMessageThat().contains("SPUs");
enabledElapsed = stopwatch1.elapsed(TimeUnit.MILLISECONDS);
}

Expand All @@ -142,13 +143,19 @@ public void testRetryInfo() throws IOException {
.readRows(Query.create(testEnvRule.env().getTableId()).limit(1))
.iterator()
.hasNext());
Truth.assertThat(e.getMessage()).contains("SPUs");
assertThat(e).hasMessageThat().contains("SPUs");
disabledElapsed = stopwatch2.elapsed(TimeUnit.MILLISECONDS);
}

Truth.assertThat(disabledElapsed).isGreaterThan(0);
Truth.assertThat(enabledElapsed).isGreaterThan(disabledElapsed);
Truth.assertThat(enabledElapsed).isGreaterThan(26000);
assertWithMessage("Operation duration without RetryInfo")
.that(disabledElapsed)
.isGreaterThan(0);
assertWithMessage("Operation duration with RetryInfo > without")
.that(enabledElapsed)
.isGreaterThan(disabledElapsed);
assertWithMessage("operation duration with Retrying minimum duration")
.that(enabledElapsed)
.isGreaterThan(26000);
}

@Test
Expand Down Expand Up @@ -179,10 +186,10 @@ public void testRetryInfoGuardedByTotalTimeout() throws Exception {
.readRows(Query.create(testEnvRule.env().getTableId()).limit(1))
.iterator()
.hasNext());
Truth.assertThat(e.getMessage()).contains("SPUs");
assertThat(e).hasMessageThat().contains("SPUs");
enabledElapsed = stopwatch1.elapsed(TimeUnit.MILLISECONDS);
}

Truth.assertThat(enabledElapsed).isLessThan(5000);
assertThat(enabledElapsed).isLessThan(5000);
}
}

0 comments on commit 7259558

Please sign in to comment.