Skip to content

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Sep 29, 2025

K8SPSMDB-1425 Powered by Pull Request Badge

CHANGE DESCRIPTION

Add e2e test for K8SPSMDB-1425.

Also I fix two problems that I encountered in e2e test:

  1. After restore finishes, operator reverts main storage as it should but doesn't actually trigger resync.
  2. Backoff configuration for backup validation retries sometimes are not enough.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

@egegunes egegunes added this to the v1.21.0 milestone Sep 29, 2025
@pull-request-size pull-request-size bot added the size/L 100-499 lines label Sep 29, 2025
@github-actions github-actions bot added the tests label Sep 29, 2025
@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 08:58
@pull-request-size pull-request-size bot added size/XL 500-999 lines and removed size/L 100-499 lines labels Oct 1, 2025
pbm_binary=/opt/percona/pbm
fi

kubectl_bin exec ${cluster}-rs0-0 -c ${container} -- ${pbm_binary} config > ${tmp_dir}/pbm_config.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

[shfmt] reported by reviewdog 🐶

Suggested change
kubectl_bin exec ${cluster}-rs0-0 -c ${container} -- ${pbm_binary} config > ${tmp_dir}/pbm_config.yml
kubectl_bin exec ${cluster}-rs0-0 -c ${container} -- ${pbm_binary} config >${tmp_dir}/pbm_config.yml

Copy link

@Copilot 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 adds an end-to-end test for K8SPSMDB-1425, specifically testing Point-in-Time Recovery (PITR) to a new cluster. The test validates the ability to restore backups from a source cluster to a completely separate target cluster using both logical and physical backup types.

Key changes:

  • Adds a new e2e test pitr-to-new-cluster that tests PITR functionality across different clusters
  • Updates test execution lists to include the new test in release, PR, and backup test suites
  • Implements test scenarios for both logical and physical restore operations with PBM configuration validation

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
e2e-tests/run-release.csv Adds pitr-to-new-cluster test to release test suite
e2e-tests/run-pr.csv Adds pitr-to-new-cluster test to PR test suite
e2e-tests/run-backups.csv Adds pitr-to-new-cluster and other backup tests to backup test suite
e2e-tests/pitr-to-new-cluster/run Main test script implementing the PITR cross-cluster functionality
e2e-tests/pitr-to-new-cluster/conf/* Configuration files for source/target clusters and backup/restore operations
e2e-tests/pitr-to-new-cluster/compare/* Expected output files for test validation
e2e-tests/functions Updates echo statements to include '.OK' suffix for consistency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@percona percona deleted a comment from Copilot AI Oct 1, 2025
@percona percona deleted a comment from Copilot AI Oct 1, 2025
@hors hors requested a review from eleo007 October 1, 2025 09:03
Copy link

@Copilot 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@egegunes egegunes requested a review from Copilot October 1, 2025 09:12
Copy link

@Copilot 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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if isResyncNeeded(currentCfg, &main) {
log.Info("resync storage", "storage", mainStgName)
log.V(1).Info("main storage changed", "old", currentCfg.Storage, "new", main.Storage)
log.Info("main storage changed. starting resync", "old", currentCfg.Storage, "new", main.Storage)
Copy link
Preview

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The variable currentCfg may be nil at this point since the code that ensures it's not nil was removed. This could cause a panic when accessing currentCfg.Storage in the log message.

Suggested change
log.Info("main storage changed. starting resync", "old", currentCfg.Storage, "new", main.Storage)
var oldStorage interface{}
if currentCfg != nil {
oldStorage = currentCfg.Storage
} else {
oldStorage = nil
}
log.Info("main storage changed. starting resync", "old", oldStorage, "new", main.Storage)

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't make sense, nil config already handled on line 118

spec:
clusterName:
pitr:
pitrType: latest
Copy link
Preview

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The field pitrType is being used here but the sed replacement pattern on line 62 of the test script suggests this should be type. This inconsistency could cause the restore configuration to be malformed.

Suggested change
pitrType: latest
type: latest

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@gkech gkech left a comment

Choose a reason for hiding this comment

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

tests are passing for me, leaving some minor comments

setup_target_cluster

desc "Case 1: Logical restore"
test_case_1
Copy link
Contributor

Choose a reason for hiding this comment

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

For the function names, I would rather have the purpose than the number of the case we are evaluating. So test_pbm_config_logical, test_pbm_config_physical pitr_backup_restore, or something like that.

Comment on lines +216 to +220
sleep_with_log 3 "wait for data to be replicated"

compare_mongo_cmd "find" "myApp:myPass@${target_cluster}-rs0.${namespace}" "-3rd" \
".svc.cluster.local" myApp test 'sort( { x: 1 } )'
log "Data is ready for PiTR: OK"
Copy link
Contributor

Choose a reason for hiding this comment

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

If we added retries for the find command, sleeping would be redundant, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL 500-999 lines tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants