Skip to content

Commit

Permalink
test: attempt tests up to 3 times (googleapis#400)
Browse files Browse the repository at this point in the history
* test: attempt tests up to 3 times

* chore: run formatter
  • Loading branch information
BenWhitehead committed Feb 1, 2021
1 parent e382962 commit 5a4fd38
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions google-cloud-nio/pom.xml
Expand Up @@ -82,6 +82,13 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.94.0</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -18,10 +18,12 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.net.SocketTimeoutException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -30,6 +32,8 @@
@RunWith(JUnit4.class)
public class CloudStorageConfigurationTest {

@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Test
public void testBuilder() {
CloudStorageConfiguration config =
Expand Down
Expand Up @@ -20,6 +20,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.io.IOException;
Expand All @@ -31,13 +32,15 @@
import java.nio.file.attribute.FileTime;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileAttributeView}. */
@RunWith(JUnit4.class)
public class CloudStorageFileAttributeViewTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final byte[] HAPPY = "(✿◕ ‿◕ )ノ".getBytes(UTF_8);

Expand Down
Expand Up @@ -21,6 +21,7 @@

import com.google.cloud.storage.Acl;
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.io.IOException;
Expand All @@ -29,13 +30,15 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileAttributes}. */
@RunWith(JUnit4.class)
public class CloudStorageFileAttributesTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final byte[] HAPPY = "(✿◕ ‿◕ )ノ".getBytes(UTF_8);
private static final byte[] EMPTY = "".getBytes(UTF_8);
Expand Down
Expand Up @@ -28,6 +28,7 @@
import static java.nio.file.StandardOpenOption.WRITE;

import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.NullPointerTester;
import java.io.IOException;
Expand All @@ -53,13 +54,15 @@
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileSystemProvider}. */
@RunWith(JUnit4.class)
public class CloudStorageFileSystemProviderTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final List<String> FILE_CONTENTS =
ImmutableList.of(
Expand Down
Expand Up @@ -25,6 +25,7 @@

import com.google.cloud.storage.StorageOptions;
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.io.IOException;
Expand All @@ -43,13 +44,15 @@
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileSystem}. */
@RunWith(JUnit4.class)
public class CloudStorageFileSystemTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final String ALONE =
"To be, or not to be, that is the question—\n"
Expand Down
Expand Up @@ -24,15 +24,18 @@

import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.net.URI;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileSystemProvider} late initialization. */
@RunWith(JUnit4.class)
public class CloudStorageLateInitializationTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private StorageOptions mockOptions;

Expand Down
Expand Up @@ -21,20 +21,23 @@

import com.google.cloud.storage.Acl;
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.testing.NullPointerTester;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageOptions}. */
@RunWith(JUnit4.class)
public class CloudStorageOptionsTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Before
public void before() {
Expand Down
Expand Up @@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.collect.Iterables;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
Expand All @@ -31,13 +32,15 @@
import java.nio.file.ProviderMismatchException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStoragePath}. */
@RunWith(JUnit4.class)
public class CloudStoragePathTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Before
public void before() {
Expand Down
Expand Up @@ -30,13 +30,15 @@
import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.NonWritableChannelException;
import javax.net.ssl.SSLHandshakeException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -45,6 +47,7 @@
/** Unit tests for {@link CloudStorageReadChannel}. */
@RunWith(JUnit4.class)
public class CloudStorageReadChannelTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private CloudStorageReadChannel chan;

Expand Down
Expand Up @@ -19,17 +19,21 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class CloudStorageReadFileChannelTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final class SeekableByteChannelImpl implements SeekableByteChannel {
private boolean open = true;
private ByteBuffer data;
Expand Down
Expand Up @@ -21,6 +21,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -32,13 +33,15 @@
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageFileSystem}. */
@RunWith(JUnit4.class)
public class CloudStorageReadTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final String ALONE =
"To be, or not to be, that is the question—\n"
Expand Down
Expand Up @@ -19,13 +19,16 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.storage.StorageException;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.collect.ImmutableList;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class CloudStorageRetryHandlerTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Test
public void testIsRetryable() throws Exception {
Expand Down
Expand Up @@ -26,19 +26,22 @@
import static org.mockito.Mockito.when;

import com.google.cloud.WriteChannel;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.NonReadableChannelException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link CloudStorageWriteChannel}. */
@RunWith(JUnit4.class)
public class CloudStorageWriteChannelTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private final WriteChannel gcsChannel = mock(WriteChannel.class);
private final CloudStorageWriteChannel chan = new CloudStorageWriteChannel(gcsChannel);
Expand Down
Expand Up @@ -19,17 +19,21 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class CloudStorageWriteFileChannelTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private static final class SeekableByteChannelImpl implements SeekableByteChannel {
private boolean open = true;
private ByteBuffer data;
Expand Down
Expand Up @@ -18,10 +18,12 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -32,6 +34,7 @@
*/
@RunWith(JUnit4.class)
public class NIOTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

private URI uriToCloudStorage;

Expand Down
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
Expand All @@ -27,12 +28,15 @@
import java.nio.file.Path;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class SeekableByteChannelPrefetcherTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

// A file big enough to try seeks on.
private static Path input;

Expand Down
Expand Up @@ -19,16 +19,19 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assume.assumeTrue;

import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit tests for {@link UnixPath}. */
@RunWith(JUnit4.class)
public class UnixPathTest {
@Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Test
public void testNormalize() {
Expand Down

0 comments on commit 5a4fd38

Please sign in to comment.