Skip to content

test: Adds collection restore job acceptance tests - #4671

Open
EspenAlbert wants to merge 3 commits into
CLOUDP-435981_collection-restore-docsfrom
CLOUDP-435981_collection-restore-acc-tests
Open

test: Adds collection restore job acceptance tests#4671
EspenAlbert wants to merge 3 commits into
CLOUDP-435981_collection-restore-docsfrom
CLOUDP-435981_collection-restore-acc-tests

Conversation

@EspenAlbert

@EspenAlbert EspenAlbert commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds acceptance tests for mongodbatlas_cloud_backup_collection_restore_job and snapshot database data sources, plus a shared fixture that provisions a backup-enabled source cluster and on-demand snapshot. CI gets a backup_collection_restore test group.

Link to any related issue(s): CLOUDP-435981

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fix and verified my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

External reuse is supported via MONGODB_ATLAS_PROJECT_ID, MONGODB_ATLAS_CLUSTER_NAME, and MONGODB_ATLAS_SNAPSHOT_ID. The execution cluster helper can enable cloud backup and PIT when the fixture creates it.

@EspenAlbert EspenAlbert changed the title CLOUDP 435981 collection restore acc tests test: Adds collection restore job acceptance tests Aug 24, 2026
@EspenAlbert
EspenAlbert requested a lite review from Copilot August 24, 2026 07:41

Copilot AI left a comment

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.

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_job and snapshot database/collection data sources.
  • Extends the acceptance test runner workflow to include a backup_collection_restore change-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.

Comment thread internal/testutil/acc/cloud_backup_collection_restore_fixture.go
Comment thread internal/testutil/acc/cloud_backup_collection_restore_fixture.go
@EspenAlbert
EspenAlbert force-pushed the CLOUDP-435981_collection-restore-acc-tests branch 2 times, most recently from 0ac624b to b2eff2b Compare August 24, 2026 09:23
@EspenAlbert
EspenAlbert force-pushed the CLOUDP-435981_collection-restore-acc-tests branch from b2eff2b to af12ebc Compare August 24, 2026 09:32
EspenAlbert and others added 3 commits August 24, 2026 10:45
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@EspenAlbert
EspenAlbert force-pushed the CLOUDP-435981_collection-restore-acc-tests branch from 91f4c3d to 355f27d Compare August 24, 2026 09:45
@EspenAlbert
EspenAlbert marked this pull request as ready for review August 24, 2026 09:50
@EspenAlbert
EspenAlbert requested a review from a team as a code owner August 24, 2026 09:50
@EspenAlbert
EspenAlbert requested a lite review from Copilot August 24, 2026 09:50

Copilot AI left a comment

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.

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
	}

Comment on lines +238 to +241
resp, err := MongoDBClient.UntypedAPICall(ctx, collectionRestoreJobCall(projectID, clusterName, jobID), nil)
if err != nil {
return nil, err
}
@augmentcode

augmentcode Bot commented Aug 24, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR adds acceptance coverage for collection-level cloud backup restores and snapshot-discovery data sources.

  • Adds same-cluster snapshot restore coverage, including database renaming and collection results.
  • Adds cross-cluster point-in-time restore coverage for database and collection suffixes.
  • Adds an invalid-collection case and a create-timeout/cleanup lifecycle case.
  • Verifies singular, plural, and per-collection restore-job data sources.
  • Adds snapshot database and collection discovery assertions for seeded sample data.
  • Introduces a process-wide fixture that provisions a backup- and PIT-enabled source cluster, seeds it, and waits for an on-demand snapshot.
  • Supports reusing an externally supplied project, cluster, and snapshot through environment variables.
  • Extends the shared execution-cluster factory to request backup and PIT when required.
  • Adds focused unit tests for fixture environment parsing, timestamps, and backup/PIT validation.
  • Adds a dedicated CI change-detection group and acceptance-test job for this coverage.
Technical note: The restore resource is immutable and its delete is state-only, so the timeout test observes the Atlas job lifecycle during teardown.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

tb.Helper()
ctx := tb.Context()
if env, ok := collectionRestoreEnvFromOS(); ok {
snapshot, _, err := ConnV2().CloudBackupsAPI.GetClusterBackupSnapshot(ctx, env.ProjectID, env.ClusterName, env.SnapshotID).Execute()

@augmentcode augmentcode Bot Aug 24, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

2 participants