Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e-tests/replset-remapping/conf/restore-pitr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ spec:
backupName:
replsetRemapping:
rs0: replset0
rs1: replset1
pitr:
type: latest
1 change: 1 addition & 0 deletions e2e-tests/replset-remapping/conf/restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ spec:
backupName:
replsetRemapping:
rs0: replset0
rs1: replset1
59 changes: 59 additions & 0 deletions e2e-tests/replset-remapping/conf/some-name-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,62 @@ spec:
resources:
requests:
storage: 3Gi
- name: rs1
size: 3
expose:
enabled: false
exposeType: ClusterIP
configuration: |
security:
enableEncryption: false
resources:
limits:
cpu: 300m
memory: 0.5G
requests:
cpu: 300m
memory: 0.5G
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
sharding:
enabled: true
configsvrReplSet:
size: 3
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
expose:
enabled: false
type: ClusterIP
resources:
limits:
cpu: "600m"
memory: "1Gi"
requests:
cpu: "300m"
memory: "1Gi"
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
mongos:
size: 3
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
resources:
limits:
cpu: "600m"
memory: "1Gi"
requests:
cpu: "300m"
memory: "1Gi"
expose:
type: ClusterIP

58 changes: 58 additions & 0 deletions e2e-tests/replset-remapping/conf/some-name-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,61 @@ spec:
resources:
requests:
storage: 3Gi
- name: replset1
size: 3
expose:
enabled: false
exposeType: ClusterIP
configuration: |
security:
enableEncryption: false
resources:
limits:
cpu: 300m
memory: 0.5G
requests:
cpu: 300m
memory: 0.5G
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
sharding:
enabled: true
configsvrReplSet:
size: 3
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
expose:
enabled: false
type: ClusterIP
resources:
limits:
cpu: "600m"
memory: "1Gi"
requests:
cpu: "300m"
memory: "1Gi"
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 3Gi
mongos:
size: 3
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
resources:
limits:
cpu: "600m"
memory: "1Gi"
requests:
cpu: "300m"
memory: "1Gi"
expose:
type: ClusterIP
40 changes: 15 additions & 25 deletions e2e-tests/replset-remapping/run
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,26 @@ function setup_source_cluster() {
wait_cluster_consistency "${source_cluster}"

log "writing some data"
run_mongo \
run_mongos \
'use myApp\n db.test.insert({ x: 100500 })' \
"databaseAdmin:databaseAdmin123456@${source_cluster}-rs0.${namespace}"
compare_mongo_cmd \
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}"
Comment on lines 31 to +34
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

Missing sharding setup operations. For a sharded cluster, you need to enable sharding on the database and shard the collection before inserting data. Between line 30 and 31, you should add:

  1. Enable sharding on the database with sh.enableSharding("myApp") using the clusterAdmin credentials
  2. Insert the test data
  3. Shard the collection with sh.shardCollection("myApp.test", { _id: 1 })

This is necessary to properly test replset remapping with a sharded cluster, as shown in the replset-remapping-sharded test.

Copilot uses AI. Check for mistakes.
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${source_cluster}-rs0.${namespace}" \
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}" \
"" \
".svc.cluster.local" \
myApp \
test \
'' \
false \
rs0
test
run_backup "minio" "backup-minio-physical" "physical"
wait_backup "backup-minio-physical"
Comment on lines 42 to 43
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The backup order has been changed from logical-then-physical (in the original) to physical-then-logical. This could affect test reliability if there are timing dependencies. Consider keeping the original order (logical backup first at line 42-43, then physical backup at line 45-46) to maintain consistency with established test patterns and avoid potential timing-related issues.

Copilot uses AI. Check for mistakes.

run_backup "minio" "backup-minio-logical"
wait_backup "backup-minio-logical"

log "writing more data for PiTR"
run_mongo \
run_mongos \
'use myApp\n db.test.insert({ x: 100501 })' \
"databaseAdmin:databaseAdmin123456@${source_cluster}-rs0.${namespace}"
"databaseAdmin:databaseAdmin123456@${source_cluster}-mongos.${namespace}"
sleep_with_log 70 "wait for oplog chunk upload"

log "deleting PSMDB cluster: ${source_cluster}"
Expand All @@ -75,37 +72,30 @@ function test_restores() {
run_restore backup-minio-physical
wait_restore backup-minio-physical ${target_cluster}
wait_cluster_consistency "${target_cluster}"
compare_mongo_cmd \
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-replset0.${namespace}" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}" \
"" \
".svc.cluster.local" \
myApp \
test \
'' \
false \
replset0
test
desc "CASE 1: PASSED"

log "dropping test collection"
run_mongo 'use myApp\n db.test.drop()' \
"databaseAdmin:databaseAdmin123456@${target_cluster}-replset0.${namespace}" \
"mongodb" ".svc.cluster.local" "" "replset0"
run_mongos 'use myApp\n db.test.drop()' \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}"

desc "CASE 2: Logical restore with replset remapping"
run_restore backup-minio-logical ${test_dir}/conf/restore-pitr.yml
wait_restore backup-minio-logical ${target_cluster}
wait_cluster_consistency "${target_cluster}"
compare_mongo_cmd \
compare_mongos_cmd \
"find" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-replset0.${namespace}" \
"databaseAdmin:databaseAdmin123456@${target_cluster}-mongos.${namespace}" \
"-2nd" \
".svc.cluster.local" \
myApp \
test \
'' \
false \
replset0
test
desc "CASE 2: PASSED"
}

Expand Down
Loading