@@ -47,6 +47,11 @@ func TestAccDataSourceDbaasLogsClusterRetention_basic(t *testing.T) {
47
47
"is_supported" ,
48
48
"true" ,
49
49
),
50
+ resource .TestCheckResourceAttr (
51
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
52
+ "retention_type" ,
53
+ "LOGS_INDEXING" ,
54
+ ),
50
55
),
51
56
},
52
57
},
@@ -90,6 +95,60 @@ func TestAccDataSourceDbaasLogsClusterRetention_by_duration(t *testing.T) {
90
95
"is_supported" ,
91
96
"true" ,
92
97
),
98
+ resource .TestCheckResourceAttr (
99
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
100
+ "retention_type" ,
101
+ "LOGS_INDEXING" ,
102
+ ),
103
+ ),
104
+ },
105
+ },
106
+ })
107
+ }
108
+
109
+ func TestAccDataSourceDbaasLogsClusterRetention_by_duration_and_type (t * testing.T ) {
110
+ serviceName := os .Getenv ("OVH_DBAAS_LOGS_SERVICE_TEST" )
111
+ clusterId := os .Getenv ("OVH_DBAAS_LOGS_CLUSTER_ID" )
112
+ retentionId := os .Getenv ("OVH_DBAAS_LOGS_CLUSTER_RETENTION_ID" )
113
+
114
+ config := fmt .Sprintf (`
115
+ data "ovh_dbaas_logs_cluster_retention" "ret" {
116
+ service_name = "%s"
117
+ cluster_id = "%s"
118
+ duration = "P1Y"
119
+ retention_type = "LOGS_INDEXING"
120
+ }` ,
121
+ serviceName ,
122
+ clusterId ,
123
+ )
124
+
125
+ resource .Test (t , resource.TestCase {
126
+ PreCheck : func () { testAccPreCheckDbaasLogsClusterRetention (t ) },
127
+ ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
128
+ Steps : []resource.TestStep {
129
+ {
130
+ Config : config ,
131
+ Check : resource .ComposeTestCheckFunc (
132
+ resource .TestCheckResourceAttr (
133
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
134
+ "service_name" ,
135
+ serviceName ,
136
+ ),
137
+ resource .TestCheckResourceAttr (
138
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
139
+ "retention_id" ,
140
+ retentionId ,
141
+ ),
142
+ resource .TestCheckResourceAttr (
143
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
144
+ "is_supported" ,
145
+ "true" ,
146
+ ),
147
+ resource .TestCheckResourceAttr (
148
+ "data.ovh_dbaas_logs_cluster_retention.ret" ,
149
+ "retention_type" ,
150
+ "LOGS_INDEXING" ,
151
+ ),
93
152
),
94
153
},
95
154
},
@@ -116,7 +175,34 @@ func TestAccDataSourceDbaasLogsClusterRetention_by_duration_not_found(t *testing
116
175
Steps : []resource.TestStep {
117
176
{
118
177
Config : config ,
119
- ExpectError : regexp .MustCompile ("no retention was found with duration P1000Y" ),
178
+ ExpectError : regexp .MustCompile ("no retention was found with duration P1000Y and type LOGS_INDEXING" ),
179
+ },
180
+ },
181
+ })
182
+ }
183
+
184
+ func TestAccDataSourceDbaasLogsClusterRetention_by_duration_and_type_not_found (t * testing.T ) {
185
+ serviceName := os .Getenv ("OVH_DBAAS_LOGS_SERVICE_TEST" )
186
+ clusterId := os .Getenv ("OVH_DBAAS_LOGS_CLUSTER_ID" )
187
+
188
+ config := fmt .Sprintf (`
189
+ data "ovh_dbaas_logs_cluster_retention" "ret" {
190
+ service_name = "%s"
191
+ cluster_id = "%s"
192
+ duration = "P1Y"
193
+ retention_type = "METRICS_TENANT"
194
+ }` ,
195
+ serviceName ,
196
+ clusterId ,
197
+ )
198
+
199
+ resource .Test (t , resource.TestCase {
200
+ PreCheck : func () { testAccPreCheckDbaasLogsClusterRetention (t ) },
201
+ ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
202
+ Steps : []resource.TestStep {
203
+ {
204
+ Config : config ,
205
+ ExpectError : regexp .MustCompile ("no retention was found with duration P1Y and type METRICS_TENANT" ),
120
206
},
121
207
},
122
208
})
@@ -146,3 +232,32 @@ func TestAccDataSourceDbaasLogsClusterRetention_missing_params(t *testing.T) {
146
232
},
147
233
})
148
234
}
235
+
236
+ func TestAccDataSourceDbaasLogsClusterRetention_invalid_params (t * testing.T ) {
237
+ serviceName := os .Getenv ("OVH_DBAAS_LOGS_SERVICE_TEST" )
238
+ clusterId := os .Getenv ("OVH_DBAAS_LOGS_CLUSTER_ID" )
239
+ retentionId := os .Getenv ("OVH_DBAAS_LOGS_CLUSTER_RETENTION_ID" )
240
+
241
+ config := fmt .Sprintf (`
242
+ data "ovh_dbaas_logs_cluster_retention" "ret" {
243
+ service_name = "%s"
244
+ cluster_id = "%s"
245
+ retention_id = "%s"
246
+ retention_type = "LOGS_INDEXING"
247
+ }` ,
248
+ serviceName ,
249
+ clusterId ,
250
+ retentionId ,
251
+ )
252
+
253
+ resource .Test (t , resource.TestCase {
254
+ PreCheck : func () { testAccPreCheckDbaasLogsCluster (t ) },
255
+ ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
256
+ Steps : []resource.TestStep {
257
+ {
258
+ Config : config ,
259
+ ExpectError : regexp .MustCompile (`Attribute \"retention_type\" cannot be specified when \"retention_id\"` ),
260
+ },
261
+ },
262
+ })
263
+ }
0 commit comments