Skip to content

Commit

Permalink
fix: update S3ParquetTestBase testReadWriteUsingProfile
Browse files Browse the repository at this point in the history
This fixes an nightly error that deephaven#6305 introduced where `S3ParquetLocalStackTest.testReadWriteUsingProfile` was not erroring out with the use of an "invalid" region name. While we might want to have some sort of test like this, it should be standalone and not tied to the usage of profiles. As such, the corresponding code was removed.

Ultimately, the behavior was traced down to a difference in behavior between localstack 3.6 and localstack 3.7; the region name logic must have changed in some way. We could do a deep dive into the commits to figure out why the behavior changed, or file an issue, if we care to pursue this further.

https://github.com/localstack/localstack/releases/tag/v3.7.0
  • Loading branch information
devinrsmith committed Oct 29, 2024
1 parent 640ab8f commit 2000b1b
Showing 1 changed file with 3 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,52 +520,12 @@ public void indexByLongKey() {
@Test
public void testReadWriteUsingProfile() throws IOException {
final Table table = TableTools.emptyTable(5).update("someIntColumn = (int) i");
Path tempConfigFile = null;
Path tempCredentialsFile = null;
// Create temporary config and credentials file and write correct credentials and region to them
final Path tempConfigFile = Files.createTempFile("config", ".tmp");
final Path tempCredentialsFile = Files.createTempFile("credentials", ".tmp");
try {
// Create temporary config and credentials file and write wrong credentials to them
tempConfigFile = Files.createTempFile("config", ".tmp");
final String configData = "[profile test-user]\nregion = wrong-region";
Files.write(tempConfigFile, configData.getBytes());

tempCredentialsFile = Files.createTempFile("credentials", ".tmp");
final String credentialsData = "[test-user]\naws_access_key_id = foo\naws_secret_access_key = bar";
Files.write(tempCredentialsFile, credentialsData.getBytes());

final S3Instructions s3Instructions = S3Instructions.builder()
.readTimeout(Duration.ofSeconds(3))
.endpointOverride(s3Endpoint())
.profileName("test-user")
.credentialsFilePath(tempCredentialsFile.toString())
.configFilePath(tempConfigFile.toString())
.credentials(Credentials.profile())
.build();
final ParquetInstructions instructions = ParquetInstructions.builder()
.setSpecialInstructions(s3Instructions)
.build();
try {
final URI uri = uri("table1.parquet");
ParquetTools.writeTable(table, uri.toString(), instructions);
fail("Expected exception");
} catch (final UncheckedDeephavenException expected) {
}
} finally {
// Delete the temporary files
if (tempConfigFile != null) {
Files.deleteIfExists(tempConfigFile);
}
if (tempCredentialsFile != null) {
Files.delete(tempCredentialsFile);
}
}

try {
// Create temporary config and credentials file and write correct credentials and region to them
tempConfigFile = Files.createTempFile("config", ".tmp");
final String configData = "[profile test-user]\nregion = " + region();
Files.write(tempConfigFile, configData.getBytes());

tempCredentialsFile = Files.createTempFile("credentials", ".tmp");
final String credentialsData = "[test-user]\naws_access_key_id = " + accessKey() +
"\naws_secret_access_key = " + secretAccessKey();
Files.write(tempCredentialsFile, credentialsData.getBytes());
Expand Down

0 comments on commit 2000b1b

Please sign in to comment.