Skip to content

Commit

Permalink
updated the SDK build number
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Jan 8, 2025
1 parent da9a7a6 commit 8a9f6bd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 167 deletions.
2 changes: 1 addition & 1 deletion javav2/example_code/identitystore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.29.45</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
10 changes: 9 additions & 1 deletion javav2/example_code/iot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.29.45</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -114,5 +114,13 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion javav2/example_code/iotsitewise/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.27.22</version>
<version>2.29.45</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
10 changes: 9 additions & 1 deletion javav2/example_code/kendra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.29.45</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -95,5 +95,13 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>kendra</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
</dependency>
</dependencies>
</project>
10 changes: 9 additions & 1 deletion javav2/example_code/keyspaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.21.20</version>
<version>2.29.45</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -91,5 +91,13 @@
<artifactId>cassandra-driver-core</artifactId>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
</dependency>
</dependencies>
</project>
169 changes: 7 additions & 162 deletions javav2/example_code/keyspaces/src/test/java/KeyspaceTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
import com.example.keyspace.ScenarioKeyspaces;
import com.google.gson.Gson;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;

import com.example.keyspace.HelloKeyspaces;
import org.junit.jupiter.api.Tag;
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
import org.junit.jupiter.api.TestInstance;
Expand All @@ -17,179 +13,28 @@
import org.junit.jupiter.api.Order;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.keyspaces.KeyspacesClient;
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
import java.io.IOException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

@TestInstance(TestInstance.Lifecycle.PER_METHOD)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class KeyspaceTest {
public static final String DASHES = new String(new char[80]).replace("\0", "-");
private static String fileName = "";
private static String keyspaceName = "";
private static String titleUpdate = "The Family";
private static int yearUpdate = 2013;
private static String tableName = "Movie";
private static String tableNameRestore = "MovieRestore";
private static KeyspacesClient keyClient;
private static CqlSession session;

@BeforeAll
public static void setUp() {
Random rand = new Random();
int randomNum = rand.nextInt((10000 - 1) + 1) + 1;
keyspaceName = "key" + randomNum;
Region region = Region.US_EAST_1;
keyClient = KeyspacesClient.builder()
.region(region)
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();

DriverConfigLoader loader = DriverConfigLoader.fromClasspath("application.conf");
session = CqlSession.builder()
.withConfigLoader(loader)
.build();

// Get the values to run these tests from AWS Secrets Manager.
Gson gson = new Gson();
String json = getSecretValues();
SecretValues values = gson.fromJson(json, SecretValues.class);
fileName = values.getFileName();
keyspaceName = values.getKeyspaceName() + randomNum;
}

@Test
@Tag("IntegrationTest")
@Order(1)
public void scenarioTest() throws InterruptedException, IOException {
System.out.println(DASHES);
System.out.println("1. Create a keyspace.");
ScenarioKeyspaces.createKeySpace(keyClient, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
Thread.sleep(5000);
System.out.println("2. Check for keyspace existence.");
ScenarioKeyspaces.checkKeyspaceExistence(keyClient, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("3. List keyspaces using a paginator.");
ScenarioKeyspaces.listKeyspacesPaginator(keyClient);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("4. Create a table with a simple movie data schema, and enable point-in-time recovery.");
ScenarioKeyspaces.createTable(keyClient, keyspaceName, tableName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("5. Check for the table to be in an Active state.");
Thread.sleep(6000);
ScenarioKeyspaces.checkTable(keyClient, keyspaceName, tableName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("6. Use a Cassandra driver to insert some records into the Movie table.");
Thread.sleep(6000);
ScenarioKeyspaces.loadData(session, fileName, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("7. Get all records from the Movie table.");
ScenarioKeyspaces.getMovieData(session, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("8. Get a specific Movie.");
ScenarioKeyspaces.getSpecificMovie(session, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("9. Get a UTC timestamp for the current time.");
ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
System.out.println("DATETIME = " + Date.from(utc.toInstant()));
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("10. Update the table schema to add a watched Boolean column.");
ScenarioKeyspaces.updateTable(keyClient, keyspaceName, tableName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("11. Update an item as watched.");
Thread.sleep(10000); // Wait 10 secs for the update.
ScenarioKeyspaces.updateRecord(session, keyspaceName, titleUpdate, yearUpdate);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("12. Query for items with watched = True.");
ScenarioKeyspaces.getWatchedData(session, keyspaceName);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("13. Restore the table back to the previous state using the timestamp.");
System.out.println("Note that the restore operation can take up to 20 minutes.");
ScenarioKeyspaces.restoreTable(keyClient, keyspaceName, utc);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("14. Check for completion of the restore action.");
Thread.sleep(5000);
ScenarioKeyspaces.checkRestoredTable(keyClient, keyspaceName, "MovieRestore");
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("15. Delete both tables.");
ScenarioKeyspaces.deleteTable(keyClient, keyspaceName, tableName);
ScenarioKeyspaces.deleteTable(keyClient, keyspaceName, tableNameRestore);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("16. Confirm that the table was deleted.");
ScenarioKeyspaces.checkTableDelete(keyClient, keyspaceName, tableName);
ScenarioKeyspaces.checkTableDelete(keyClient, keyspaceName, tableNameRestore);
System.out.println(DASHES);

System.out.println(DASHES);
System.out.println("17. Delete the keyspace.");
ScenarioKeyspaces.deleteKeyspace(keyClient, keyspaceName);
System.out.println(DASHES);
}

public static String getSecretValues() {
// Get the Amazon RDS creds from Secrets Manager.
SecretsManagerClient secretClient = SecretsManagerClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
String secretName = "test/keyspace";

GetSecretValueRequest valueRequest = GetSecretValueRequest.builder()
.secretId(secretName)
.build();

GetSecretValueResponse valueResponse = secretClient.getSecretValue(valueRequest);
return valueResponse.secretString();
}

@Nested
@DisplayName("A class used to get test values from test/keyspace (an AWS Secrets Manager secret)")
class SecretValues {
private String fileName;
private String keyspaceName;

public String getFileName() {
return fileName;
}

public String getKeyspaceName() {
return keyspaceName;
}
public void KeyspaceTest() {
assertDoesNotThrow(() -> HelloKeyspaces.listKeyspaces(keyClient),
"Failed to list namespaces.");
System.out.println("Test passed");
}
}

0 comments on commit 8a9f6bd

Please sign in to comment.