Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Follow-up to #1467. Refactored all Kibana connector acceptance tests to use the ConfigDirectory and ConfigVariables pattern, consistent with fleet integration tests.

Changes

All acceptance tests in internal/kibana/connectors/acc_test.go now use external Terraform configuration files:

  • TestAccResourceKibanaConnectorAI: Consolidated TestAccResourceKibanaConnectorBedrock and TestAccResourceKibanaConnectorGenAi into table-driven test
  • TestAccResourceKibanaConnectorCasesWebhook: Refactored with table-driven test for connector ID scenarios (empty and predefined)
  • TestAccResourceKibanaConnectorIndex: Uses ConfigDirectory with create/update subdirectories
  • TestAccResourceKibanaConnectorFromSDK: Uses embedded config for SDK step, ConfigDirectory for plugin framework step
  • TestAccResourceKibanaConnectorEmptyConfigFromSDK: Same pattern as FromSDK test

Structure

Test configurations are organized in testdata/ directories:

  • testdata/TestAccResourceKibanaConnectorAI/{bedrock,gen-ai}/{create,update}/connector.tf
  • testdata/TestAccResourceKibanaConnectorCasesWebhook/{with_empty_connector_id,with_predefined_connector_id}/{create,update}/connector.tf
  • testdata/TestAccResourceKibanaConnectorIndex/{create,update}/connector.tf
  • testdata/TestAccResourceKibanaConnectorFromSDK/connector.tf
  • testdata/TestAccResourceKibanaConnectorEmptyConfigFromSDK/connector.tf

Test Results

All acceptance tests pass (24.7s total runtime):

  • ✅ TestAccResourceKibanaConnectorCasesWebhook (both with and without predefined connector ID)
  • ✅ TestAccResourceKibanaConnectorIndex
  • ✅ TestAccResourceKibanaConnectorFromSDK
  • ✅ TestAccResourceKibanaConnectorEmptyConfigFromSDK
  • ✅ TestAccResourceKibanaConnectorAI (bedrock and gen-ai)

Code Reduction

  • Original: 555 lines
  • Final: 376 lines
  • Total reduction: 179 lines (32.3%)

Test execution logic is now separated from test data, with Terraform configurations in external files and test assertions in table-driven structures.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor acc tests for Kibana connectors</issue_title>
<issue_description>It's a follow-up from #1467, namely we need to address #1467 (comment).</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 24, 2025 14:54
Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>
Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor acc tests for Kibana connectors Refactor AI connector acceptance tests to eliminate duplication Nov 24, 2025
Copilot AI requested a review from dimuon November 24, 2025 15:00
Copilot finished work on behalf of dimuon November 24, 2025 15:00
})
}

func TestAccResourceKibanaConnectorBedrock(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , restructure this test file to be consistent with this pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f5b838e. Restructured to use ConfigDirectory and ConfigVariables pattern with testdata files, matching the fleet integration test structure.

Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>
Copilot AI requested a review from dimuon November 24, 2025 15:43
Copilot finished work on behalf of dimuon November 24, 2025 15:43
@tobio
Copy link
Member

tobio commented Nov 24, 2025

@copilot refactor all the tests in internal/kibana/connectors/acc_test.go to follow the established pattern:

  • Terraform modules located in external files
  • Variables defined via ConfigVariables

Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot refactor all the tests in internal/kibana/connectors/acc_test.go to follow the established pattern:

  • Terraform modules located in external files
  • Variables defined via ConfigVariables

Done in 7bb50da. All tests now use ConfigDirectory pattern with external terraform files:

  • TestAccResourceKibanaConnectorCasesWebhook: Table-driven test with testdata subdirectories
  • TestAccResourceKibanaConnectorIndex: ConfigDirectory with create/update subdirectories
  • TestAccResourceKibanaConnectorFromSDK: Embedded config for SDK step, ConfigDirectory for plugin framework step
  • TestAccResourceKibanaConnectorEmptyConfigFromSDK: Same pattern as FromSDK
  • TestAccResourceKibanaConnectorAI: Already refactored

All acceptance tests pass (24.7s total runtime).

Copilot AI changed the title Refactor AI connector acceptance tests to eliminate duplication Refactor all Kibana connector acceptance tests to use ConfigDirectory pattern Nov 24, 2025
Copilot AI requested a review from tobio November 24, 2025 19:54
Copilot finished work on behalf of tobio November 24, 2025 19:54
@tobio tobio marked this pull request as ready for review November 24, 2025 20:40
Copilot AI review requested due to automatic review settings November 24, 2025 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors all Kibana connector acceptance tests to use external Terraform configuration files with the ConfigDirectory and ConfigVariables pattern, following the same approach previously established in fleet integration tests.

Key Changes

  • Consolidated TestAccResourceKibanaConnectorBedrock and TestAccResourceKibanaConnectorGenAi into a single table-driven test TestAccResourceKibanaConnectorAI
  • Migrated inline Terraform configuration strings to external .tf files organized in testdata/ subdirectories
  • Implemented ConfigDirectory and ConfigVariables pattern across all connector acceptance tests

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/kibana/connectors/acc_test.go Refactored test functions to use external configs and table-driven patterns, eliminating inline Terraform strings
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorAI/bedrock/create/connector.tf External config for bedrock connector creation test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorAI/bedrock/update/connector.tf External config for bedrock connector update test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorAI/gen-ai/create/connector.tf External config for gen-ai connector creation test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorAI/gen-ai/update/connector.tf External config for gen-ai connector update test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_empty_connector_id/create/connector.tf External config for cases webhook connector creation without predefined ID
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_empty_connector_id/update/connector.tf External config for cases webhook connector update without predefined ID
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_predefined_connector_id/create/connector.tf External config for cases webhook connector creation with predefined ID
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorCasesWebhook/with_predefined_connector_id/update/connector.tf External config for cases webhook connector update with predefined ID
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorIndex/create/connector.tf External config for index connector creation test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorIndex/update/connector.tf External config for index connector update test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorFromSDK/connector.tf External config for SDK-based connector test
internal/kibana/connectors/testdata/TestAccResourceKibanaConnectorEmptyConfigFromSDK/connector.tf External config for SDK-based empty config connector test

Comment on lines +1 to +4
variable "connector_name" {
description = "The connector name"
type = string
}
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All test configuration files define the same connector_name variable with identical description and type. Consider creating a shared variables file to eliminate this duplication across 13 test configuration files.

Copilot uses AI. Check for mistakes.
"connector_name": config.StringVariable(connectorName),
},
Check: resource.ComposeTestCheckFunc(
append([]resource.TestCheckFunc{testCommonAttributes(connectorName, tc.connectorTypeID)}, tc.createChecks...)...,
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The pattern of appending testCommonAttributes to check functions could be simplified by having tc.createChecks and tc.updateChecks include all necessary checks. This would eliminate the need for the append operation and make the test structure clearer.

Copilot uses AI. Check for mistakes.
@tobio tobio merged commit 0f16228 into main Nov 24, 2025
54 checks passed
@tobio tobio deleted the copilot/refactor-acc-tests-kibana-connectors branch November 24, 2025 20:42
nick-benoit pushed a commit that referenced this pull request Nov 25, 2025
… pattern (#1484)

* Initial plan

* Refactor AI connector tests into table-driven test

Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>

* Fix regex pattern for secret field in bedrock update checks

Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>

* Restructure test to use ConfigDirectory pattern with testdata files

Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>

* Refactor all connector acceptance tests to use ConfigDirectory pattern

Co-authored-by: tobio <444668+tobio@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dimuon <8962171+dimuon@users.noreply.github.com>
Co-authored-by: tobio <444668+tobio@users.noreply.github.com>
tobio added a commit that referenced this pull request Nov 27, 2025
…ata-view-resource

* origin/main: (32 commits)
  chore(deps): update kibana-openapi-spec digest to c99d51c (#1487)
  [Feature] Introduce elasticsearch alias resource with atomic write index management and nested attributes (#1343)
  Support setting solution for 8.16+ on Cloud (#1486)
  Refactor all Kibana connector acceptance tests to use ConfigDirectory pattern (#1484)
  Support .bedrock and .gen-ai connectors (#1467)
  Bump golang.org/x/crypto from 0.41.0 to 0.45.0 in /libs/go-kibana-rest (#1481)
  Bump golang.org/x/crypto from 0.42.0 to 0.45.0 (#1480)
  fix(deps): update module github.com/go-resty/resty/v2 to v2.17.0 (#1478)
  chore(deps): update kibana-openapi-spec digest to f1d0789 (#1479)
  chore(deps): update kibana-openapi-spec digest to 5841714 (#1477)
  chore(deps): update golang:1.25.4 docker digest to 6981837 (#1476)
  chore(deps): update kibana-openapi-spec digest to 67de5ef (#1475)
  chore(deps): update golangci/golangci-lint-action digest to e7fa5ac (#1474)
  chore(deps): update kibana-openapi-spec digest to b4553b6 (#1472)
  chore(deps): update actions/checkout action to v6 (#1470)
  Support publishing experimental resources/datasources within the framework provider (#1464)
  chore(deps): update actions/setup-go digest to 4dc6199 (#1466)
  fix(deps): update module github.com/elastic/elastic-transport-go/v8 to v8.8.0 (#1459)
  Prepare 0.12.2 Release (#1458)
  Support spaces for detection rules (#1457)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor acc tests for Kibana connectors

3 participants