mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 00:45:17 -05:00
test(bedrock): reuse inference-profile metadata test helpers (#9044)
Share same-account client construction and successful summary lookup in the existing metadata tests. Preserve each test assertion, region and resource lifetime, including the unavailable-region negative control. Closes #9043
This commit is contained in:
1 parent
61be3048e7
commit
fca7dfdd22
1 file changed
+16
-12
+16
-12
@@ -22,7 +22,7 @@ class BedrockInferenceProfileMetadataIntegrationTest {
|
||||
|
||||
@Test
|
||||
void getFoundationModelAdvertisesOnDemandAndInferenceProfileSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
try (BedrockClient client = client(Region.US_EAST_1)) {
|
||||
FoundationModelDetails model = client.getFoundationModel(request -> request.modelIdentifier(MODEL))
|
||||
.modelDetails();
|
||||
assertEquals(MODEL, model.modelId());
|
||||
@@ -32,21 +32,19 @@ class BedrockInferenceProfileMetadataIntegrationTest {
|
||||
|
||||
@Test
|
||||
void modelWithoutAProfileOnlyAdvertisesOnDemandSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
try (BedrockClient client = client(Region.US_EAST_1)) {
|
||||
String modelId = "amazon.titan-embed-text-v2:0";
|
||||
assertEquals(List.of("ON_DEMAND"), client.getFoundationModel(request -> request
|
||||
.modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings());
|
||||
FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow();
|
||||
FoundationModelSummary listed = summary(client, modelId);
|
||||
assertEquals(List.of("ON_DEMAND"), listed.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void listFoundationModelsAdvertisesOnDemandAndInferenceProfileSupport() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) {
|
||||
FoundationModelSummary model = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(candidate -> MODEL.equals(candidate.modelId())).findFirst().orElseThrow();
|
||||
try (BedrockClient client = client(Region.US_EAST_1)) {
|
||||
FoundationModelSummary model = summary(client, MODEL);
|
||||
assertEquals(List.of("ON_DEMAND", "INFERENCE_PROFILE"), model.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
@@ -54,19 +52,17 @@ class BedrockInferenceProfileMetadataIntegrationTest {
|
||||
@Test
|
||||
void profileOnlyRegionAdvertisesOnlyInferenceProfilesOnGetAndList() {
|
||||
String modelId = "amazon.nova-micro-v1:0";
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.EU_CENTRAL_1)) {
|
||||
try (BedrockClient client = client(Region.EU_CENTRAL_1)) {
|
||||
assertEquals(List.of("INFERENCE_PROFILE"), client.getFoundationModel(request -> request
|
||||
.modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings());
|
||||
FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow();
|
||||
FoundationModelSummary listed = summary(client, modelId);
|
||||
assertEquals(List.of("INFERENCE_PROFILE"), listed.inferenceTypesSupportedAsStrings());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void unavailableRegionExcludesTheModelAndRetainsGetValidation() {
|
||||
try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022",
|
||||
Region.AP_NORTHEAST_3)) {
|
||||
try (BedrockClient client = client(Region.AP_NORTHEAST_3)) {
|
||||
ValidationException error = assertThrows(ValidationException.class,
|
||||
() -> client.getFoundationModel(request -> request.modelIdentifier(MODEL)));
|
||||
assertEquals(400, error.statusCode());
|
||||
@@ -75,4 +71,12 @@ class BedrockInferenceProfileMetadataIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static BedrockClient client(Region region) {
|
||||
return AwsTestClients.create(BedrockClient.builder(), "741623800022", region);
|
||||
}
|
||||
|
||||
private static FoundationModelSummary summary(BedrockClient client, String modelId) {
|
||||
return client.listFoundationModels(request -> { }).modelSummaries().stream()
|
||||
.filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user