Skip to content

Commit 796de41

Browse files
committed
Modified tests
1 parent 73da94a commit 796de41

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AAnalyticsAcceleratorStreamReading.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -205,61 +205,4 @@ public void testInvalidConfigurationThrows() throws Exception {
205205
() -> S3SeekableInputStreamConfiguration.fromConfiguration(connectorConfiguration));
206206
}
207207

208-
/**
209-
* This test verifies that the OpenStreamInfo object contains correct encryption
210-
* settings when reading an SSEC encrypted file with analytics stream.
211-
*
212-
* @throws Exception
213-
*/
214-
215-
@Test
216-
public void testAnalyticsStreamOpenStreamInfoWhenSSECEncryptionEnabled() throws Exception {
217-
Configuration confSSEC = this.createConfiguration();
218-
S3ATestUtils.disableFilesystemCaching(confSSEC);
219-
removeBaseAndBucketOverrides(getTestBucketName(confSSEC), confSSEC, S3_ENCRYPTION_ALGORITHM, S3_ENCRYPTION_KEY);
220-
221-
confSSEC.set(S3_ENCRYPTION_ALGORITHM, S3AEncryptionMethods.SSE_C.getMethod());
222-
confSSEC.set(S3_ENCRYPTION_KEY, SSEC_KEY);
223-
224-
S3AContract contractSSEC = (S3AContract) createContract(confSSEC);
225-
contractSSEC.init();
226-
contractSSEC.setConf(confSSEC);
227-
S3AFileSystem fileSystemSSEC = (S3AFileSystem) contractSSEC.getTestFileSystem();
228-
229-
int len = TEST_FILE_LEN;
230-
describe("Create an encrypted file and verify OpenStreamInfo encryption settings");
231-
Path src = methodPath();
232-
byte[] data = dataset(len, 'a', 'z');
233-
writeDataset(fileSystemSSEC, src, data, len, 1024 * 1024, true);
234-
// Read with encryption settings
235-
OpenStreamInformation originalInfo;
236-
try (FSDataInputStream in = fileSystemSSEC.open(src)) {
237-
AnalyticsStream s3AInputStream = (AnalyticsStream) in.getWrappedStream();
238-
Field inputStreamField = s3AInputStream.getClass().getDeclaredField("inputStream");
239-
inputStreamField.setAccessible(true);
240-
S3SeekableInputStream seekableInputStream = (S3SeekableInputStream) inputStreamField.get(s3AInputStream);
241-
242-
Field logicalIOField = seekableInputStream.getClass().getDeclaredField("logicalIO");
243-
logicalIOField.setAccessible(true);
244-
Object logicalIO = logicalIOField.get(seekableInputStream);
245-
246-
Field physicalIOField = logicalIO.getClass().getDeclaredField("physicalIO");
247-
physicalIOField.setAccessible(true);
248-
Object physicalIO = physicalIOField.get(logicalIO);
249-
250-
Field openStreamInfoField = physicalIO.getClass().getDeclaredField("openStreamInformation");
251-
openStreamInfoField.setAccessible(true);
252-
originalInfo = (OpenStreamInformation) openStreamInfoField.get(physicalIO);
253-
254-
// Verify the OpenStreamInfo object exists
255-
assertNotNull(originalInfo.getEncryptionSecrets().getSsecCustomerKey().get(), "OpenStreamInfo should not be null");
256-
assertEquals(SSEC_KEY, originalInfo.getEncryptionSecrets().getSsecCustomerKey().get());
257-
}
258-
259-
// Clean up
260-
fileSystemSSEC.delete(src, false);
261-
}
262-
263-
264-
265208
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AEncryptionSSEC.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_KEY;
4141

4242
import static org.apache.hadoop.fs.s3a.S3ATestUtils.assumeStoreAwsHosted;
43+
import static org.apache.hadoop.fs.s3a.S3ATestUtils.enableAnalyticsAccelerator;
4344
import static org.apache.hadoop.fs.s3a.S3ATestUtils.getTestBucketName;
4445
import static org.apache.hadoop.fs.s3a.S3ATestUtils.maybeSkipRootTests;
4546
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
@@ -324,6 +325,65 @@ public void testChecksumRequiresReadAccess() throws Throwable {
324325
() -> fsKeyB.getFileChecksum(path));
325326
}
326327

328+
329+
/**
330+
* Tests the creation and reading of a file using a different encryption key
331+
* when Analytics Accelerator is enabled.
332+
*
333+
* @throws Exception if any error occurs during the test execution
334+
*/
335+
@Test
336+
public void testCreateFileAndReadWithDifferentEncryptionKeyWithAnalyticsAcceleratorEnabled() throws Exception {
337+
enableAnalyticsAccelerator(getConfiguration());
338+
testCreateFileAndReadWithDifferentEncryptionKey();
339+
}
340+
341+
/**
342+
* Tests the creation and movement of a file using a different SSE-C key
343+
* when Analytics Accelerator is enabled.
344+
*
345+
* @throws Exception if any error occurs during the test execution
346+
*/
347+
@Test
348+
public void testCreateFileThenMoveWithDifferentSSECKeyWithAnalyticsAcceleratorEnabled() throws Exception {
349+
enableAnalyticsAccelerator(getConfiguration());
350+
testCreateFileThenMoveWithDifferentSSECKey();
351+
}
352+
353+
/**
354+
* Tests create and file rename operation when Analytics Accelerator is enabled.
355+
*
356+
* @throws Exception if any error occurs during the test execution
357+
*/
358+
@Test
359+
public void testCreateFileAndRenameFileWithAnalyticsAcceleratorEnabled() throws Exception {
360+
enableAnalyticsAccelerator(getConfiguration());
361+
testRenameFile();
362+
}
363+
364+
/**
365+
* Tests the creation and listing of encrypted files when Analytics Accelerator is enabled.
366+
*
367+
* @throws Exception if any error occurs during the test execution
368+
*/
369+
@Test
370+
public void testCreateFileAndListStatusEncryptedFileWithAnalyticsAcceleratorEnabled() throws Exception {
371+
enableAnalyticsAccelerator(getConfiguration());
372+
testListStatusEncryptedFile();
373+
}
374+
375+
/**
376+
* Tests the creation and deletion of an encrypted object using a different key
377+
* when Analytics Accelerator is enabled.t.
378+
*
379+
* @throws Exception if any error occurs during the test execution
380+
*/
381+
@Test
382+
public void testCreateFileAndDeleteEncryptedObjectWithDifferentKeyWithAnalyticsAcceleratorEnabled() throws Exception {
383+
enableAnalyticsAccelerator(getConfiguration());
384+
testDeleteEncryptedObjectWithDifferentKey();
385+
}
386+
327387
private S3AFileSystem createNewFileSystemWithSSECKey(String sseCKey) throws
328388
IOException {
329389
Configuration conf = this.createConfiguration();

0 commit comments

Comments
 (0)