Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.stream.Collectors;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -326,6 +327,14 @@ public void setUp() {
createCiphertextTables(client);
}

@AfterTest
public void tearDownDDBLocal() {
if (client != null) {
client.shutdown();
client = null;
}
}

@Test(dataProvider = "getDecryptTestVectors")
public void decryptTestVector(Scenario scenario) throws IOException {
client = DynamoDBEmbedded.create().amazonDynamoDB();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -71,6 +72,14 @@ public void setup() {
methodCalls.clear();
}

@AfterMethod

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to shut down ddb local after each test method? If yes, can you explain why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @AfterMethod is intentional here. The @BeforeMethod setup() creates a new DynamoDB Local client and @AfterMethod is doing the reverse as its consuming a lot of memory without shutting it down.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crux of question is that do we need DB local to be created after each test method? Why can't we setup DB local for a test class and do setup/teardown after the test class is complete. This practice is seen on other test cases in the same PR.

@rishav-karanjit rishav-karanjit Apr 7, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — I've refactored CachingMostRecentProviderTests to create the DDB Local client once in BeforeClass and shut it down in AfterClass, with table create/delete per method for test isolation as test expects it.

For TransformerHolisticIT, the refactor of interop test takes longer — the parameterized tests expect fresh DDB Local instance to get a completely clean database per scenario, and converting that to a shared client would require refactoring of interop test. Since we plan to delete sdkv1 anyway, I did not refactor all of the interop test.

public void tearDownDDBLocal() {
if (client != null) {
client.shutdown();
client = null;
}
}

@Test
public void testConstructors() {
final CachingMostRecentProvider prov = new CachingMostRecentProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.testng.annotations.AfterClass;

public class DynamoDBTestBase {

Expand All @@ -30,6 +31,14 @@ public static void setUpTestBase() {
dynamo = DynamoDBEmbedded.create().amazonDynamoDB();
}

@AfterClass
public static void tearDownDDBLocal() {
if (dynamo != null) {
dynamo.shutdown();
dynamo = null;
}
}

public static AmazonDynamoDB getClient() {
if (dynamo == null) {
setUpTestBase();
Expand Down
Loading