Skip to content

Commit c4e1d66

Browse files
committed
test: raise errors on data consistency errors
1 parent d223496 commit c4e1d66

50 files changed

Lines changed: 469 additions & 219 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/service/cloud/data_sources.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121

2222
func DataSourceHosts() *schema.Resource {
2323
return &schema.Resource{
24+
EnableLegacyTypeSystemApplyErrors: true,
25+
EnableLegacyTypeSystemPlanErrors: true,
2426
Description: `Returns a list of available UpCloud hosts.
2527
A host identifies the host server that virtual machines are run on.
2628
Only hosts on private cloud to which the calling account has access to are available through this resource.`,
@@ -30,6 +32,8 @@ func DataSourceHosts() *schema.Resource {
3032
Type: schema.TypeSet,
3133
Computed: true,
3234
Elem: &schema.Resource{
35+
EnableLegacyTypeSystemApplyErrors: true,
36+
EnableLegacyTypeSystemPlanErrors: true,
3337
Schema: map[string]*schema.Schema{
3438
"host_id": {
3539
Type: schema.TypeInt,
@@ -86,8 +90,10 @@ func dataSourceHostsRead(ctx context.Context, d *schema.ResourceData, meta inter
8690

8791
func DataSourceZone() *schema.Resource {
8892
return &schema.Resource{
89-
Description: "Data-source is deprecated.",
90-
ReadContext: resourceZoneRead,
93+
EnableLegacyTypeSystemApplyErrors: true,
94+
EnableLegacyTypeSystemPlanErrors: true,
95+
Description: "Data-source is deprecated.",
96+
ReadContext: resourceZoneRead,
9197
Schema: map[string]*schema.Schema{
9298
"name": {
9399
Description: "Unique lablel for the zone",
@@ -148,8 +154,10 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac
148154

149155
func DataSourceZones() *schema.Resource {
150156
return &schema.Resource{
151-
Description: "Data-source is deprecated.",
152-
ReadContext: dataSourceZonesRead,
157+
EnableLegacyTypeSystemApplyErrors: true,
158+
EnableLegacyTypeSystemPlanErrors: true,
159+
Description: "Data-source is deprecated.",
160+
ReadContext: dataSourceZonesRead,
153161
Schema: map[string]*schema.Schema{
154162
"zone_ids": {
155163
Type: schema.TypeSet,

internal/service/database/data_source_opensearch_indices.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import (
1313

1414
func DataSourceOpenSearchIndices() *schema.Resource {
1515
return &schema.Resource{
16-
Description: "OpenSearch indices",
17-
ReadContext: dataSourceOpenSearchIndicesRead,
16+
EnableLegacyTypeSystemApplyErrors: true,
17+
EnableLegacyTypeSystemPlanErrors: true,
18+
Description: "OpenSearch indices",
19+
ReadContext: dataSourceOpenSearchIndicesRead,
1820
Schema: map[string]*schema.Schema{
1921
"indices": {
2022
Description: "Available indices for OpenSearch",
@@ -35,7 +37,9 @@ func DataSourceOpenSearchIndices() *schema.Resource {
3537

3638
func schemaOpenSearchIndex() *schema.Resource {
3739
return &schema.Resource{
38-
Description: "OpenSearch index",
40+
EnableLegacyTypeSystemApplyErrors: true,
41+
EnableLegacyTypeSystemPlanErrors: true,
42+
Description: "OpenSearch index",
3943
Schema: map[string]*schema.Schema{
4044
"create_time": {
4145
Description: "Timestamp indicating the creation time of the index.",

internal/service/database/data_source_sessions.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515

1616
func DataSourceSessionsMySQL() *schema.Resource {
1717
return &schema.Resource{
18-
Description: "Current sessions of a MySQL managed database",
19-
ReadContext: dataSourceSessionsMySQLRead,
18+
EnableLegacyTypeSystemApplyErrors: true,
19+
EnableLegacyTypeSystemPlanErrors: true,
20+
Description: "Current sessions of a MySQL managed database",
21+
ReadContext: dataSourceSessionsMySQLRead,
2022
Schema: utils.JoinSchemas(
2123
schemaDataSourceSessionsCommon(),
2224
schemaDataSourceSessionsMySQL(),
@@ -26,8 +28,10 @@ func DataSourceSessionsMySQL() *schema.Resource {
2628

2729
func DataSourceSessionsPostgreSQL() *schema.Resource {
2830
return &schema.Resource{
29-
Description: "Current sessions of a PostgreSQL managed database",
30-
ReadContext: dataSourceSessionsPostgreSQLRead,
31+
EnableLegacyTypeSystemApplyErrors: true,
32+
EnableLegacyTypeSystemPlanErrors: true,
33+
Description: "Current sessions of a PostgreSQL managed database",
34+
ReadContext: dataSourceSessionsPostgreSQLRead,
3135
Schema: utils.JoinSchemas(
3236
schemaDataSourceSessionsCommon(),
3337
schemaDataSourceSessionsPostgreSQL(),
@@ -37,8 +41,10 @@ func DataSourceSessionsPostgreSQL() *schema.Resource {
3741

3842
func DataSourceSessionsRedis() *schema.Resource {
3943
return &schema.Resource{
40-
Description: "Current sessions of a Redis managed database",
41-
ReadContext: dataSourceSessionsRedisRead,
44+
EnableLegacyTypeSystemApplyErrors: true,
45+
EnableLegacyTypeSystemPlanErrors: true,
46+
Description: "Current sessions of a Redis managed database",
47+
ReadContext: dataSourceSessionsRedisRead,
4248
Schema: utils.JoinSchemas(
4349
schemaDataSourceSessionsCommon(),
4450
schemaDataSourceSessionsRedis(),
@@ -113,7 +119,9 @@ func schemaDataSourceSessionsRedis() map[string]*schema.Schema {
113119

114120
func schemaDatabaseSessionMySQL() *schema.Resource {
115121
return &schema.Resource{
116-
Description: "MySQL session",
122+
EnableLegacyTypeSystemApplyErrors: true,
123+
EnableLegacyTypeSystemPlanErrors: true,
124+
Description: "MySQL session",
117125
Schema: map[string]*schema.Schema{
118126
"application_name": {
119127
Description: "Name of the application that is connected to this service.",
@@ -161,7 +169,9 @@ func schemaDatabaseSessionMySQL() *schema.Resource {
161169

162170
func schemaDatabaseSessionPostgreSQL() *schema.Resource {
163171
return &schema.Resource{
164-
Description: "PostgreSQL session",
172+
EnableLegacyTypeSystemApplyErrors: true,
173+
EnableLegacyTypeSystemPlanErrors: true,
174+
Description: "PostgreSQL session",
165175
Schema: map[string]*schema.Schema{
166176
"application_name": {
167177
Description: "Name of the application that is connected to this service.",
@@ -278,7 +288,9 @@ func schemaDatabaseSessionPostgreSQL() *schema.Resource {
278288

279289
func schemaDatabaseSessionRedis() *schema.Resource {
280290
return &schema.Resource{
281-
Description: "Redis session",
291+
EnableLegacyTypeSystemApplyErrors: true,
292+
EnableLegacyTypeSystemPlanErrors: true,
293+
Description: "Redis session",
282294
Schema: map[string]*schema.Schema{
283295
"active_channel_subscriptions": {
284296
Description: "Number of active channel subscriptions",

internal/service/database/database_common.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ func schemaDatabaseComponents() *schema.Schema {
118118
Type: schema.TypeList,
119119
Computed: true,
120120
Elem: &schema.Resource{
121+
EnableLegacyTypeSystemApplyErrors: true,
122+
EnableLegacyTypeSystemPlanErrors: true,
121123
Schema: map[string]*schema.Schema{
122124
"component": {
123125
Description: "Type of the component",
@@ -157,6 +159,8 @@ func schemaDatabaseNetwork() *schema.Schema {
157159
MaxItems: 8,
158160
MinItems: 1,
159161
Elem: &schema.Resource{
162+
EnableLegacyTypeSystemApplyErrors: true,
163+
EnableLegacyTypeSystemPlanErrors: true,
160164
Schema: map[string]*schema.Schema{
161165
"name": {
162166
Description: "The name of the network. Must be unique within the service.",
@@ -223,6 +227,8 @@ func schemaDatabaseNodeStates() *schema.Schema {
223227
Type: schema.TypeList,
224228
Computed: true,
225229
Elem: &schema.Resource{
230+
EnableLegacyTypeSystemApplyErrors: true,
231+
EnableLegacyTypeSystemPlanErrors: true,
226232
Schema: map[string]*schema.Schema{
227233
"name": {
228234
Description: "Name plus a node iteration",

internal/service/database/logical_database.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818

1919
func ResourceLogicalDatabase() *schema.Resource {
2020
return &schema.Resource{
21-
Description: "This resource represents a logical database in managed database",
22-
CreateContext: resourceLogicalDatabaseCreate,
23-
ReadContext: resourceLogicalDatabaseRead,
24-
DeleteContext: resourceLogicalDatabaseDelete,
21+
EnableLegacyTypeSystemApplyErrors: true,
22+
EnableLegacyTypeSystemPlanErrors: true,
23+
Description: "This resource represents a logical database in managed database",
24+
CreateContext: resourceLogicalDatabaseCreate,
25+
ReadContext: resourceLogicalDatabaseRead,
26+
DeleteContext: resourceLogicalDatabaseDelete,
2527
Importer: &schema.ResourceImporter{
2628
StateContext: schema.ImportStatePassthroughContext,
2729
},

internal/service/database/mysql.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import (
1212

1313
func ResourceMySQL() *schema.Resource {
1414
return &schema.Resource{
15-
Description: serviceDescription("MySQL"),
16-
CreateContext: resourceMySQLCreate,
17-
ReadContext: resourceMySQLRead,
18-
UpdateContext: resourceMySQLUpdate,
19-
DeleteContext: resourceDatabaseDelete,
15+
EnableLegacyTypeSystemApplyErrors: true,
16+
EnableLegacyTypeSystemPlanErrors: true,
17+
Description: serviceDescription("MySQL"),
18+
CreateContext: resourceMySQLCreate,
19+
ReadContext: resourceMySQLRead,
20+
UpdateContext: resourceMySQLUpdate,
21+
DeleteContext: resourceDatabaseDelete,
2022
Importer: &schema.ResourceImporter{
2123
StateContext: schema.ImportStatePassthroughContext,
2224
},
@@ -63,7 +65,9 @@ func schemaMySQLEngine() map[string]*schema.Schema {
6365
Computed: true,
6466
MaxItems: 1,
6567
Elem: &schema.Resource{
66-
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeMySQL),
68+
EnableLegacyTypeSystemApplyErrors: true,
69+
EnableLegacyTypeSystemPlanErrors: true,
70+
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeMySQL),
6771
},
6872
},
6973
}

internal/service/database/opensearch.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import (
1414

1515
func ResourceOpenSearch() *schema.Resource {
1616
return &schema.Resource{
17-
Description: serviceDescription("OpenSearch"),
18-
CreateContext: resourceOpenSearchCreate,
19-
ReadContext: resourceOpenSearchRead,
20-
UpdateContext: resourceOpenSearchUpdate,
21-
DeleteContext: resourceDatabaseDelete,
17+
EnableLegacyTypeSystemApplyErrors: true,
18+
EnableLegacyTypeSystemPlanErrors: true,
19+
Description: serviceDescription("OpenSearch"),
20+
CreateContext: resourceOpenSearchCreate,
21+
ReadContext: resourceOpenSearchRead,
22+
UpdateContext: resourceOpenSearchUpdate,
23+
DeleteContext: resourceDatabaseDelete,
2224
Importer: &schema.ResourceImporter{
2325
StateContext: schema.ImportStatePassthroughContext,
2426
},
@@ -110,7 +112,9 @@ func schemaOpenSearchEngine() map[string]*schema.Schema {
110112
Computed: true,
111113
MaxItems: 1,
112114
Elem: &schema.Resource{
113-
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeOpenSearch),
115+
EnableLegacyTypeSystemApplyErrors: true,
116+
EnableLegacyTypeSystemPlanErrors: true,
117+
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeOpenSearch),
114118
},
115119
},
116120
}

internal/service/database/postgresql.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import (
1313

1414
func ResourcePostgreSQL() *schema.Resource {
1515
return &schema.Resource{
16-
Description: serviceDescription("PostgreSQL"),
17-
CreateContext: resourcePostgreSQLCreate,
18-
ReadContext: resourcePostgreSQLRead,
19-
UpdateContext: resourcePostgreSQLUpdate,
20-
DeleteContext: resourceDatabaseDelete,
16+
EnableLegacyTypeSystemApplyErrors: true,
17+
EnableLegacyTypeSystemPlanErrors: true,
18+
Description: serviceDescription("PostgreSQL"),
19+
CreateContext: resourcePostgreSQLCreate,
20+
ReadContext: resourcePostgreSQLRead,
21+
UpdateContext: resourcePostgreSQLUpdate,
22+
DeleteContext: resourceDatabaseDelete,
2123
Importer: &schema.ResourceImporter{
2224
StateContext: schema.ImportStatePassthroughContext,
2325
},
@@ -107,7 +109,9 @@ func schemaPostgreSQLEngine() map[string]*schema.Schema {
107109
Computed: true,
108110
MaxItems: 1,
109111
Elem: &schema.Resource{
110-
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypePostgreSQL),
112+
EnableLegacyTypeSystemApplyErrors: true,
113+
EnableLegacyTypeSystemPlanErrors: true,
114+
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypePostgreSQL),
111115
},
112116
},
113117
}

internal/service/database/properties/schema.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ func getSchema(key string, prop upcloud.ManagedDatabaseServiceProperty) (*schema
181181

182182
s.Type = schema.TypeList
183183
s.MaxItems = 1
184-
s.Elem = &schema.Resource{Schema: nested}
184+
s.Elem = &schema.Resource{
185+
EnableLegacyTypeSystemApplyErrors: true,
186+
EnableLegacyTypeSystemPlanErrors: true,
187+
Schema: nested,
188+
}
185189
default:
186190
return nil, fmt.Errorf(`unknown property value type "%s"`, prop.Type)
187191
}

internal/service/database/redis.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import (
1212

1313
func ResourceRedis() *schema.Resource {
1414
return &schema.Resource{
15-
Description: serviceDescription("Redis"),
16-
CreateContext: resourceRedisCreate,
17-
ReadContext: resourceRedisRead,
18-
UpdateContext: resourceRedisUpdate,
19-
DeleteContext: resourceDatabaseDelete,
15+
EnableLegacyTypeSystemApplyErrors: true,
16+
EnableLegacyTypeSystemPlanErrors: true,
17+
Description: serviceDescription("Redis"),
18+
CreateContext: resourceRedisCreate,
19+
ReadContext: resourceRedisRead,
20+
UpdateContext: resourceRedisUpdate,
21+
DeleteContext: resourceDatabaseDelete,
2022
Importer: &schema.ResourceImporter{
2123
StateContext: schema.ImportStatePassthroughContext,
2224
},
@@ -63,7 +65,9 @@ func schemaRedisEngine() map[string]*schema.Schema {
6365
Computed: true,
6466
MaxItems: 1,
6567
Elem: &schema.Resource{
66-
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeRedis),
68+
EnableLegacyTypeSystemApplyErrors: true,
69+
EnableLegacyTypeSystemPlanErrors: true,
70+
Schema: properties.GetSchemaMap(upcloud.ManagedDatabaseServiceTypeRedis),
6771
},
6872
},
6973
}

0 commit comments

Comments
 (0)