test: Adds collection restore job acceptance tests - #4671
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a shared acceptance-test fixture and new acceptance tests to validate Atlas Cloud Backup collection restore jobs and snapshot database/collection discovery, and wires them into CI via a dedicated backup_collection_restore test group.
Changes:
- Introduces a reusable fixture that provisions (or reuses via env vars) a backup/PIT-enabled source cluster plus an on-demand snapshot, along with helper pollers for collection-restore jobs.
- Adds new acceptance tests for
mongodbatlas_cloud_backup_collection_restore_joband snapshot database/collection data sources. - Extends the acceptance test runner workflow to include a
backup_collection_restorechange-detection group and job.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/testutil/acc/shared_resource.go |
Adds internal helper to create an execution cluster with backup/PIT toggles for fixture-driven tests. |
internal/testutil/acc/cloud_backup_collection_restore_fixture.go |
New shared fixture and helper functions for collection-restore acceptance tests (snapshot creation, job polling, env reuse). |
internal/testutil/acc/cloud_backup_collection_restore_fixture_test.go |
Unit tests for fixture helper functions (env parsing, timestamp conversion, backup/PIT flag checks). |
internal/testutil/acc/atlas.go |
Extends cluster creation helpers to allow enabling cloud backup and PIT for fixture-created clusters. |
internal/serviceapi/cloudbackupsnapshotdatabase/main_test.go |
Adds TestMain to run acceptance harness for the snapshot database acceptance test package. |
internal/serviceapi/cloudbackupsnapshotdatabase/data_source_test.go |
Adds acceptance coverage for snapshot database and database-collections discovery data sources. |
internal/serviceapi/cloudbackupcollectionrestorejob/resource_test.go |
Adds acceptance coverage for collection restore job resource + related data sources (incl. PIT and timeout behaviors). |
internal/serviceapi/cloudbackupcollectionrestorejob/main_test.go |
Adds TestMain to run acceptance harness for the restore job acceptance test package. |
.github/workflows/acceptance-tests-runner.yml |
Adds backup_collection_restore change-detection filter and a dedicated acceptance-test job. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0ac624b to
b2eff2b
Compare
b2eff2b to
af12ebc
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
91f4c3d to
355f27d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
internal/testutil/acc/cloud_backup_collection_restore_fixture.go:254
- Same response-body leak pattern as GetCollectionRestoreJob: on HTTP errors UntypedAPICall returns (resp, err) and the body should be closed before returning.
func LatestCollectionRestoreJobID(ctx context.Context, projectID, clusterName, destClusterName string) (string, error) {
resp, err := MongoDBClient.UntypedAPICall(ctx, collectionRestoreJobCall(projectID, clusterName, ""), nil)
if err != nil {
return "", err
}
| resp, err := MongoDBClient.UntypedAPICall(ctx, collectionRestoreJobCall(projectID, clusterName, jobID), nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
🤖 Augment PR SummarySummary: This PR adds acceptance coverage for collection-level cloud backup restores and snapshot-discovery data sources.
🤖 Was this summary useful? React with 👍 or 👎 |
| tb.Helper() | ||
| ctx := tb.Context() | ||
| if env, ok := collectionRestoreEnvFromOS(); ok { | ||
| snapshot, _, err := ConnV2().CloudBackupsAPI.GetClusterBackupSnapshot(ctx, env.ProjectID, env.ClusterName, env.SnapshotID).Execute() |
There was a problem hiding this comment.
When external reuse is selected, this accepts a snapshot in any state and returns it immediately; a queued or failed snapshot will make the later restore tests fail even though all three documented environment variables are valid. This differs from the fixture-created path, which waits until the snapshot is completed.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Description
Adds acceptance tests for
mongodbatlas_cloud_backup_collection_restore_joband snapshot database data sources, plus a shared fixture that provisions a backup-enabled source cluster and on-demand snapshot. CI gets abackup_collection_restoretest group.Link to any related issue(s): CLOUDP-435981
Type of change:
Required Checklist:
Further comments
External reuse is supported via
MONGODB_ATLAS_PROJECT_ID,MONGODB_ATLAS_CLUSTER_NAME, andMONGODB_ATLAS_SNAPSHOT_ID. The execution cluster helper can enable cloud backup and PIT when the fixture creates it.