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
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
}
🤖 Augment PR SummarySummary: Adds acceptance coverage for collection-level cloud backup restores and snapshot namespace discovery.
🤖 Was this summary useful? React with 👍 or 👎 |
355f27d to
6d6acc7
Compare
6d6acc7 to
312ede6
Compare
312ede6 to
88b1490
Compare
88b1490 to
1e2c138
Compare
|
Need to fix the change in the plural data source |
a0f46de to
ccd5a37
Compare
|
Tests fixed, and all checks passing again: |
| stateConf := retry.StateChangeConf{ | ||
| Pending: []string{"INITIALIZING", "IN_PROGRESS", "FINALIZING"}, | ||
| Target: []string{wantState}, | ||
| Timeout: constant.DefaultTimeout, | ||
| MinTimeout: 1 * time.Minute, | ||
| Delay: 30 * time.Second, | ||
| Refresh: func() (any, string, error) { | ||
| body, err := GetCollectionRestoreJob(ctx, projectID, clusterName, jobID) |
There was a problem hiding this comment.
q: A lot of code here seems associated to triggering and handling a restore job, couldnt we use the TF resource for this?
There was a problem hiding this comment.
Happy-path tests already POST through the TF resource. These helpers only GET/poll.
We still need them because:
- Delete is a no-op (no public cancel API)
- A timed-out create never records
job_id, so Terraform state is empty - CheckDestroy has to find that leftover job and wait until dest-cluster teardown reaches
CANCELED
ccd5a37 to
831f6e8
Compare
831f6e8 to
01c64e2
Compare
01c64e2 to
844ba17
Compare
844ba17 to
5e61eed
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…read Co-authored-by: Cursor <cursoragent@cursor.com>
913f764 to
3689827
Compare
| cfg.databaseTarget = renamedDB | ||
| cfg.collectionSource = restaurantsNS | ||
| cfg.withDataSources = true | ||
| filtered := cfg.withCollectionsFilter(restaurantsNS) |
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.