Skip to content

[AV-128970] Add acceptance tests for query index datasources#625

Open
panigrahisubhrajit wants to merge 6 commits into
mainfrom
AV-128970-acceptance-tests
Open

[AV-128970] Add acceptance tests for query index datasources#625
panigrahisubhrajit wants to merge 6 commits into
mainfrom
AV-128970-acceptance-tests

Conversation

@panigrahisubhrajit
Copy link
Copy Markdown
Contributor

@panigrahisubhrajit panigrahisubhrajit commented May 29, 2026

Jira

Description

Adds acceptance tests for couchbase-capella_query_indexes and couchbase-capella_query_index_monitor datasources. Fixes three provider bugs found during testing: (1) query_index_monitor accepted an empty indexes set and silently succeeded — now rejected at plan time; (2) WatchIndexes polled for 60 minutes on a permanently-invalid cluster ID instead of failing fast — now fails after 5 consecutive 404s (AV-132670); (3) WatchIndexes polled 60 minutes for a deferred index that can never self-resolve — now returns an error immediately when index status is Deferred (AV-132671).

Type of Change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).

Manual Testing Approach

How was this change tested and do you have evidence? (REQUIRED: Select at least 1)

  • Acceptance tested

Testing

Testing
TestAccDatasourceQueryIndexes                     PASS
TestAccDatasourceQueryIndexesBucketOnly           PASS
TestAccDatasourceQueryIndexesScopeOnly            PASS
TestAccDatasourceQueryIndexesCollectionOnly       PASS
TestAccDatasourceQueryIndexesInvalidOrg           PASS
TestAccDatasourceQueryIndexesInvalidProject       PASS
TestAccDatasourceQueryIndexesInvalidCluster       PASS
TestAccDatasourceQueryIndexMonitorReady           PASS
TestAccDatasourceQueryIndexMonitorMultipleIndexes PASS
TestAccDatasourceQueryIndexMonitorMissingIndexes  PASS
TestAccDatasourceQueryIndexMonitorDeferred        PASS (ExpectError: deferred)
TestAccDatasourceQueryIndexMonitorNonexistentIndex PASS (ExpectError: Error monitoring query indexes)
TestAccDatasourceQueryIndexMonitorInvalidCluster  PASS (ExpectError: Error monitoring query indexes)

Further comments

panigrahisubhrajit and others added 3 commits May 25, 2026 22:49
Covers query_indexes datasource (list with scope+collection, bucket-level only,
scope-only filter, invalid cluster, invalid bucket, nonexistent scope, missing
bucket_name) and query_index_monitor datasource (ready non-deferred index,
multiple ready indexes, deferred index warning, nonexistent index warning,
invalid cluster, missing/empty indexes set).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add setvalidator.SizeAtLeast(1) to query_index_monitor indexes attribute
so an empty set is rejected at plan time. Skip three monitor tests that
hang for 60 minutes due to WatchIndexes not failing fast on permanent
errors; tracked in AV-132670 and AV-132671.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@panigrahisubhrajit panigrahisubhrajit requested a review from a team as a code owner May 29, 2026 11:51
Copilot AI review requested due to automatic review settings May 29, 2026 11:51
@github-actions github-actions Bot added bug Something isn't working enhancement New feature or request labels May 29, 2026
@factory-droid
Copy link
Copy Markdown
Contributor

factory-droid Bot commented May 29, 2026

Droid finished @panigrahisubhrajit's task —— View job


Copy link
Copy Markdown
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

Adds acceptance test coverage for the couchbase-capella_query_indexes and couchbase-capella_query_index_monitor datasources, and adds a SizeAtLeast(1) validator on the monitor datasource's indexes attribute so an empty set is rejected at plan time instead of silently succeeding. Three monitor tests that would hang for 60 minutes due to existing WatchIndexes behavior are skipped pending fixes tracked in AV-132670/AV-132671.

Changes:

  • New acceptance test file covering query_indexes (full/bucket-only/scope-only/invalid variants) and query_index_monitor (ready/multi/missing/skipped error cases).
  • Adds set validator SizeAtLeast(1) on indexes in the GSI monitor datasource schema.

Reviewed changes

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

File Description
internal/datasources/gsi_monitor_schema.go Adds validator import and SizeAtLeast(1) on the indexes set attribute.
acceptance_tests/query_index_acceptance_test.go New file with acceptance tests for query indexes and query index monitor datasources, including skipped tests linked to bug tickets.

resource.TestCheckResourceAttr(dsReference, "bucket_name", globalBucketName),
resource.TestCheckResourceAttr(dsReference, "scope_name", globalScopeName),
resource.TestCheckResourceAttr(dsReference, "collection_name", globalCollectionName),
resource.TestCheckResourceAttrSet(dsReference, "data.#"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] data.# assertions can pass even when the datasource returns zero rows

resource.TestCheckResourceAttrSet(dsReference, "data.#") will pass when the datasource returns an empty list because data.# is still set (to the string "0"). This can let this test succeed even if the created index is not returned. Add a non-zero count check or assert the created index name appears in data.

Copy link
Copy Markdown
Contributor

@factory-droid factory-droid Bot left a comment

Choose a reason for hiding this comment

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

Validated all candidate comments for this PR. Approved one actionable test-correctness issue (data.# can false-pass at "0"), and rejected one speculative flakiness report whose stated state-corruption path is not supported by current provider behavior.

panigrahisubhrajit and others added 3 commits May 29, 2026 17:31
- Return ErrIndexDeferred immediately when index status is Deferred
  instead of polling 60 minutes (AV-132671)
- Fail fast on non-404 API errors; limit consecutive 404 retries to 5
  before giving up, preventing 60-minute hang on invalid cluster IDs (AV-132670)
- Distinguish timeout (warning) from permanent failure (error) in gsi_monitor
- Re-enable Deferred, NonexistentIndex, InvalidCluster acceptance tests
  with ExpectError now that the datasource returns errors for these cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ed pattern

maxConsecutive404s=5 caused 31-minute wait (1+2+4+8+16 min) exceeding the
30-minute test timeout on Azure. Reducing to 3 caps the wait at 7 minutes.
Update deferred test ExpectError to match the error title rather than
the status string, which also handles transient network errors (DNS failure).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The API returns 200 OK with a non-Deferred status for a deferred index,
so WatchIndexes polls at 1 req/sec indefinitely and the test always
times out at 30 minutes. Skip until the exact status string is known
so ErrIndexDeferred can be triggered correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants