Skip to content

Commit fbacf14

Browse files
author
Joshua Miller
committed
Make test env data policies all force create jobs
1 parent 52a3313 commit fbacf14

File tree

3 files changed

+98
-95
lines changed

3 files changed

+98
-95
lines changed

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ public class GetJobManagement_Test {
5353
private static final String BUCKET_NAME = "Get_Job_Management_Test";
5454
private static final String TEST_ENV_NAME = "GetJobManagement_Test";
5555
private static TempStorageIds envStorageIds;
56+
private static UUID dataPolicyId;
5657

5758
@BeforeClass
5859
public static void startup() throws Exception {
59-
final UUID dataPolicyId = TempStorageUtil.setupDataPolicy(TEST_ENV_NAME, true, ChecksumType.Type.MD5, client);
60+
dataPolicyId = TempStorageUtil.setupDataPolicy(TEST_ENV_NAME, false, ChecksumType.Type.MD5, client);
6061
envStorageIds = TempStorageUtil.setup(TEST_ENV_NAME, dataPolicyId, client);
6162
HELPERS.ensureBucketExists(BUCKET_NAME);
6263
putBeowulf();

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/test/helpers/ABMTestHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ public static PutDataPolicySpectraS3Response createDataPolicyWithVersioningAndCr
5959
if (checksumType == null) {
6060
//Create the data policy with versioning
6161
return client.putDataPolicySpectraS3(new PutDataPolicySpectraS3Request(dataPolicyName)
62-
.withVersioning(versioningLevel));
62+
.withVersioning(versioningLevel).withAlwaysForcePutJobCreation(true));
6363
}
6464
//Create the data policy with versioning and checksum
6565
return client.putDataPolicySpectraS3(new PutDataPolicySpectraS3Request(dataPolicyName)
6666
.withVersioning(versioningLevel)
6767
.withEndToEndCrcRequired(true)
68-
.withChecksumType(checksumType));
68+
.withChecksumType(checksumType).withAlwaysForcePutJobCreation(true));
6969
}
7070

7171
/**
Lines changed: 94 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,94 @@
1-
package com.spectralogic.ds3client.integration.test.helpers;
2-
3-
import com.spectralogic.ds3client.Ds3Client;
4-
import com.spectralogic.ds3client.commands.spectrads3.*;
5-
import com.spectralogic.ds3client.models.ChecksumType;
6-
import com.spectralogic.ds3client.models.PoolType;
7-
8-
import java.io.IOException;
9-
import java.security.SignatureException;
10-
import java.util.UUID;
11-
12-
import static com.spectralogic.ds3client.integration.test.helpers.ABMTestHelper.*;
13-
14-
/**
15-
* This is a testing utility designed for creating a temporary data policy, storage domain,
16-
* and partition for use in the integration tests to avoid error if the BP does not currently
17-
* have a partition available for running the unit tests.
18-
*/
19-
public class TempStorageUtil {
20-
21-
private static final String DATA_POLICY_NAME = "_dp";
22-
private static final String STORAGE_DOMAIN_NAME = "_sd";
23-
private static final String POOL_PARTITION_NAME = "_pp";
24-
25-
/**
26-
* Sets up a temporary data policy with a temporary storage domain and partition
27-
* for use in integration tests where the user may not currently have access to
28-
* a partition.
29-
* @param testSetName The unique name of tests being run under this domain to
30-
* prevent race conditions between test setup and teardown
31-
*/
32-
public static TempStorageIds setup(
33-
final String testSetName,
34-
final UUID dataPolicyId,
35-
final Ds3Client client) throws IOException, SignatureException {
36-
//Create storage domain
37-
final PutStorageDomainSpectraS3Response storageDomainResponse = createStorageDomain(
38-
testSetName + STORAGE_DOMAIN_NAME,
39-
client);
40-
41-
//Create pool partition
42-
final PutPoolPartitionSpectraS3Response poolPartitionResponse = createPoolPartition(
43-
testSetName + POOL_PARTITION_NAME,
44-
PoolType.ONLINE,
45-
client);
46-
47-
//Create storage domain member linking pool partition to storage domain
48-
final PutPoolStorageDomainMemberSpectraS3Response memberResponse = createPoolStorageDomainMember(
49-
storageDomainResponse.getStorageDomainResult().getId(),
50-
poolPartitionResponse.getPoolPartitionResult().getId(),
51-
client);
52-
final UUID storageDomainMemberId = memberResponse.getStorageDomainMemberResult().getId();
53-
54-
//create data persistence rule
55-
final PutDataPersistenceRuleSpectraS3Response dataPersistenceResponse = createDataPersistenceRule(
56-
dataPolicyId,
57-
storageDomainResponse.getStorageDomainResult().getId(),
58-
client);
59-
final UUID dataPersistenceRuleId = dataPersistenceResponse.getDataPersistenceRuleResult().getDataPolicyId();
60-
61-
return new TempStorageIds(storageDomainMemberId, dataPersistenceRuleId);
62-
}
63-
64-
/**
65-
* Tears down the temporary test environment
66-
*/
67-
public static void teardown(
68-
final String testSetName,
69-
final TempStorageIds ids,
70-
final Ds3Client client) throws IOException, SignatureException {
71-
deleteDataPersistenceRule(ids.getDataPersistenceRuleId(), client);
72-
deleteDataPolicy(testSetName + DATA_POLICY_NAME, client);
73-
deleteStorageDomainMember(ids.getStorageDomainMemberId(), client);
74-
deleteStorageDomain(testSetName + STORAGE_DOMAIN_NAME, client);
75-
deletePoolPartition(testSetName + POOL_PARTITION_NAME, client);
76-
}
77-
78-
/**
79-
* Creates a Data Policy with the specified checksum type and end-to-end crc requirement
80-
*/
81-
public static UUID setupDataPolicy(
82-
final String testSetName,
83-
final boolean withEndToEndCrcRequired,
84-
final ChecksumType.Type checksumType,
85-
final Ds3Client client) throws IOException, SignatureException {
86-
final PutDataPolicySpectraS3Response dataPolicyResponse = client.putDataPolicySpectraS3(
87-
new PutDataPolicySpectraS3Request(testSetName + DATA_POLICY_NAME)
88-
.withEndToEndCrcRequired(withEndToEndCrcRequired)
89-
.withChecksumType(checksumType));
90-
return dataPolicyResponse.getDataPolicyResult().getId();
91-
}
92-
}
1+
package com.spectralogic.ds3client.integration.test.helpers;
2+
3+
import com.spectralogic.ds3client.Ds3Client;
4+
import com.spectralogic.ds3client.commands.spectrads3.*;
5+
import com.spectralogic.ds3client.models.ChecksumType;
6+
import com.spectralogic.ds3client.models.PoolType;
7+
8+
import java.io.IOException;
9+
import java.security.SignatureException;
10+
import java.util.UUID;
11+
12+
import static com.spectralogic.ds3client.integration.test.helpers.ABMTestHelper.*;
13+
14+
/**
15+
* This is a testing utility designed for creating a temporary data policy, storage domain,
16+
* and partition for use in the integration tests to avoid error if the BP does not currently
17+
* have a partition available for running the unit tests.
18+
*/
19+
public class TempStorageUtil {
20+
21+
private static final String DATA_POLICY_NAME = "_dp";
22+
private static final String STORAGE_DOMAIN_NAME = "_sd";
23+
private static final String POOL_PARTITION_NAME = "_pp";
24+
25+
/**
26+
* Sets up a temporary data policy with a temporary storage domain and partition
27+
* for use in integration tests where the user may not currently have access to
28+
* a partition.
29+
* @param testSetName The unique name of tests being run under this domain to
30+
* prevent race conditions between test setup and teardown
31+
*/
32+
public static TempStorageIds setup(
33+
final String testSetName,
34+
final UUID dataPolicyId,
35+
final Ds3Client client) throws IOException, SignatureException {
36+
//Create storage domain
37+
final PutStorageDomainSpectraS3Response storageDomainResponse = createStorageDomain(
38+
testSetName + STORAGE_DOMAIN_NAME,
39+
client);
40+
41+
//Create pool partition
42+
final PutPoolPartitionSpectraS3Response poolPartitionResponse = createPoolPartition(
43+
testSetName + POOL_PARTITION_NAME,
44+
PoolType.ONLINE,
45+
client);
46+
47+
//Create storage domain member linking pool partition to storage domain
48+
final PutPoolStorageDomainMemberSpectraS3Response memberResponse = createPoolStorageDomainMember(
49+
storageDomainResponse.getStorageDomainResult().getId(),
50+
poolPartitionResponse.getPoolPartitionResult().getId(),
51+
client);
52+
final UUID storageDomainMemberId = memberResponse.getStorageDomainMemberResult().getId();
53+
54+
//create data persistence rule
55+
final PutDataPersistenceRuleSpectraS3Response dataPersistenceResponse = createDataPersistenceRule(
56+
dataPolicyId,
57+
storageDomainResponse.getStorageDomainResult().getId(),
58+
client);
59+
final UUID dataPersistenceRuleId = dataPersistenceResponse.getDataPersistenceRuleResult().getDataPolicyId();
60+
61+
return new TempStorageIds(storageDomainMemberId, dataPersistenceRuleId);
62+
}
63+
64+
/**
65+
* Tears down the temporary test environment
66+
*/
67+
public static void teardown(
68+
final String testSetName,
69+
final TempStorageIds ids,
70+
final Ds3Client client) throws IOException, SignatureException {
71+
deleteDataPersistenceRule(ids.getDataPersistenceRuleId(), client);
72+
deleteDataPolicy(testSetName + DATA_POLICY_NAME, client);
73+
deleteStorageDomainMember(ids.getStorageDomainMemberId(), client);
74+
deleteStorageDomain(testSetName + STORAGE_DOMAIN_NAME, client);
75+
deletePoolPartition(testSetName + POOL_PARTITION_NAME, client);
76+
}
77+
78+
/**
79+
* Creates a Data Policy with the specified checksum type and end-to-end crc requirement
80+
*/
81+
public static UUID setupDataPolicy(
82+
final String testSetName,
83+
final boolean withEndToEndCrcRequired,
84+
final ChecksumType.Type checksumType,
85+
final Ds3Client client) throws IOException, SignatureException {
86+
final PutDataPolicySpectraS3Response dataPolicyResponse = client.putDataPolicySpectraS3(
87+
new PutDataPolicySpectraS3Request(testSetName + DATA_POLICY_NAME)
88+
.withEndToEndCrcRequired(withEndToEndCrcRequired)
89+
.withChecksumType(checksumType).withAlwaysForcePutJobCreation(true));
90+
client.modifyUserSpectraS3(new ModifyUserSpectraS3Request("spectra")
91+
.withDefaultDataPolicyId(dataPolicyResponse.getDataPolicyResult().getId()));
92+
return dataPolicyResponse.getDataPolicyResult().getId();
93+
}
94+
}

0 commit comments

Comments
 (0)