Skip to content

Commit f4aaa38

Browse files
committed
Add acceptance test verifying the SDK -> PF migration does not break state
1 parent eabb997 commit f4aaa38

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

internal/kibana/connectors/acc_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,62 @@ func TestAccResourceKibanaConnectorIndex(t *testing.T) {
270270
},
271271
})
272272
}
273+
274+
func TestAccResourceKibanaConnectorFromSDK(t *testing.T) {
275+
minSupportedVersion := version.Must(version.NewSemver("7.14.0"))
276+
277+
connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum)
278+
279+
create := func(name string) string {
280+
return fmt.Sprintf(`
281+
provider "elasticstack" {
282+
elasticsearch {}
283+
kibana {}
284+
}
285+
286+
resource "elasticstack_kibana_action_connector" "test" {
287+
name = "%s"
288+
config = jsonencode({
289+
index = ".kibana"
290+
refresh = true
291+
})
292+
connector_type_id = ".index"
293+
}`,
294+
name)
295+
}
296+
297+
resource.Test(t, resource.TestCase{
298+
PreCheck: func() { acctest.PreCheck(t) },
299+
CheckDestroy: checkResourceKibanaConnectorDestroy,
300+
Steps: []resource.TestStep{
301+
{
302+
// Create the connector with the last provider version where the connector resource was built on the SDK
303+
ExternalProviders: map[string]resource.ExternalProvider{
304+
"elasticstack": {
305+
Source: "elastic/elasticstack",
306+
VersionConstraint: "0.11.17",
307+
},
308+
},
309+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion),
310+
Config: create(connectorName),
311+
Check: resource.ComposeTestCheckFunc(
312+
testCommonAttributes(connectorName, ".index"),
313+
314+
resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"index\":\"\.kibana\"`)),
315+
resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"refresh\":true`)),
316+
),
317+
},
318+
{
319+
ProtoV6ProviderFactories: acctest.Providers,
320+
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion),
321+
Config: create(connectorName),
322+
Check: resource.ComposeTestCheckFunc(
323+
testCommonAttributes(connectorName, ".index"),
324+
325+
resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"index\":\"\.kibana\"`)),
326+
resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"refresh\":true`)),
327+
),
328+
},
329+
},
330+
})
331+
}

internal/kibana/connectors/delete.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ func (r *Resource) Delete(ctx context.Context, request resource.DeleteRequest, r
3737
spaceId := state.SpaceID.ValueString()
3838

3939
response.Diagnostics.Append(kibana_oapi.DeleteConnector(ctx, oapiClient, compositeID.ResourceId, spaceId)...)
40-
if response.Diagnostics.HasError() {
41-
return
42-
}
4340
}

0 commit comments

Comments
 (0)