mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 07:11:11 -05:00
* feat(neptune): support the Terraform aws_neptune_cluster read-back contract The Terraform AWS provider's aws_neptune_cluster resource reads back every DBCluster field after create and update, and treats a mismatch on a ForceNew attribute as a replacement. Against Floci the resource could not converge: StorageEncrypted was hardcoded to true against the provider's default of false, AvailabilityZones was emitted as a singular element that SDK parsers drop, BackupRetentionPeriod and the other settings were never stored, and tag calls on a Neptune ARN never reached the Neptune store. CreateDBCluster and ModifyDBCluster now store the settings a request carries (NeptuneClusterSettings, modelled on DocDbClusterSettings) and DescribeDBClusters reads them back with the AWS defaults otherwise: AvailabilityZones, BackupRetentionPeriod, PreferredBackupWindow, PreferredMaintenanceWindow, DBSubnetGroup, DBClusterParameterGroup, VpcSecurityGroups, StorageEncrypted, KmsKeyId, StorageType, DeletionProtection, CopyTagsToSnapshot, EnabledCloudwatchLogsExports, ReplicationSourceIdentifier, ServerlessV2ScalingConfiguration, AssociatedRoles and ClusterCreateTime. StorageEncrypted defaults to false as on AWS. Also: - A requested Port is honoured when it is free inside the proxy range, so Terraform's default port of 8182 matches the first cluster. - DeleteDBCluster refuses a cluster with DeletionProtection enabled with InvalidParameterCombination, as on AWS. - DBClusterMembers uses the DBClusterMember element the Neptune API model declares; the previous member element was dropped by SDK parsers. - New actions: AddRoleToDBCluster, RemoveRoleFromDBCluster, DescribeGlobalClusters (empty list), ListTagsForResource, AddTagsToResource and RemoveTagsFromResource. Tags are accepted on CreateDBCluster and CreateDBInstance, and the rds credential scope routes a Neptune ARN ResourceName to the Neptune handler. Verified against hashicorp/aws 6.62.0 with terraform apply, a clean re-plan, an update covering retention, protection, log exports, security groups, iam_roles and tags, a destroy blocked by deletion protection, and a destroy after disabling it. * test(compat): cover aws_neptune_cluster in the Terraform and Java SDK suites Adds a dedicated Terraform fixture and bats test that applies an aws_neptune_cluster, checks the read-back through terraform output and the AWS CLI, checks tags through ListTagsForResource, and asserts a clean re-plan. Extends the Java SDK NeptuneTest with tags, IAM roles, modify settings, deletion protection and cluster members, so a real SDK parser covers the new DBCluster fields. * fix(neptune): infer the rds service for the DBCluster role actions Unsigned Query requests resolve their service from the action name, and AddRoleToDBCluster and RemoveRoleFromDBCluster were missing from the RDS action set, so they fell through to the SQS default instead of reaching the Neptune handler. * feat(neptune): read back the settings Terraform's aws_neptune_cluster_instance manages DescribeDBInstances omitted AutoMinorVersionUpgrade, PromotionTier, PubliclyAccessible, the parameter and subnet groups and the windows, ModifyDBInstance ignored them, StorageEncrypted was hardcoded to true, and every cluster member was reported as the writer, so the provider issued a ModifyDBInstance on every apply. NeptuneInstanceSettings, modelled on NeptuneClusterSettings, stores what a request carries and DescribeDBInstances reads it back with the AWS defaults otherwise; StorageEncrypted, KmsKeyId and StorageType are the cluster's. The first member of a cluster is its writer and deleting it promotes the next. Covered by unit, integration and Java SDK tests and a Terraform compat fixture with a writer and a reader instance. --------- Co-authored-by: kurtmc <2661907+kurtmc@users.noreply.github.com>
116 lines
4.6 KiB
Bash
116 lines
4.6 KiB
Bash
#!/usr/bin/env bats
|
|
# Neptune Cluster Instance Compatibility Test
|
|
|
|
setup_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
NEPTUNE_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/neptune-cluster-instance-tf" && pwd)"
|
|
cd "$NEPTUNE_TF_DIR"
|
|
|
|
echo "# === Neptune Cluster Instance Test ===" >&3
|
|
echo "# Endpoint: $FLOCI_ENDPOINT" >&3
|
|
echo "# Config: $NEPTUNE_TF_DIR" >&3
|
|
|
|
rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true
|
|
|
|
echo "# --- terraform init ---" >&3
|
|
run terraform init -input=false -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform init failed: $output" >&3
|
|
return 1
|
|
fi
|
|
|
|
echo "# --- terraform apply ---" >&3
|
|
run terraform apply -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color
|
|
if [ "$status" -ne 0 ]; then
|
|
echo "# terraform apply failed: $output" >&3
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
teardown_file() {
|
|
load 'test_helper/common-setup'
|
|
|
|
NEPTUNE_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/neptune-cluster-instance-tf" && pwd)"
|
|
cd "$NEPTUNE_TF_DIR"
|
|
|
|
terraform destroy -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color || true
|
|
rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true
|
|
}
|
|
|
|
setup() {
|
|
load 'test_helper/common-setup'
|
|
NEPTUNE_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/neptune-cluster-instance-tf" && pwd)"
|
|
}
|
|
|
|
@test "Neptune cluster instance: terraform reads back the attributes it manages" {
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_is_writer
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw reader_is_writer
|
|
assert_success
|
|
assert_output "false"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_storage_encrypted
|
|
assert_success
|
|
assert_output "false"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_parameter_group_name
|
|
assert_success
|
|
assert_output "default.neptune1.3"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_port
|
|
assert_success
|
|
assert_output "8183"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_auto_minor_version_upgrade
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw reader_promotion_tier
|
|
assert_success
|
|
assert_output "2"
|
|
|
|
run terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_endpoint
|
|
assert_success
|
|
assert_output --partial ":8183"
|
|
}
|
|
|
|
@test "Neptune cluster instance: describe reports the configured settings" {
|
|
run aws_cmd neptune describe-db-instances --db-instance-identifier floci-tf-neptune-reader
|
|
assert_success
|
|
[ "$(json_get "$output" '.DBInstances[0].DBClusterIdentifier')" = "floci-tf-neptune-instances" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].DBInstanceClass')" = "db.r5.large" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].DBInstanceStatus')" = "available" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].Endpoint.Port')" = "8183" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].PromotionTier')" = "2" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].AutoMinorVersionUpgrade')" = "false" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].PubliclyAccessible')" = "false" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].StorageEncrypted')" = "false" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].DBSubnetGroup.DBSubnetGroupName')" = "default" ]
|
|
[ "$(json_get "$output" '.DBInstances[0].DBParameterGroups[0].DBParameterGroupName')" = "default.neptune1.3" ]
|
|
}
|
|
|
|
@test "Neptune cluster instance: tags round-trip through ListTagsForResource" {
|
|
arn=$(terraform -chdir="$NEPTUNE_TF_DIR" output -raw writer_arn)
|
|
run aws_cmd neptune list-tags-for-resource --resource-name "$arn"
|
|
assert_success
|
|
[ "$(json_get "$output" '.TagList[] | select(.Key == "Name") | .Value')" = "floci-tf-neptune-writer" ]
|
|
}
|
|
|
|
@test "Neptune cluster instance: the cluster reports exactly one writer" {
|
|
run aws_cmd neptune describe-db-clusters --db-cluster-identifier floci-tf-neptune-instances
|
|
assert_success
|
|
[ "$(json_get "$output" '.DBClusters[0].DBClusterMembers | length')" = "2" ]
|
|
[ "$(json_get "$output" '[.DBClusters[0].DBClusterMembers[] | select(.IsClusterWriter)] | length')" = "1" ]
|
|
[ "$(json_get "$output" '.DBClusters[0].DBClusterMembers[] | select(.IsClusterWriter) | .DBInstanceIdentifier')" = "floci-tf-neptune-writer" ]
|
|
}
|
|
|
|
@test "Neptune cluster instance: re-plan after apply is clean" {
|
|
cd "$NEPTUNE_TF_DIR"
|
|
run terraform plan -var="endpoint=${FLOCI_ENDPOINT}" -input=false -no-color -detailed-exitcode
|
|
assert_success
|
|
assert_output --partial "No changes"
|
|
}
|