Skip to content

Commit ec4a1c0

Browse files
committed
Merge pull request #245 from GtJosh/3_2_Force_Flag_Change
Make test env data policies all force create jobs
2 parents 4015412 + 5600c93 commit ec4a1c0

File tree

3 files changed

+130
-95
lines changed

3 files changed

+130
-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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
116
package com.spectralogic.ds3client.integration.test.helpers;
217

318
import com.spectralogic.ds3client.Ds3Client;
@@ -59,13 +74,15 @@ public static PutDataPolicySpectraS3Response createDataPolicyWithVersioningAndCr
5974
if (checksumType == null) {
6075
//Create the data policy with versioning
6176
return client.putDataPolicySpectraS3(new PutDataPolicySpectraS3Request(dataPolicyName)
62-
.withVersioning(versioningLevel));
77+
.withVersioning(versioningLevel)
78+
.withAlwaysForcePutJobCreation(true));
6379
}
6480
//Create the data policy with versioning and checksum
6581
return client.putDataPolicySpectraS3(new PutDataPolicySpectraS3Request(dataPolicyName)
6682
.withVersioning(versioningLevel)
6783
.withEndToEndCrcRequired(true)
68-
.withChecksumType(checksumType));
84+
.withChecksumType(checksumType)
85+
.withAlwaysForcePutJobCreation(true));
6986
}
7087

7188
/**
Lines changed: 109 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,109 @@
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+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.integration.test.helpers;
17+
18+
import com.spectralogic.ds3client.Ds3Client;
19+
import com.spectralogic.ds3client.commands.spectrads3.*;
20+
import com.spectralogic.ds3client.models.ChecksumType;
21+
import com.spectralogic.ds3client.models.PoolType;
22+
23+
import java.io.IOException;
24+
import java.security.SignatureException;
25+
import java.util.UUID;
26+
27+
import static com.spectralogic.ds3client.integration.test.helpers.ABMTestHelper.*;
28+
29+
/**
30+
* This is a testing utility designed for creating a temporary data policy, storage domain,
31+
* and partition for use in the integration tests to avoid error if the BP does not currently
32+
* have a partition available for running the unit tests.
33+
*/
34+
public class TempStorageUtil {
35+
36+
private static final String DATA_POLICY_NAME = "_dp";
37+
private static final String STORAGE_DOMAIN_NAME = "_sd";
38+
private static final String POOL_PARTITION_NAME = "_pp";
39+
40+
/**
41+
* Sets up a temporary data policy with a temporary storage domain and partition
42+
* for use in integration tests where the user may not currently have access to
43+
* a partition.
44+
* @param testSetName The unique name of tests being run under this domain to
45+
* prevent race conditions between test setup and teardown
46+
*/
47+
public static TempStorageIds setup(
48+
final String testSetName,
49+
final UUID dataPolicyId,
50+
final Ds3Client client) throws IOException, SignatureException {
51+
//Create storage domain
52+
final PutStorageDomainSpectraS3Response storageDomainResponse = createStorageDomain(
53+
testSetName + STORAGE_DOMAIN_NAME,
54+
client);
55+
56+
//Create pool partition
57+
final PutPoolPartitionSpectraS3Response poolPartitionResponse = createPoolPartition(
58+
testSetName + POOL_PARTITION_NAME,
59+
PoolType.ONLINE,
60+
client);
61+
62+
//Create storage domain member linking pool partition to storage domain
63+
final PutPoolStorageDomainMemberSpectraS3Response memberResponse = createPoolStorageDomainMember(
64+
storageDomainResponse.getStorageDomainResult().getId(),
65+
poolPartitionResponse.getPoolPartitionResult().getId(),
66+
client);
67+
final UUID storageDomainMemberId = memberResponse.getStorageDomainMemberResult().getId();
68+
69+
//create data persistence rule
70+
final PutDataPersistenceRuleSpectraS3Response dataPersistenceResponse = createDataPersistenceRule(
71+
dataPolicyId,
72+
storageDomainResponse.getStorageDomainResult().getId(),
73+
client);
74+
final UUID dataPersistenceRuleId = dataPersistenceResponse.getDataPersistenceRuleResult().getDataPolicyId();
75+
76+
return new TempStorageIds(storageDomainMemberId, dataPersistenceRuleId);
77+
}
78+
79+
/**
80+
* Tears down the temporary test environment
81+
*/
82+
public static void teardown(
83+
final String testSetName,
84+
final TempStorageIds ids,
85+
final Ds3Client client) throws IOException, SignatureException {
86+
deleteDataPersistenceRule(ids.getDataPersistenceRuleId(), client);
87+
deleteDataPolicy(testSetName + DATA_POLICY_NAME, client);
88+
deleteStorageDomainMember(ids.getStorageDomainMemberId(), client);
89+
deleteStorageDomain(testSetName + STORAGE_DOMAIN_NAME, client);
90+
deletePoolPartition(testSetName + POOL_PARTITION_NAME, client);
91+
}
92+
93+
/**
94+
* Creates a Data Policy with the specified checksum type and end-to-end crc requirement
95+
*/
96+
public static UUID setupDataPolicy(
97+
final String testSetName,
98+
final boolean withEndToEndCrcRequired,
99+
final ChecksumType.Type checksumType,
100+
final Ds3Client client) throws IOException, SignatureException {
101+
final PutDataPolicySpectraS3Response dataPolicyResponse = client.putDataPolicySpectraS3(
102+
new PutDataPolicySpectraS3Request(testSetName + DATA_POLICY_NAME)
103+
.withEndToEndCrcRequired(withEndToEndCrcRequired)
104+
.withChecksumType(checksumType).withAlwaysForcePutJobCreation(true));
105+
client.modifyUserSpectraS3(new ModifyUserSpectraS3Request("spectra")
106+
.withDefaultDataPolicyId(dataPolicyResponse.getDataPolicyResult().getId()));
107+
return dataPolicyResponse.getDataPolicyResult().getId();
108+
}
109+
}

0 commit comments

Comments
 (0)