Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Aug 9, 2023
1 parent 29d5821 commit 08fde9b
Show file tree
Hide file tree
Showing 3 changed files with 377 additions and 188 deletions.
173 changes: 173 additions & 0 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,176 @@ func validateAPITest(isValid func(body string)) func(t *testing.T, stack integra
isValid(string(body))
}
}

func init() {
// This is necessary for gRPC testing. It doesn't effect integration tests, since
// they use their own binary.
version.Version = "6.0.0"
}

func replay(t *testing.T, sequence string) {
info := *aws.Provider()
ctx := context.Background()
p, err := pfbridge.MakeMuxedServer(ctx, info.Name, info,
/*
* We leave the schema blank. This will result in incorrect calls to
* GetSchema, but otherwise does not effect the provider. It reduces the
* time to test start by minutes.
*/
[]byte("{}"),
)(nil)
require.NoError(t, err)
testutils.ReplaySequence(t, p, sequence)
}

// This replicates the diff when running `pulumi preview` on a aws.rds.Instance with
// pulumi-aws v6.0.0 and state from pulumi-aws 5.42.0.
//
// This ensures we don't regress on https://github.com/pulumi/pulumi-aws/issues/2682
func TestMigrateRdsInstance(t *testing.T) {
replay(t, `[
{
"method": "/pulumirpc.ResourceProvider/Diff",
"request": {
"id": "postgresdb8a8a6f1",
"urn": "urn:pulumi:dev::ts::aws:rds/instance:Instance::postgresdb",
"olds": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}",
"address": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com",
"allocatedStorage": 30,
"applyImmediately": false,
"arn": "arn:aws:rds:us-west-2:616138583583:db:postgresdb8a8a6f1",
"autoMinorVersionUpgrade": true,
"availabilityZone": "us-west-2d",
"backupRetentionPeriod": 0,
"backupWindow": "06:15-06:45",
"caCertIdentifier": "rds-ca-2019",
"characterSetName": "",
"copyTagsToSnapshot": false,
"customIamInstanceProfile": "",
"customerOwnedIpEnabled": false,
"dbName": "airflow",
"dbSubnetGroupName": "default",
"deleteAutomatedBackups": true,
"deletionProtection": false,
"domain": "",
"domainIamRoleName": "",
"enabledCloudwatchLogsExports": [],
"endpoint": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com:5432",
"engine": "postgres",
"engineVersion": "15.3",
"engineVersionActual": "15.3",
"hostedZoneId": "Z1PVIF0B656C1W",
"iamDatabaseAuthenticationEnabled": false,
"id": "postgresdb8a8a6f1",
"identifier": "postgresdb8a8a6f1",
"identifierPrefix": "",
"instanceClass": "db.t4g.micro",
"iops": 0,
"kmsKeyId": "",
"latestRestorableTime": "",
"licenseModel": "postgresql-license",
"listenerEndpoints": [],
"maintenanceWindow": "sun:07:16-sun:07:46",
"masterUserSecrets": [],
"maxAllocatedStorage": 0,
"monitoringInterval": 0,
"monitoringRoleArn": "",
"multiAz": false,
"name": "airflow",
"ncharCharacterSetName": "",
"networkType": "IPV4",
"optionGroupName": "default:postgres-15",
"parameterGroupName": "default.postgres15",
"password": "tuFp574p9Arw58gu",
"performanceInsightsEnabled": false,
"performanceInsightsKmsKeyId": "",
"performanceInsightsRetentionPeriod": 0,
"port": 5432,
"publiclyAccessible": false,
"replicaMode": "",
"replicas": [],
"replicateSourceDb": "",
"resourceId": "db-DUPUZANEFBXYECMTI2B5RZPTOE",
"securityGroupNames": [],
"skipFinalSnapshot": true,
"status": "available",
"storageEncrypted": false,
"storageThroughput": 0,
"storageType": "gp2",
"tags": {},
"tagsAll": {},
"timezone": "",
"username": "airflow",
"vpcSecurityGroupIds": [
"sg-4d436f12"
]
},
"news": {
"__defaults": [
"applyImmediately",
"autoMinorVersionUpgrade",
"copyTagsToSnapshot",
"deleteAutomatedBackups",
"identifier",
"monitoringInterval",
"performanceInsightsEnabled",
"publiclyAccessible"
],
"allocatedStorage": 30,
"applyImmediately": false,
"autoMinorVersionUpgrade": true,
"copyTagsToSnapshot": false,
"deleteAutomatedBackups": true,
"engine": "postgres",
"identifier": "postgresdb8a8a6f1",
"instanceClass": "db.t4g.micro",
"monitoringInterval": 0,
"dbName": "airflow",
"password": "tuFp574p9Arw58gu",
"performanceInsightsEnabled": false,
"publiclyAccessible": false,
"skipFinalSnapshot": true,
"username": "airflow"
},
"oldInputs": {
"__defaults": [
"applyImmediately",
"autoMinorVersionUpgrade",
"copyTagsToSnapshot",
"deleteAutomatedBackups",
"identifier",
"monitoringInterval",
"performanceInsightsEnabled",
"publiclyAccessible"
],
"allocatedStorage": 30,
"applyImmediately": false,
"autoMinorVersionUpgrade": true,
"copyTagsToSnapshot": false,
"deleteAutomatedBackups": true,
"engine": "postgres",
"identifier": "postgresdb8a8a6f1",
"instanceClass": "db.t4g.micro",
"monitoringInterval": 0,
"name": "airflow",
"password": "tuFp574p9Arw58gu",
"performanceInsightsEnabled": false,
"publiclyAccessible": false,
"skipFinalSnapshot": true,
"username": "airflow"
}
},
"response": {
"stables": "*",
"changes": "DIFF_NONE",
"hasDetailedDiff": true
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "aws"
}
}
]`)
}
133 changes: 68 additions & 65 deletions provider/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ replace (

require (
github.com/pulumi/pulumi-aws/provider/v6 v6.0.0-00010101000000-000000000000
github.com/pulumi/pulumi-terraform-bridge/pf v0.14.2-0.20230801203955-5d215c892096
github.com/pulumi/pulumi-terraform-bridge/pf v0.15.2
github.com/pulumi/pulumi-terraform-bridge/testing v0.0.1
github.com/stretchr/testify v1.8.4
)
Expand All @@ -25,73 +25,76 @@ require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go v1.44.304 // indirect
github.com/aws/aws-sdk-go-v2 v1.19.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go v1.44.315 // indirect
github.com/aws/aws-sdk-go-v2 v1.20.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.11 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.28 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.31 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 // indirect
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.19.15 // indirect
github.com/aws/aws-sdk-go-v2/service/account v1.10.9 // indirect
github.com/aws/aws-sdk-go-v2/service/acm v1.17.14 // indirect
github.com/aws/aws-sdk-go-v2/service/appconfig v1.17.12 // indirect
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.25.1 // indirect
github.com/aws/aws-sdk-go-v2/service/cleanrooms v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.11.15 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.22.1 // indirect
github.com/aws/aws-sdk-go-v2/service/comprehend v1.24.5 // indirect
github.com/aws/aws-sdk-go-v2/service/computeoptimizer v1.24.3 // indirect
github.com/aws/aws-sdk-go-v2/service/directoryservice v1.17.4 // indirect
github.com/aws/aws-sdk-go-v2/service/docdbelastic v1.1.13 // indirect
github.com/aws/aws-sdk-go-v2/service/ec2 v1.105.1 // indirect
github.com/aws/aws-sdk-go-v2/service/finspace v1.10.3 // indirect
github.com/aws/aws-sdk-go-v2/service/fis v1.14.13 // indirect
github.com/aws/aws-sdk-go-v2/service/glacier v1.14.14 // indirect
github.com/aws/aws-sdk-go-v2/service/healthlake v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.20.0 // indirect
github.com/aws/aws-sdk-go-v2/service/account v1.11.0 // indirect
github.com/aws/aws-sdk-go-v2/service/acm v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/service/appconfig v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.26.0 // indirect
github.com/aws/aws-sdk-go-v2/service/cleanrooms v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.23.0 // indirect
github.com/aws/aws-sdk-go-v2/service/comprehend v1.25.0 // indirect
github.com/aws/aws-sdk-go-v2/service/computeoptimizer v1.25.0 // indirect
github.com/aws/aws-sdk-go-v2/service/directoryservice v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/service/docdbelastic v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ec2 v1.109.0 // indirect
github.com/aws/aws-sdk-go-v2/service/emrserverless v1.10.0 // indirect
github.com/aws/aws-sdk-go-v2/service/finspace v1.11.0 // indirect
github.com/aws/aws-sdk-go-v2/service/fis v1.15.0 // indirect
github.com/aws/aws-sdk-go-v2/service/glacier v1.15.0 // indirect
github.com/aws/aws-sdk-go-v2/service/healthlake v1.17.0 // indirect
github.com/aws/aws-sdk-go-v2/service/iam v1.21.1 // indirect
github.com/aws/aws-sdk-go-v2/service/identitystore v1.16.14 // indirect
github.com/aws/aws-sdk-go-v2/service/inspector2 v1.15.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internetmonitor v1.3.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ivschat v1.4.8 // indirect
github.com/aws/aws-sdk-go-v2/service/kendra v1.41.1 // indirect
github.com/aws/aws-sdk-go-v2/service/keyspaces v1.3.3 // indirect
github.com/aws/aws-sdk-go-v2/service/lambda v1.37.1 // indirect
github.com/aws/aws-sdk-go-v2/service/lightsail v1.27.2 // indirect
github.com/aws/aws-sdk-go-v2/service/medialive v1.32.1 // indirect
github.com/aws/aws-sdk-go-v2/service/oam v1.1.14 // indirect
github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.2.7 // indirect
github.com/aws/aws-sdk-go-v2/service/pipes v1.2.9 // indirect
github.com/aws/aws-sdk-go-v2/service/pricing v1.20.1 // indirect
github.com/aws/aws-sdk-go-v2/service/qldb v1.15.14 // indirect
github.com/aws/aws-sdk-go-v2/service/rbin v1.8.15 // indirect
github.com/aws/aws-sdk-go-v2/service/rds v1.46.2 // indirect
github.com/aws/aws-sdk-go-v2/service/resourceexplorer2 v1.2.16 // indirect
github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.2.3 // indirect
github.com/aws/aws-sdk-go-v2/service/route53domains v1.15.1 // indirect
github.com/aws/aws-sdk-go-v2/service/s3control v1.31.9 // indirect
github.com/aws/aws-sdk-go-v2/service/scheduler v1.1.14 // indirect
github.com/aws/aws-sdk-go-v2/service/securitylake v1.4.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sesv2 v1.18.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssm v1.36.8 // indirect
github.com/aws/aws-sdk-go-v2/service/ssmcontacts v1.15.8 // indirect
github.com/aws/aws-sdk-go-v2/service/ssmincidents v1.21.7 // indirect
github.com/aws/aws-sdk-go-v2/service/identitystore v1.17.0 // indirect
github.com/aws/aws-sdk-go-v2/service/inspector2 v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internetmonitor v1.4.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ivschat v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/service/kendra v1.42.0 // indirect
github.com/aws/aws-sdk-go-v2/service/keyspaces v1.4.0 // indirect
github.com/aws/aws-sdk-go-v2/service/lambda v1.39.0 // indirect
github.com/aws/aws-sdk-go-v2/service/lightsail v1.28.0 // indirect
github.com/aws/aws-sdk-go-v2/service/medialive v1.33.0 // indirect
github.com/aws/aws-sdk-go-v2/service/mediapackage v1.22.0 // indirect
github.com/aws/aws-sdk-go-v2/service/oam v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.4.0 // indirect
github.com/aws/aws-sdk-go-v2/service/pipes v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/service/pricing v1.21.0 // indirect
github.com/aws/aws-sdk-go-v2/service/qldb v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/rbin v1.9.0 // indirect
github.com/aws/aws-sdk-go-v2/service/rds v1.49.0 // indirect
github.com/aws/aws-sdk-go-v2/service/resourceexplorer2 v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/service/route53domains v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/s3control v1.32.0 // indirect
github.com/aws/aws-sdk-go-v2/service/scheduler v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2/service/securitylake v1.6.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sesv2 v1.19.0 // indirect
github.com/aws/aws-sdk-go-v2/service/signer v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssm v1.37.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssmcontacts v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ssmincidents v1.22.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 // indirect
github.com/aws/aws-sdk-go-v2/service/swf v1.15.3 // indirect
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.17.3 // indirect
github.com/aws/aws-sdk-go-v2/service/transcribe v1.26.9 // indirect
github.com/aws/aws-sdk-go-v2/service/verifiedpermissions v1.0.5 // indirect
github.com/aws/aws-sdk-go-v2/service/vpclattice v1.0.8 // indirect
github.com/aws/aws-sdk-go-v2/service/workspaces v1.28.16 // indirect
github.com/aws/aws-sdk-go-v2/service/xray v1.16.14 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/aws/aws-sdk-go-v2/service/swf v1.16.0 // indirect
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/service/transcribe v1.28.0 // indirect
github.com/aws/aws-sdk-go-v2/service/verifiedpermissions v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2/service/vpclattice v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2/service/workspaces v1.29.0 // indirect
github.com/aws/aws-sdk-go-v2/service/xray v1.17.0 // indirect
github.com/aws/smithy-go v1.14.0 // indirect
github.com/beevik/etree v1.2.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
Expand Down Expand Up @@ -128,15 +131,15 @@ require (
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.18.1 // indirect
github.com/hashicorp/terraform-json v0.17.0 // indirect
github.com/hashicorp/terraform-plugin-framework v1.3.2 // indirect
github.com/hashicorp/terraform-json v0.17.1 // indirect
github.com/hashicorp/terraform-plugin-framework v1.3.3 // indirect
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 // indirect
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.18.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-mux v0.11.2 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 // indirect
github.com/hashicorp/terraform-plugin-testing v1.3.0 // indirect
github.com/hashicorp/terraform-plugin-testing v1.4.0 // indirect
github.com/hashicorp/terraform-provider-aws v1.60.1-0.20220923175450-ca71523cdc36 // indirect
github.com/hashicorp/terraform-provider-aws/shim v0.0.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.1 // indirect
Expand Down Expand Up @@ -167,7 +170,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pulumi/pulumi-terraform-bridge/v3 v3.55.1-0.20230801203955-5d215c892096 // indirect
github.com/pulumi/pulumi-terraform-bridge/v3 v3.56.2 // indirect
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.7-0.20230801203955-5d215c892096 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.76.1 // indirect
github.com/pulumi/pulumi/sdk/v3 v3.76.1 // indirect
Expand Down
Loading

0 comments on commit 08fde9b

Please sign in to comment.