diff --git a/README.md b/README.md index 6121ea4619..ed29f82f83 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ Run AWS-compatible services locally without an AWS account, auth token, or paid
Real Docker where fidelity matters -Lambda, RDS, ElastiCache, MSK, ECS, EC2, EKS, OpenSearch, and CodeBuild use real Docker-backed execution instead of shallow mocks. +Lambda, RDS, Neptune, ElastiCache, MSK, ECS, EC2, EKS, OpenSearch, and CodeBuild use real Docker-backed execution instead of shallow mocks.
@@ -161,6 +161,7 @@ LocalStack's community edition [sunset in March 2026](https://blog.localstack.cl | API Gateway v2 / HTTP API | Yes | No | | Cognito | Yes | No | | RDS, ElastiCache, MSK | Real Docker | No | +| Neptune (graph DB + Gremlin WebSocket) | Real Docker | No | | ECS, EC2, EKS | Real Docker | No | | CodeBuild | Real Docker execution | No | | Native binary | ~40 MB | No | @@ -185,7 +186,7 @@ flowchart LR end subgraph Containers ["Container Services"] - C["Lambda\nElastiCache\nRDS\nECS\nEC2\nMSK\nEKS\nOpenSearch\nCodeBuild"] + C["Lambda\nElastiCache\nRDS\nNeptune\nECS\nEC2\nMSK\nEKS\nOpenSearch\nCodeBuild"] D["Athena -> floci-duck\nDuckDB sidecar"] end @@ -210,6 +211,7 @@ Floci supports local emulation for application services, data services, eventing | Events and workflows | EventBridge, EventBridge Scheduler, Step Functions, CloudWatch Logs, CloudWatch Metrics | | API and identity | API Gateway REST, API Gateway v2, Cognito, ACM, Route53 | | Containers and compute | ECS, EC2, EKS, CodeBuild, CodeDeploy, Auto Scaling, ELB v2 | +| Graph database | Neptune | | Data and analytics | Athena, Glue, Firehose, OpenSearch, Textract | | Messaging and transfer | SES, SES v2, Kinesis, Transfer Family | | Cost and billing | Pricing, Cost Explorer, Cost and Usage Reports, BCM Data Exports | @@ -246,6 +248,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/ | CloudWatch Metrics | In-process | Custom metrics, statistics, alarms | | ElastiCache | Real Docker | Redis / Valkey protocol, IAM auth, SigV4 validation | | RDS | Real Docker | PostgreSQL, MySQL, MariaDB, IAM auth, JDBC-compatible engines | +| Neptune | Real Docker | Graph DB via TinkerPop Gremlin Server; RDS-shaped control plane; Gremlin WebSocket on port 8182 with SigV4 proxy | | MSK | Real Docker | Kafka-compatible broker via Redpanda | | Athena | In-process with DuckDB sidecar | Real SQL execution over S3 and Glue-backed views | | Glue | In-process | Data Catalog, Schema Registry, tables consumed by Athena | @@ -288,6 +291,7 @@ Floci uses real Docker containers when in-process emulation would reduce fidelit | RDS PostgreSQL | `postgres:16-alpine` | PostgreSQL engine, IAM auth, JDBC-compatible access | | RDS MySQL / Aurora | `mysql:8.0` | MySQL engine, IAM auth, JDBC-compatible access | | RDS MariaDB | `mariadb:11` | MariaDB engine, IAM auth, JDBC-compatible access | +| Neptune | `tinkerpop/gremlin-server:3.7.3` | TinkerPop Gremlin Server; Gremlin WebSocket on port 8182; SigV4 auth proxy | | MSK | `redpandadata/redpanda:latest` | Kafka-compatible broker via Redpanda | | EC2 | AMI-mapped Linux images | Linux containers, SSH key injection, UserData, IMDS, IAM credentials | | ECS | User-specified task image | Container lifecycle, start, stop, health checks | @@ -316,6 +320,7 @@ docker run -d --name floci \ | `FLOCI_SERVICES_RDS_DEFAULT_MARIADB_IMAGE` | `mariadb:11` | | `FLOCI_SERVICES_MSK_DEFAULT_IMAGE` | `redpandadata/redpanda:latest` | | `FLOCI_SERVICES_OPENSEARCH_DEFAULT_IMAGE` | `opensearchproject/opensearch:2` | +| `FLOCI_SERVICES_NEPTUNE_DEFAULT_IMAGE` | `tinkerpop/gremlin-server:3.7.3` | | `FLOCI_SERVICES_EKS_DEFAULT_IMAGE` | `rancher/k3s:latest` | | `FLOCI_SERVICES_ECR_REGISTRY_IMAGE` | `registry:2` | | `FLOCI_ECR_BASE_URI` | `public.ecr.aws` | @@ -634,17 +639,17 @@ The [`compatibility-tests`](./compatibility-tests/) directory validates Floci ac | Module | Language / Tool | SDK / Client | Tests | |---|---|---|---:| -| `sdk-test-java` | Java 17 | AWS SDK for Java v2 | 889 | -| `sdk-test-node` | Node.js | AWS SDK for JavaScript v3 | 360 | -| `sdk-test-python` | Python 3 | boto3 | 264 | -| `sdk-test-go` | Go | AWS SDK for Go v2 | 136 | -| `sdk-test-awscli` | Bash | AWS CLI v2 | 145 | -| `sdk-test-rust` | Rust | AWS SDK for Rust | 86 | +| `sdk-test-java` | Java 17 | AWS SDK for Java v2 | 899 | +| `sdk-test-node` | Node.js | AWS SDK for JavaScript v3 | 366 | +| `sdk-test-python` | Python 3 | boto3 | 272 | +| `sdk-test-go` | Go | AWS SDK for Go v2 | 144 | +| `sdk-test-awscli` | Bash | AWS CLI v2 | 152 | +| `sdk-test-rust` | Rust | AWS SDK for Rust | 90 | | `compat-terraform` | Terraform | v1.10+ | 14 | | `compat-opentofu` | OpenTofu | v1.9+ | 14 | | `compat-cdk` | AWS CDK | v2+ | 17 | -**1,850+ automated compatibility tests across 6 SDKs and 3 IaC tools.** +**1,968 automated compatibility tests across 6 SDKs and 3 IaC tools.** ## Migrating from LocalStack diff --git a/compatibility-tests/sdk-test-awscli/test/neptune.bats b/compatibility-tests/sdk-test-awscli/test/neptune.bats new file mode 100644 index 0000000000..d7a38f9db5 --- /dev/null +++ b/compatibility-tests/sdk-test-awscli/test/neptune.bats @@ -0,0 +1,170 @@ +#!/usr/bin/env bats +# Neptune cluster and instance management tests + +setup() { + load 'test_helper/common-setup' + CLUSTER_ID="bats-neptune-$(unique_name)" + INSTANCE_ID="bats-neptune-inst-$(unique_name)" + CLUSTER_CREATED=false + INSTANCE_CREATED=false +} + +teardown() { + if [ "$INSTANCE_CREATED" = "true" ]; then + aws_cmd neptune delete-db-instance \ + --db-instance-identifier "$INSTANCE_ID" >/dev/null 2>&1 || true + fi + if [ "$CLUSTER_CREATED" = "true" ]; then + aws_cmd neptune delete-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --skip-final-snapshot >/dev/null 2>&1 || true + fi +} + +@test "Neptune: create DB cluster" { + run aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune + assert_success + CLUSTER_CREATED=true + + id=$(json_get "$output" '.DBCluster.DBClusterIdentifier') + engine=$(json_get "$output" '.DBCluster.Engine') + status=$(json_get "$output" '.DBCluster.Status') + arn=$(json_get "$output" '.DBCluster.DBClusterArn') + port=$(json_get "$output" '.DBCluster.Port') + + [ "$id" = "$CLUSTER_ID" ] + [ "$engine" = "neptune" ] + [ "$status" = "available" ] + [[ "$arn" == arn:aws:neptune:* ]] + [ "$port" -gt 0 ] +} + +@test "Neptune: create duplicate cluster fails" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + + run aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune + assert_failure + [[ "$output" == *"DBClusterAlreadyExistsFault"* ]] +} + +@test "Neptune: describe DB cluster by ID" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + + run aws_cmd neptune describe-db-clusters \ + --db-cluster-identifier "$CLUSTER_ID" + assert_success + + id=$(json_get "$output" '.DBClusters[0].DBClusterIdentifier') + [ "$id" = "$CLUSTER_ID" ] +} + +@test "Neptune: modify DB cluster IAM auth" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + + run aws_cmd neptune modify-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --enable-iam-database-authentication + assert_success + + iam=$(json_get "$output" '.DBCluster.IAMDatabaseAuthenticationEnabled') + [ "$iam" = "true" ] +} + +@test "Neptune: create DB instance in cluster" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + + run aws_cmd neptune create-db-instance \ + --db-instance-identifier "$INSTANCE_ID" \ + --db-cluster-identifier "$CLUSTER_ID" \ + --db-instance-class db.r5.large \ + --engine neptune + assert_success + INSTANCE_CREATED=true + + id=$(json_get "$output" '.DBInstance.DBInstanceIdentifier') + cluster=$(json_get "$output" '.DBInstance.DBClusterIdentifier') + status=$(json_get "$output" '.DBInstance.DBInstanceStatus') + + [ "$id" = "$INSTANCE_ID" ] + [ "$cluster" = "$CLUSTER_ID" ] + [ "$status" = "available" ] +} + +@test "Neptune: describe DB instance by ID" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + aws_cmd neptune create-db-instance \ + --db-instance-identifier "$INSTANCE_ID" \ + --db-cluster-identifier "$CLUSTER_ID" \ + --db-instance-class db.r5.large \ + --engine neptune >/dev/null + INSTANCE_CREATED=true + + run aws_cmd neptune describe-db-instances \ + --db-instance-identifier "$INSTANCE_ID" + assert_success + + id=$(json_get "$output" '.DBInstances[0].DBInstanceIdentifier') + [ "$id" = "$INSTANCE_ID" ] +} + +@test "Neptune: delete cluster with instance fails" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + aws_cmd neptune create-db-instance \ + --db-instance-identifier "$INSTANCE_ID" \ + --db-cluster-identifier "$CLUSTER_ID" \ + --db-instance-class db.r5.large \ + --engine neptune >/dev/null + INSTANCE_CREATED=true + + run aws_cmd neptune delete-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --skip-final-snapshot + assert_failure + [[ "$output" == *"InvalidDBClusterStateFault"* ]] +} + +@test "Neptune: delete DB instance then cluster" { + aws_cmd neptune create-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --engine neptune >/dev/null + CLUSTER_CREATED=true + aws_cmd neptune create-db-instance \ + --db-instance-identifier "$INSTANCE_ID" \ + --db-cluster-identifier "$CLUSTER_ID" \ + --db-instance-class db.r5.large \ + --engine neptune >/dev/null + INSTANCE_CREATED=true + + run aws_cmd neptune delete-db-instance \ + --db-instance-identifier "$INSTANCE_ID" + assert_success + INSTANCE_CREATED=false + + run aws_cmd neptune delete-db-cluster \ + --db-cluster-identifier "$CLUSTER_ID" \ + --skip-final-snapshot + assert_success + CLUSTER_CREATED=false +} diff --git a/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go b/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go index c9cf8985aa..e309ec9411 100644 --- a/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go +++ b/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go @@ -20,6 +20,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/kinesis" "github.com/aws/aws-sdk-go-v2/service/kms" "github.com/aws/aws-sdk-go-v2/service/lambda" + "github.com/aws/aws-sdk-go-v2/service/neptune" "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/secretsmanager" @@ -133,6 +134,11 @@ func RDSClient() *rds.Client { return rds.NewFromConfig(Config()) } +// NeptuneClient returns a new Neptune client. +func NeptuneClient() *neptune.Client { + return neptune.NewFromConfig(Config()) +} + // CognitoClient returns a new Cognito Identity Provider client. func CognitoClient() *cognitoidentityprovider.Client { return cognitoidentityprovider.NewFromConfig(Config()) diff --git a/compatibility-tests/sdk-test-go/tests/neptune_test.go b/compatibility-tests/sdk-test-go/tests/neptune_test.go new file mode 100644 index 0000000000..a05a6fe0d3 --- /dev/null +++ b/compatibility-tests/sdk-test-go/tests/neptune_test.go @@ -0,0 +1,131 @@ +package tests + +import ( + "context" + "fmt" + "testing" + "time" + + "floci-sdk-test-go/internal/testutil" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/neptune" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNeptuneCluster(t *testing.T) { + ctx := context.Background() + svc := testutil.NeptuneClient() + clusterId := fmt.Sprintf("go-neptune-%d", time.Now().UnixMilli()%100000) + + t.Cleanup(func() { + svc.DeleteDBCluster(ctx, &neptune.DeleteDBClusterInput{ //nolint:errcheck + DBClusterIdentifier: aws.String(clusterId), + SkipFinalSnapshot: aws.Bool(true), + }) + }) + + t.Run("CreateDBCluster", func(t *testing.T) { + out, err := svc.CreateDBCluster(ctx, &neptune.CreateDBClusterInput{ + DBClusterIdentifier: aws.String(clusterId), + Engine: aws.String("neptune"), + }) + require.NoError(t, err) + require.NotNil(t, out.DBCluster) + assert.Equal(t, clusterId, aws.ToString(out.DBCluster.DBClusterIdentifier)) + assert.Equal(t, "neptune", aws.ToString(out.DBCluster.Engine)) + assert.Equal(t, "available", aws.ToString(out.DBCluster.Status)) + assert.Contains(t, aws.ToString(out.DBCluster.DBClusterArn), "arn:aws:neptune:") + assert.Greater(t, aws.ToInt32(out.DBCluster.Port), int32(0)) + }) + + t.Run("DescribeDBClusters", func(t *testing.T) { + out, err := svc.DescribeDBClusters(ctx, &neptune.DescribeDBClustersInput{ + DBClusterIdentifier: aws.String(clusterId), + }) + require.NoError(t, err) + require.Len(t, out.DBClusters, 1) + assert.Equal(t, clusterId, aws.ToString(out.DBClusters[0].DBClusterIdentifier)) + }) + + t.Run("ModifyDBCluster", func(t *testing.T) { + out, err := svc.ModifyDBCluster(ctx, &neptune.ModifyDBClusterInput{ + DBClusterIdentifier: aws.String(clusterId), + EnableIAMDatabaseAuthentication: aws.Bool(true), + }) + require.NoError(t, err) + assert.True(t, aws.ToBool(out.DBCluster.IAMDatabaseAuthenticationEnabled)) + }) + + t.Run("DeleteDBCluster", func(t *testing.T) { + _, err := svc.DeleteDBCluster(ctx, &neptune.DeleteDBClusterInput{ + DBClusterIdentifier: aws.String(clusterId), + SkipFinalSnapshot: aws.Bool(true), + }) + require.NoError(t, err) + }) +} + +func TestNeptuneInstance(t *testing.T) { + ctx := context.Background() + svc := testutil.NeptuneClient() + clusterId := fmt.Sprintf("go-neptune-cl-%d", time.Now().UnixMilli()%100000) + instanceId := fmt.Sprintf("go-neptune-inst-%d", time.Now().UnixMilli()%100000) + + // Create cluster first + _, err := svc.CreateDBCluster(ctx, &neptune.CreateDBClusterInput{ + DBClusterIdentifier: aws.String(clusterId), + Engine: aws.String("neptune"), + }) + require.NoError(t, err, "setup: create Neptune cluster") + + t.Cleanup(func() { + svc.DeleteDBInstance(ctx, &neptune.DeleteDBInstanceInput{ //nolint:errcheck + DBInstanceIdentifier: aws.String(instanceId), + }) + svc.DeleteDBCluster(ctx, &neptune.DeleteDBClusterInput{ //nolint:errcheck + DBClusterIdentifier: aws.String(clusterId), + SkipFinalSnapshot: aws.Bool(true), + }) + }) + + t.Run("CreateDBInstance", func(t *testing.T) { + out, err := svc.CreateDBInstance(ctx, &neptune.CreateDBInstanceInput{ + DBInstanceIdentifier: aws.String(instanceId), + DBClusterIdentifier: aws.String(clusterId), + DBInstanceClass: aws.String("db.r5.large"), + Engine: aws.String("neptune"), + }) + require.NoError(t, err) + require.NotNil(t, out.DBInstance) + assert.Equal(t, instanceId, aws.ToString(out.DBInstance.DBInstanceIdentifier)) + assert.Equal(t, clusterId, aws.ToString(out.DBInstance.DBClusterIdentifier)) + assert.Equal(t, "available", aws.ToString(out.DBInstance.DBInstanceStatus)) + }) + + t.Run("DescribeDBInstances", func(t *testing.T) { + out, err := svc.DescribeDBInstances(ctx, &neptune.DescribeDBInstancesInput{ + DBInstanceIdentifier: aws.String(instanceId), + }) + require.NoError(t, err) + require.Len(t, out.DBInstances, 1) + assert.Equal(t, instanceId, aws.ToString(out.DBInstances[0].DBInstanceIdentifier)) + }) + + t.Run("ModifyDBInstance", func(t *testing.T) { + out, err := svc.ModifyDBInstance(ctx, &neptune.ModifyDBInstanceInput{ + DBInstanceIdentifier: aws.String(instanceId), + DBInstanceClass: aws.String("db.r5.xlarge"), + }) + require.NoError(t, err) + assert.Equal(t, "db.r5.xlarge", aws.ToString(out.DBInstance.DBInstanceClass)) + }) + + t.Run("DeleteDBInstance", func(t *testing.T) { + _, err := svc.DeleteDBInstance(ctx, &neptune.DeleteDBInstanceInput{ + DBInstanceIdentifier: aws.String(instanceId), + }) + require.NoError(t, err) + }) +} diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml index fab2edc598..4867ea31e6 100644 --- a/compatibility-tests/sdk-test-java/pom.xml +++ b/compatibility-tests/sdk-test-java/pom.xml @@ -153,6 +153,10 @@ software.amazon.awssdk rds + + software.amazon.awssdk + neptune + software.amazon.awssdk diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java index a5ed6e65e1..fa1ab49d98 100644 --- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java +++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java @@ -17,6 +17,7 @@ import software.amazon.awssdk.http.Protocol; import software.amazon.awssdk.services.kms.KmsClient; import software.amazon.awssdk.services.lambda.LambdaClient; import software.amazon.awssdk.services.opensearch.OpenSearchClient; +import software.amazon.awssdk.services.neptune.NeptuneClient; import software.amazon.awssdk.services.rds.RdsClient; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.endpoints.Endpoint; @@ -484,6 +485,14 @@ public final class TestFixtures { .build(); } + public static NeptuneClient neptuneClient() { + return NeptuneClient.builder() + .endpointOverride(ENDPOINT) + .region(REGION) + .credentialsProvider(CREDENTIALS) + .build(); + } + public static ElastiCacheClient elastiCacheClient() { return ElastiCacheClient.builder() .endpointOverride(ENDPOINT) diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/NeptuneTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/NeptuneTest.java new file mode 100644 index 0000000000..6c49b4077a --- /dev/null +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/NeptuneTest.java @@ -0,0 +1,179 @@ +package com.floci.test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import software.amazon.awssdk.services.neptune.NeptuneClient; +import software.amazon.awssdk.services.neptune.model.CreateDbClusterRequest; +import software.amazon.awssdk.services.neptune.model.CreateDbInstanceRequest; +import software.amazon.awssdk.services.neptune.model.DeleteDbClusterRequest; +import software.amazon.awssdk.services.neptune.model.DeleteDbInstanceRequest; +import software.amazon.awssdk.services.neptune.model.DescribeDbClustersRequest; +import software.amazon.awssdk.services.neptune.model.DescribeDbInstancesRequest; +import software.amazon.awssdk.services.neptune.model.InvalidDbClusterStateException; +import software.amazon.awssdk.services.neptune.model.ModifyDbClusterRequest; +import software.amazon.awssdk.services.neptune.model.ModifyDbInstanceRequest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@DisplayName("Neptune Cluster and Instance Management") +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +class NeptuneTest { + + private static NeptuneClient neptune; + private static final String CLUSTER_ID = TestFixtures.uniqueName("neptune-cl"); + private static final String INSTANCE_ID = TestFixtures.uniqueName("neptune-inst"); + + @BeforeAll + static void setup() { + neptune = TestFixtures.neptuneClient(); + } + + @AfterAll + static void cleanup() { + if (neptune == null) return; + try { + neptune.deleteDBInstance(DeleteDbInstanceRequest.builder() + .dbInstanceIdentifier(INSTANCE_ID) + .build()); + } catch (Exception ignored) {} + try { + neptune.deleteDBCluster(DeleteDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .skipFinalSnapshot(true) + .build()); + } catch (Exception ignored) {} + neptune.close(); + } + + @Test + @Order(1) + @DisplayName("CreateDBCluster returns valid cluster descriptor") + void createCluster() { + var response = neptune.createDBCluster(CreateDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .engine("neptune") + .build()); + + var cluster = response.dbCluster(); + assertThat(cluster.dbClusterIdentifier()).isEqualTo(CLUSTER_ID); + assertThat(cluster.engine()).isEqualTo("neptune"); + assertThat(cluster.status()).isEqualTo("available"); + assertThat(cluster.dbClusterArn()).startsWith("arn:aws:neptune:"); + assertThat(cluster.port()).isGreaterThan(0); + } + + @Test + @Order(2) + @DisplayName("CreateDBCluster fails with DBClusterAlreadyExistsFault on duplicate") + void createClusterDuplicate() { + assertThatThrownBy(() -> + neptune.createDBCluster(CreateDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .engine("neptune") + .build())) + .hasMessageContaining("already exists"); + } + + @Test + @Order(3) + @DisplayName("DescribeDBClusters returns created cluster") + void describeClusters() { + var response = neptune.describeDBClusters(DescribeDbClustersRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .build()); + + assertThat(response.dbClusters()).hasSize(1); + assertThat(response.dbClusters().get(0).dbClusterIdentifier()).isEqualTo(CLUSTER_ID); + } + + @Test + @Order(4) + @DisplayName("ModifyDBCluster updates IAM auth flag") + void modifyCluster() { + var response = neptune.modifyDBCluster(ModifyDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .enableIAMDatabaseAuthentication(true) + .build()); + + assertThat(response.dbCluster().iamDatabaseAuthenticationEnabled()).isTrue(); + } + + @Test + @Order(5) + @DisplayName("CreateDBInstance returns valid instance descriptor") + void createInstance() { + var response = neptune.createDBInstance(CreateDbInstanceRequest.builder() + .dbInstanceIdentifier(INSTANCE_ID) + .dbClusterIdentifier(CLUSTER_ID) + .dbInstanceClass("db.r5.large") + .engine("neptune") + .build()); + + var instance = response.dbInstance(); + assertThat(instance.dbInstanceIdentifier()).isEqualTo(INSTANCE_ID); + assertThat(instance.dbClusterIdentifier()).isEqualTo(CLUSTER_ID); + assertThat(instance.dbInstanceStatus()).isEqualTo("available"); + assertThat(instance.dbInstanceArn()).startsWith("arn:aws:neptune:"); + } + + @Test + @Order(6) + @DisplayName("DescribeDBInstances returns created instance") + void describeInstances() { + var response = neptune.describeDBInstances(DescribeDbInstancesRequest.builder() + .dbInstanceIdentifier(INSTANCE_ID) + .build()); + + assertThat(response.dbInstances()).hasSize(1); + assertThat(response.dbInstances().get(0).dbInstanceIdentifier()).isEqualTo(INSTANCE_ID); + } + + @Test + @Order(7) + @DisplayName("ModifyDBInstance updates instance class") + void modifyInstance() { + var response = neptune.modifyDBInstance(ModifyDbInstanceRequest.builder() + .dbInstanceIdentifier(INSTANCE_ID) + .dbInstanceClass("db.r5.xlarge") + .build()); + + assertThat(response.dbInstance().dbInstanceClass()).isEqualTo("db.r5.xlarge"); + } + + @Test + @Order(8) + @DisplayName("DeleteDBCluster fails when instances still exist") + void deleteClusterWithInstancesFails() { + assertThatThrownBy(() -> + neptune.deleteDBCluster(DeleteDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .skipFinalSnapshot(true) + .build())) + .isInstanceOf(InvalidDbClusterStateException.class); + } + + @Test + @Order(9) + @DisplayName("DeleteDBInstance removes instance") + void deleteInstance() { + neptune.deleteDBInstance(DeleteDbInstanceRequest.builder() + .dbInstanceIdentifier(INSTANCE_ID) + .build()); + } + + @Test + @Order(10) + @DisplayName("DeleteDBCluster removes cluster after instances are gone") + void deleteCluster() { + neptune.deleteDBCluster(DeleteDbClusterRequest.builder() + .dbClusterIdentifier(CLUSTER_ID) + .skipFinalSnapshot(true) + .build()); + } +} diff --git a/compatibility-tests/sdk-test-node/package.json b/compatibility-tests/sdk-test-node/package.json index 2af4f30cab..abfa750b34 100644 --- a/compatibility-tests/sdk-test-node/package.json +++ b/compatibility-tests/sdk-test-node/package.json @@ -26,6 +26,7 @@ "@aws-sdk/client-sns": "^3.500.0", "@aws-sdk/client-sqs": "^3.500.0", "@aws-sdk/client-ssm": "^3.500.0", + "@aws-sdk/client-neptune": "^3.500.0", "@aws-sdk/client-sts": "^3.500.0", "selfsigned": "^5.5.0", "ws": "^8.0.0" diff --git a/compatibility-tests/sdk-test-node/tests/neptune.test.ts b/compatibility-tests/sdk-test-node/tests/neptune.test.ts new file mode 100644 index 0000000000..1837b7f2e4 --- /dev/null +++ b/compatibility-tests/sdk-test-node/tests/neptune.test.ts @@ -0,0 +1,180 @@ +/** + * Neptune cluster and instance integration tests. + */ + +import { describe, it, expect, afterEach } from 'vitest'; +import { + NeptuneClient, + CreateDBClusterCommand, + DescribeDBClustersCommand, + ModifyDBClusterCommand, + DeleteDBClusterCommand, + CreateDBInstanceCommand, + DescribeDBInstancesCommand, + ModifyDBInstanceCommand, + DeleteDBInstanceCommand, +} from '@aws-sdk/client-neptune'; +import { makeClient, uniqueName } from './setup'; + +const neptune = makeClient(NeptuneClient); + +async function deleteCluster(id: string) { + try { + await neptune.send(new DeleteDBClusterCommand({ DBClusterIdentifier: id, SkipFinalSnapshot: true })); + } catch { /* ignore */ } +} + +async function deleteInstance(id: string) { + try { + await neptune.send(new DeleteDBInstanceCommand({ DBInstanceIdentifier: id })); + } catch { /* ignore */ } +} + +describe('Neptune Clusters', () => { + it('should create a cluster', async () => { + const clusterId = `node-${uniqueName()}`; + + try { + const response = await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + const cluster = response.DBCluster!; + expect(cluster.DBClusterIdentifier).toBe(clusterId); + expect(cluster.Engine).toBe('neptune'); + expect(cluster.Status).toBe('available'); + expect(cluster.DBClusterArn).toMatch(/^arn:aws:neptune:/); + expect(cluster.Port).toBeGreaterThan(0); + } finally { + await deleteCluster(clusterId); + } + }); + + it('should fail on duplicate cluster creation', async () => { + const clusterId = `node-${uniqueName()}`; + + await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + + try { + await expect( + neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })) + ).rejects.toMatchObject({ + name: 'DBClusterAlreadyExistsFault', + }); + } finally { + await deleteCluster(clusterId); + } + }); + + it('should describe cluster by ID', async () => { + const clusterId = `node-${uniqueName()}`; + + await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + + try { + const response = await neptune.send(new DescribeDBClustersCommand({ + DBClusterIdentifier: clusterId, + })); + expect(response.DBClusters).toHaveLength(1); + expect(response.DBClusters![0].DBClusterIdentifier).toBe(clusterId); + } finally { + await deleteCluster(clusterId); + } + }); + + it('should modify cluster IAM auth', async () => { + const clusterId = `node-${uniqueName()}`; + + await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + + try { + const response = await neptune.send(new ModifyDBClusterCommand({ + DBClusterIdentifier: clusterId, + EnableIAMDatabaseAuthentication: true, + })); + expect(response.DBCluster!.IAMDatabaseAuthenticationEnabled).toBe(true); + } finally { + await deleteCluster(clusterId); + } + }); +}); + +describe('Neptune Instances', () => { + let clusterId: string; + + afterEach(async () => { + if (clusterId) { + await deleteCluster(clusterId); + clusterId = ''; + } + }); + + it('should create and describe an instance', async () => { + clusterId = `node-cl-${uniqueName()}`; + const instanceId = `node-inst-${uniqueName()}`; + + await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + + try { + const createResp = await neptune.send(new CreateDBInstanceCommand({ + DBInstanceIdentifier: instanceId, + DBClusterIdentifier: clusterId, + DBInstanceClass: 'db.r5.large', + Engine: 'neptune', + })); + const instance = createResp.DBInstance!; + expect(instance.DBInstanceIdentifier).toBe(instanceId); + expect(instance.DBClusterIdentifier).toBe(clusterId); + expect(instance.DBInstanceStatus).toBe('available'); + + const descResp = await neptune.send(new DescribeDBInstancesCommand({ + DBInstanceIdentifier: instanceId, + })); + expect(descResp.DBInstances).toHaveLength(1); + } finally { + await deleteInstance(instanceId); + } + }); + + it('should modify instance class', async () => { + clusterId = `node-cl-${uniqueName()}`; + const instanceId = `node-inst-${uniqueName()}`; + + await neptune.send(new CreateDBClusterCommand({ + DBClusterIdentifier: clusterId, + Engine: 'neptune', + })); + + try { + await neptune.send(new CreateDBInstanceCommand({ + DBInstanceIdentifier: instanceId, + DBClusterIdentifier: clusterId, + DBInstanceClass: 'db.r5.large', + Engine: 'neptune', + })); + + const response = await neptune.send(new ModifyDBInstanceCommand({ + DBInstanceIdentifier: instanceId, + DBInstanceClass: 'db.r5.xlarge', + })); + expect(response.DBInstance!.DBInstanceClass).toBe('db.r5.xlarge'); + } finally { + await deleteInstance(instanceId); + } + }); +}); diff --git a/compatibility-tests/sdk-test-python/conftest.py b/compatibility-tests/sdk-test-python/conftest.py index d06a5dc33f..e800974efc 100644 --- a/compatibility-tests/sdk-test-python/conftest.py +++ b/compatibility-tests/sdk-test-python/conftest.py @@ -145,6 +145,12 @@ def ecr_client(aws_config, client_config): return boto3.client("ecr", config=client_config, **aws_config) +@pytest.fixture +def neptune_client(aws_config, client_config): + """Create Neptune client.""" + return boto3.client("neptune", config=client_config, **aws_config) + + @pytest.fixture def pipes_client(aws_config, client_config): """Create EventBridge Pipes client.""" diff --git a/compatibility-tests/sdk-test-python/tests/test_neptune.py b/compatibility-tests/sdk-test-python/tests/test_neptune.py new file mode 100644 index 0000000000..575bb8a460 --- /dev/null +++ b/compatibility-tests/sdk-test-python/tests/test_neptune.py @@ -0,0 +1,186 @@ +"""Neptune cluster and instance integration tests.""" + +import pytest +from botocore.exceptions import ClientError + + +class TestNeptuneCluster: + """Test Neptune DB cluster operations.""" + + def test_create_cluster(self, neptune_client, unique_name): + """Test CreateDBCluster returns a valid cluster descriptor.""" + cluster_id = f"pytest-{unique_name}" + + try: + response = neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, + Engine="neptune", + ) + cluster = response["DBCluster"] + assert cluster["DBClusterIdentifier"] == cluster_id + assert cluster["Engine"] == "neptune" + assert cluster["Status"] == "available" + assert cluster["DBClusterArn"].startswith("arn:aws:neptune:") + assert cluster["Port"] > 0 + finally: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + + def test_create_cluster_duplicate_fails(self, neptune_client, unique_name): + """Test CreateDBCluster fails with DBClusterAlreadyExistsFault on duplicate.""" + cluster_id = f"pytest-{unique_name}" + + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + try: + with pytest.raises(ClientError) as exc_info: + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + assert exc_info.value.response["Error"]["Code"] == "DBClusterAlreadyExistsFault" + finally: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + + def test_describe_clusters(self, neptune_client, unique_name): + """Test DescribeDBClusters lists created cluster.""" + cluster_id = f"pytest-{unique_name}" + + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + try: + response = neptune_client.describe_db_clusters( + DBClusterIdentifier=cluster_id + ) + clusters = response["DBClusters"] + assert len(clusters) == 1 + assert clusters[0]["DBClusterIdentifier"] == cluster_id + finally: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + + def test_modify_cluster(self, neptune_client, unique_name): + """Test ModifyDBCluster updates cluster properties.""" + cluster_id = f"pytest-{unique_name}" + + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + try: + response = neptune_client.modify_db_cluster( + DBClusterIdentifier=cluster_id, + EnableIAMDatabaseAuthentication=True, + ) + assert response["DBCluster"]["IAMDatabaseAuthenticationEnabled"] is True + finally: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + + def test_delete_cluster_with_instances_fails(self, neptune_client, unique_name): + """Test DeleteDBCluster fails when instances still exist.""" + cluster_id = f"pytest-{unique_name}" + instance_id = f"pytest-inst-{unique_name}" + + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + neptune_client.create_db_instance( + DBInstanceIdentifier=instance_id, + DBClusterIdentifier=cluster_id, + DBInstanceClass="db.r5.large", + Engine="neptune", + ) + try: + with pytest.raises(ClientError) as exc_info: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + assert exc_info.value.response["Error"]["Code"] == "InvalidDBClusterStateFault" + finally: + neptune_client.delete_db_instance(DBInstanceIdentifier=instance_id) + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + + +class TestNeptuneInstance: + """Test Neptune DB instance operations.""" + + @pytest.fixture + def neptune_cluster(self, neptune_client, unique_name): + """Create and tear down a Neptune cluster for instance tests.""" + cluster_id = f"pytest-cluster-{unique_name}" + neptune_client.create_db_cluster( + DBClusterIdentifier=cluster_id, Engine="neptune" + ) + yield cluster_id + try: + neptune_client.delete_db_cluster( + DBClusterIdentifier=cluster_id, SkipFinalSnapshot=True + ) + except ClientError: + pass + + def test_create_instance(self, neptune_client, neptune_cluster, unique_name): + """Test CreateDBInstance returns a valid instance descriptor.""" + instance_id = f"pytest-inst-{unique_name}" + + try: + response = neptune_client.create_db_instance( + DBInstanceIdentifier=instance_id, + DBClusterIdentifier=neptune_cluster, + DBInstanceClass="db.r5.large", + Engine="neptune", + ) + instance = response["DBInstance"] + assert instance["DBInstanceIdentifier"] == instance_id + assert instance["DBClusterIdentifier"] == neptune_cluster + assert instance["DBInstanceStatus"] == "available" + assert instance["DBInstanceArn"].startswith("arn:aws:neptune:") + finally: + neptune_client.delete_db_instance(DBInstanceIdentifier=instance_id) + + def test_describe_instances(self, neptune_client, neptune_cluster, unique_name): + """Test DescribeDBInstances lists created instance.""" + instance_id = f"pytest-inst-{unique_name}" + + neptune_client.create_db_instance( + DBInstanceIdentifier=instance_id, + DBClusterIdentifier=neptune_cluster, + DBInstanceClass="db.r5.large", + Engine="neptune", + ) + try: + response = neptune_client.describe_db_instances( + DBInstanceIdentifier=instance_id + ) + instances = response["DBInstances"] + assert len(instances) == 1 + assert instances[0]["DBInstanceIdentifier"] == instance_id + finally: + neptune_client.delete_db_instance(DBInstanceIdentifier=instance_id) + + def test_modify_instance(self, neptune_client, neptune_cluster, unique_name): + """Test ModifyDBInstance updates instance class.""" + instance_id = f"pytest-inst-{unique_name}" + + neptune_client.create_db_instance( + DBInstanceIdentifier=instance_id, + DBClusterIdentifier=neptune_cluster, + DBInstanceClass="db.r5.large", + Engine="neptune", + ) + try: + response = neptune_client.modify_db_instance( + DBInstanceIdentifier=instance_id, + DBInstanceClass="db.r5.xlarge", + ) + assert response["DBInstance"]["DBInstanceClass"] == "db.r5.xlarge" + finally: + neptune_client.delete_db_instance(DBInstanceIdentifier=instance_id) diff --git a/compatibility-tests/sdk-test-rust/Cargo.toml b/compatibility-tests/sdk-test-rust/Cargo.toml index 015b9962e6..df40b544eb 100644 --- a/compatibility-tests/sdk-test-rust/Cargo.toml +++ b/compatibility-tests/sdk-test-rust/Cargo.toml @@ -22,6 +22,7 @@ aws-sdk-secretsmanager = "1" aws-sdk-kms = "1" aws-sdk-kinesis = "1" aws-sdk-lambda = "1" +aws-sdk-neptune = "1" aws-sdk-pipes = "1" aws-sdk-cloudwatch = "1" aws-sdk-cognitoidentityprovider = "1" diff --git a/compatibility-tests/sdk-test-rust/src/lib.rs b/compatibility-tests/sdk-test-rust/src/lib.rs index f2ceed2af7..1b06c79684 100644 --- a/compatibility-tests/sdk-test-rust/src/lib.rs +++ b/compatibility-tests/sdk-test-rust/src/lib.rs @@ -104,6 +104,11 @@ pub async fn pipes_client() -> aws_sdk_pipes::Client { aws_sdk_pipes::Client::new(&base_config().await) } +/// Returns a Neptune client. +pub async fn neptune_client() -> aws_sdk_neptune::Client { + aws_sdk_neptune::Client::new(&base_config().await) +} + /// Returns a minimal Lambda deployment zip with a Node.js handler. pub fn minimal_zip() -> Vec { use std::io::Write; diff --git a/compatibility-tests/sdk-test-rust/tests/neptune_test.rs b/compatibility-tests/sdk-test-rust/tests/neptune_test.rs new file mode 100644 index 0000000000..c95cc884f9 --- /dev/null +++ b/compatibility-tests/sdk-test-rust/tests/neptune_test.rs @@ -0,0 +1,169 @@ +mod common; + +#[tokio::test(flavor = "multi_thread")] +async fn test_neptune_create_cluster() { + let neptune = common::neptune_client().await; + let cluster_id = "rust-neptune-create-cluster"; + + let result = neptune + .create_db_cluster() + .db_cluster_identifier(cluster_id) + .engine("neptune") + .send() + .await; + assert!(result.is_ok(), "CreateDBCluster failed: {:?}", result.err()); + + let cluster = result.unwrap().db_cluster.unwrap(); + assert_eq!(cluster.db_cluster_identifier().unwrap_or(""), cluster_id); + assert_eq!(cluster.engine().unwrap_or(""), "neptune"); + assert_eq!(cluster.status().unwrap_or(""), "available"); + assert!(cluster.db_cluster_arn().unwrap_or("").starts_with("arn:aws:neptune:")); + + let _guard = common::CleanupGuard::new({ + let neptune = neptune.clone(); + async move { + let _ = neptune + .delete_db_cluster() + .db_cluster_identifier(cluster_id) + .skip_final_snapshot(true) + .send() + .await; + } + }); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_neptune_describe_cluster() { + let neptune = common::neptune_client().await; + let cluster_id = "rust-neptune-describe-cluster"; + + neptune + .create_db_cluster() + .db_cluster_identifier(cluster_id) + .engine("neptune") + .send() + .await + .expect("setup: create cluster"); + + let _guard = common::CleanupGuard::new({ + let neptune = neptune.clone(); + async move { + let _ = neptune + .delete_db_cluster() + .db_cluster_identifier(cluster_id) + .skip_final_snapshot(true) + .send() + .await; + } + }); + + let result = neptune + .describe_db_clusters() + .db_cluster_identifier(cluster_id) + .send() + .await; + assert!(result.is_ok(), "DescribeDBClusters failed: {:?}", result.err()); + + let clusters = result.unwrap().db_clusters; + assert_eq!(clusters.len(), 1); + assert_eq!(clusters[0].db_cluster_identifier().unwrap_or(""), cluster_id); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_neptune_modify_cluster() { + let neptune = common::neptune_client().await; + let cluster_id = "rust-neptune-modify-cluster"; + + neptune + .create_db_cluster() + .db_cluster_identifier(cluster_id) + .engine("neptune") + .send() + .await + .expect("setup: create cluster"); + + let _guard = common::CleanupGuard::new({ + let neptune = neptune.clone(); + async move { + let _ = neptune + .delete_db_cluster() + .db_cluster_identifier(cluster_id) + .skip_final_snapshot(true) + .send() + .await; + } + }); + + let result = neptune + .modify_db_cluster() + .db_cluster_identifier(cluster_id) + .enable_iam_database_authentication(true) + .send() + .await; + assert!(result.is_ok(), "ModifyDBCluster failed: {:?}", result.err()); + + let cluster = result.unwrap().db_cluster.unwrap(); + assert!(cluster.iam_database_authentication_enabled()); +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_neptune_create_and_describe_instance() { + let neptune = common::neptune_client().await; + let cluster_id = "rust-neptune-instance-cluster"; + let instance_id = "rust-neptune-instance"; + + neptune + .create_db_cluster() + .db_cluster_identifier(cluster_id) + .engine("neptune") + .send() + .await + .expect("setup: create cluster"); + + let _cluster_guard = common::CleanupGuard::new({ + let neptune = neptune.clone(); + async move { + let _ = neptune + .delete_db_cluster() + .db_cluster_identifier(cluster_id) + .skip_final_snapshot(true) + .send() + .await; + } + }); + + let create = neptune + .create_db_instance() + .db_instance_identifier(instance_id) + .db_cluster_identifier(cluster_id) + .db_instance_class("db.r5.large") + .engine("neptune") + .send() + .await; + assert!(create.is_ok(), "CreateDBInstance failed: {:?}", create.err()); + + let instance = create.unwrap().db_instance.unwrap(); + assert_eq!(instance.db_instance_identifier().unwrap_or(""), instance_id); + assert_eq!(instance.db_cluster_identifier().unwrap_or(""), cluster_id); + assert_eq!(instance.db_instance_status().unwrap_or(""), "available"); + + let _inst_guard = common::CleanupGuard::new({ + let neptune = neptune.clone(); + async move { + let _ = neptune + .delete_db_instance() + .db_instance_identifier(instance_id) + .send() + .await; + } + }); + + let describe = neptune + .describe_db_instances() + .db_instance_identifier(instance_id) + .send() + .await; + assert!(describe.is_ok(), "DescribeDBInstances failed: {:?}", describe.err()); + assert_eq!(describe.unwrap().db_instances.len(), 1); +} +