Skip to content

Commit

Permalink
Incorporated Flexible Changes from PR #364
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin A Nair committed Mar 26, 2019
1 parent bb777e6 commit 2b13fc4
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 121 deletions.
11 changes: 11 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ possible torun a subset of the test suite by adding
mvn test -DexcludedGroups=unlimited-crypto
```

## Dry run

It's possible to print a list of which integration tests would run and their relevant
parameters using the following invocation:

```
mvn verify -Dit.dryrun=true
```

Note: This has not yet been expanded to unit tests.

# Writing Tests

The `java-manta-client` module contains unit tests. Integration tests generally
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2015-2019, Joyent, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -32,7 +32,7 @@
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
*/
@Test(groups = { "directory" })
@Test(groups = {"directory"})
public class MantaClientDirectoriesIT {

private static final Logger LOG = LoggerFactory.getLogger(MantaClientDirectoriesIT.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2015-2019, Joyent, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -16,8 +16,6 @@
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -33,8 +31,9 @@
* failures.
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test(groups = { "error" })
@Test(groups = {"error"})
public class MantaClientErrorIT {
private MantaClient mantaClient;

Expand All @@ -43,11 +42,9 @@ public class MantaClientErrorIT {
private String testPathPrefix;

@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {

public void beforeClass() throws IOException {
// Let TestNG configuration take precedence over environment variables
config = new IntegrationTestConfigContext(usingEncryption);
config = new IntegrationTestConfigContext();

mantaClient = new MantaClient(config);
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,27 @@
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test
@Test(groups = {"encryptable"})
public class MantaClientIT {

private static final String TEST_DATA = "EPISODEII_IS_BEST_EPISODE";

private MantaClient mantaClient;
private final MantaClient mantaClient;

private String testPathPrefix;
private final String testPathPrefix;

@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
@Parameters({"encryptionCipher"})
public MantaClientIT(final @Optional String encryptionCipher) {

// Let TestNG configuration take precedence over environment variables
ConfigContext config = new IntegrationTestConfigContext(usingEncryption);
ConfigContext config = new IntegrationTestConfigContext(encryptionCipher);

mantaClient = new MantaClient(config);
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());
}

@BeforeClass
public void beforeClass() throws IOException {
mantaClient.putDirectory(testPathPrefix, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,29 @@
* Tests for verifying the behavior of metadata with {@link MantaClient}.
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test(groups = { "metadata" })
@Test(groups = {"metadata"})
public class MantaClientMetadataIT {
private static final String TEST_DATA = "EPISODEII_IS_BEST_EPISODE";

private MantaClient mantaClient;

private String testPathPrefix;

@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
@Parameters({"encryptionCipher"})
public MantaClientMetadataIT(final @Optional String encryptionCipher) {

// Let TestNG configuration take precedence over environment variables
ConfigContext config = new IntegrationTestConfigContext(usingEncryption);
ConfigContext config = new IntegrationTestConfigContext(encryptionCipher);

mantaClient = new MantaClient(config);
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());

}

@BeforeClass
public void beforeClass() throws IOException {
mantaClient.putDirectory(testPathPrefix, true);
}

Expand Down Expand Up @@ -177,7 +182,7 @@ public void canAddMetadataToDirectory() throws IOException {
}
}

@Test(groups = "encrypted")
@Test(groups = "encryptable")
public void verifyAddEncryptedMetadataToObjectOnPut() throws IOException {
if (!mantaClient.getContext().isClientEncryptionEnabled()) {
throw new SkipException("Test is only relevant when client-side encryption is enabled");
Expand Down Expand Up @@ -207,7 +212,7 @@ public void verifyAddEncryptedMetadataToObjectOnPut() throws IOException {
Assert.assertEquals(get.getHeaderAsString("e-force"), "true");
}

@Test(groups = "encrypted")
@Test(groups = "encryptable")
public final void verifyEncryptedMetadataCanBeAddedLater() throws IOException {
if (!mantaClient.getContext().isClientEncryptionEnabled()) {
throw new SkipException("Test is only relevant when client-side encryption is enabled");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2016-2019, Joyent, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -42,7 +42,13 @@

import static com.joyent.manta.exception.MantaErrorCode.RESOURCE_NOT_FOUND_ERROR;

@Test
/**
* Tests the basic functionality of the put operations in {@link MantaClient} class.
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test(groups = {"put"})
public class MantaClientPutIT {

private static final String TEST_DATA = "EPISODEII_IS_BEST_EPISODE";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/*
* Copyright (c) 2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2017-2019, Joyent, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.joyent.manta.client;

import com.joyent.manta.config.*;
import com.joyent.manta.config.BaseChainedConfigContext;
import com.joyent.manta.config.ConfigContext;
import com.joyent.manta.config.EncryptionAuthenticationMode;
import com.joyent.manta.config.IntegrationTestConfigContext;
import com.joyent.manta.config.SettableConfigContext;
import com.joyent.manta.http.MantaHttpHeaders;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -23,6 +27,13 @@
import java.nio.charset.Charset;
import java.util.UUID;

/**
* Tests for verifying the correct behavior of range operations performed by
* the {@link MantaClient} class.
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test
public class MantaClientRangeIT {
private static final String TEST_DATA =
Expand All @@ -49,23 +60,29 @@ public class MantaClientRangeIT {
"Girt with a seint* of silk, with barres small; " +
"Of his array tell I no longer tale.";

private MantaClient mantaClient;
private final MantaClient mantaClient;

private String testPathPrefix;
private final ConfigContext config;

@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
// Let TestNG configuration take precedence over environment variables
SettableConfigContext<BaseChainedConfigContext> config = new IntegrationTestConfigContext(usingEncryption);
private final String testPathPrefix;

@Parameters({"encryptionCipher"})
public MantaClientRangeIT(final @Optional String encryptionCipher) {

// Let TestNG configuration take precedence over environment variables
SettableConfigContext<BaseChainedConfigContext> config = new IntegrationTestConfigContext(encryptionCipher);
// Range request have to be in optional authentication mode
if (config.isClientEncryptionEnabled()) {
config.setEncryptionAuthenticationMode(EncryptionAuthenticationMode.Optional);
}

mantaClient = new MantaClient(config);
this.config = config;
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());

}
@BeforeClass
public void beforeClass() throws IOException {
mantaClient.putDirectory(testPathPrefix, true);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2015-2019, Joyent, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -36,22 +36,20 @@
* {@link MantaClient}.
*
* @author <a href="https://github.com/dekobon">Elijah Zupancic</a>
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test(groups = { "seekable" })
@Test(groups = {"seekable", "encryptable"})
public class MantaClientSeekableByteChannelIT {
private static final String TEST_DATA = "EPISODEII_IS_BEST_EPISODE";

private MantaClient mantaClient;
private final MantaClient mantaClient;

private String testPathPrefix;


@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
private final String testPathPrefix;

@Parameters({"encryptionCipher"})
public MantaClientSeekableByteChannelIT(final @Optional String encryptionCipher) {
// Let TestNG configuration take precedence over environment variables
SettableConfigContext<BaseChainedConfigContext> config = new IntegrationTestConfigContext(usingEncryption);
SettableConfigContext<BaseChainedConfigContext> config = new IntegrationTestConfigContext(encryptionCipher);

// Range request have to be in optional authentication mode
if (config.isClientEncryptionEnabled()) {
Expand All @@ -60,6 +58,10 @@ public void beforeClass(@Optional Boolean usingEncryption) throws IOException {

mantaClient = new MantaClient(config);
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());
}

@BeforeClass
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
mantaClient.putDirectory(testPathPrefix, true);
}

Expand All @@ -68,7 +70,6 @@ public void afterClass() throws IOException {
IntegrationTestConfigContext.cleanupTestDirectory(mantaClient, testPathPrefix);
}

@Test
public final void seekableByteSize() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -82,7 +83,6 @@ public final void seekableByteSize() throws IOException {
}
}

@Test
public final void getAllSeekableBytes() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -94,7 +94,6 @@ public final void getAllSeekableBytes() throws IOException {
}
}

@Test
public final void getAllSeekableBytesAtPosition() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -109,7 +108,6 @@ public final void getAllSeekableBytesAtPosition() throws IOException {
}
}

@Test
public final void readFromDifferentPositions() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -133,7 +131,6 @@ public final void readFromDifferentPositions() throws IOException {
}
}

@Test
public final void readAllSeekableBytesFromPositionAsInputStream() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -157,7 +154,6 @@ public final void readAllSeekableBytesFromPositionAsInputStream() throws IOExcep
}
}

@Test
public final void skipUsingInputStream() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand Down Expand Up @@ -223,7 +219,6 @@ public final void attemptToWrite() throws IOException {
}
}

@Test( groups = { "seekable" })
public final void getFromForwardPosition() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -241,7 +236,6 @@ public final void getFromForwardPosition() throws IOException {
}
}

@Test( groups = { "seekable" } )
public final void getFromBaseChannelThenForwardPosition() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand All @@ -262,7 +256,6 @@ public final void getFromBaseChannelThenForwardPosition() throws IOException {
}
}

@Test( groups = { "seekable" } )
public final void getFromForwardPositionThenBackwardPosition() throws IOException {
final String name = UUID.randomUUID().toString();
final String path = testPathPrefix + name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*
* @author <a href="https://github.com/nairashwin952013">Ashwin A Nair</a>
*/
@Test(groups = "snaplinks")
@Test(groups = {"snaplinks"})
public class MantaClientSnapLinksIT {

private static final Logger LOG = LoggerFactory.getLogger(MantaClientSnapLinksIT.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public class MantaDirectoryListingIteratorIT {
private String testPathPrefix;

@BeforeClass
@Parameters({"usingEncryption"})
public void beforeClass(@Optional Boolean usingEncryption) throws IOException {
public void beforeClass() throws IOException {

// Let TestNG configuration take precedence over environment variables
final ConfigContext config = new IntegrationTestConfigContext(usingEncryption);
ConfigContext config = new IntegrationTestConfigContext();

mantaClient = new MantaClient(config);
testPathPrefix = IntegrationTestConfigContext.generateBasePath(config, this.getClass().getSimpleName());
Expand Down
Loading

0 comments on commit 2b13fc4

Please sign in to comment.