Skip to content

Commit 4f7ca43

Browse files
nmarukovichhors
authored andcommitted
K8SPSMDB-1216 update to db.hello (#1929)
* K8SPSMDB-1216 update to db.hello * update rs-shard-migration test --------- Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent ac3cc14 commit 4f7ca43

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

e2e-tests/functions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ compare_mongos_cmd() {
971971
get_mongo_primary_endpoint() {
972972
local uri="$1"
973973

974-
run_mongo 'db.isMaster().me' "$uri" "mongodb" ":27017" \
974+
run_mongo 'db.hello().me' "$uri" "mongodb" ":27017" \
975975
| egrep -v "Time|Percona Server for MongoDB|bye|BinData|NumberLong|connecting to|Error saving history file|I NETWORK|W NETWORK|Implicit session:|versions do not match" \
976976
| sed -e 's^20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]^^' \
977977
| grep ":27017$"

e2e-tests/rs-shard-migration/run

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function get_shard_parameter() {
1010
local cluster_name=$1
1111
local namespace=$2
1212
local parameter=${3:-lastCommittedOpTime}
13-
run_mongo 'db.isMaster().'${parameter}'' "clusterAdmin:clusterAdmin123456@${cluster_name}-rs0-0.${cluster_name}-rs0.${namespace}" "mongodb" "" "--quiet" \
13+
run_mongo 'db.hello().'${parameter}'' "clusterAdmin:clusterAdmin123456@${cluster_name}-rs0-0.${cluster_name}-rs0.${namespace}" "mongodb" "" "--quiet" \
1414
| egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:'
1515
}
1616

@@ -59,8 +59,7 @@ function main() {
5959
desc 'write data, read from all'
6060
simple_data_check "${cluster}" "${CLUSTER_SIZE}" 1 "-mongos"
6161

62-
if [[ -z "$(get_shard_parameter ${cluster} ${namespace} lastCommitedOpTime)" ]] \
63-
&& [[ -z "$(get_shard_parameter ${cluster} ${namespace} '$configServerState.opTime.ts')" ]]; then # for mongo 3.6
62+
if [[ -z "$(get_shard_parameter ${cluster} ${namespace} 'lastWrite.majorityOpTime.ts')" ]]; then
6463
echo "Sharded cluster does not work properly"
6564
exit 1
6665
fi

e2e-tests/split-horizon/run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ run_mongo_tls "rs.conf().members.map(function(member) { return member.horizons }
4545
mongodb "" "--quiet" | egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|does not match the remote host name' >${tmp_dir}/horizons-3.json
4646
diff $test_dir/compare/horizons-3.json $tmp_dir/horizons-3.json
4747

48-
isMaster=$(run_mongo_tls "db.isMaster().ismaster" "clusterAdmin:clusterAdmin123456@some-name-rs0-0.clouddemo.xyz,some-name-rs0-1.clouddemo.xyz,some-name-rs0-2.clouddemo.xyz" mongodb "" "--quiet" | egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|does not match the remote host name' | grep -v certificateNames)
48+
isMaster=$(run_mongo_tls "db.hello().isWritablePrimary" "clusterAdmin:clusterAdmin123456@some-name-rs0-0.clouddemo.xyz,some-name-rs0-1.clouddemo.xyz,some-name-rs0-2.clouddemo.xyz" mongodb "" "--quiet" | egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|does not match the remote host name' | grep -v certificateNames)
4949
if [ "${isMaster}" != "true" ]; then
5050
echo "mongo client should've redirect the connection to primary"
5151
exit 1
@@ -58,7 +58,7 @@ run_mongo_tls "rs.stepDown()" \
5858

5959
sleep 10 # give some time for re-election
6060

61-
isMaster=$(run_mongo_tls "db.isMaster().ismaster" "clusterAdmin:clusterAdmin123456@some-name-rs0-0.clouddemo.xyz,some-name-rs0-1.clouddemo.xyz,some-name-rs0-2.clouddemo.xyz" mongodb "" "--quiet" | egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|does not match the remote host name' | grep -v certificateNames)
61+
isMaster=$(run_mongo_tls "db.hello().isWritablePrimary" "clusterAdmin:clusterAdmin123456@some-name-rs0-0.clouddemo.xyz,some-name-rs0-1.clouddemo.xyz,some-name-rs0-2.clouddemo.xyz" mongodb "" "--quiet" | egrep -v 'I NETWORK|W NETWORK|Error saving history file|Percona Server for MongoDB|connecting to:|Unable to reach primary for set|Implicit session:|versions do not match|Error saving history file:|does not match the remote host name' | grep -v certificateNames)
6262
if [ "${isMaster}" != "true" ]; then
6363
echo "mongo client should've redirect the connection to primary"
6464
exit 1

pkg/controller/perconaservermongodbrestore/physical.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ func (r *ReconcilePerconaServerMongoDBRestore) runIsMaster(ctx context.Context,
616616
}
617617

618618
c := strings.Join([]string{
619-
mongoClient, "--quiet", "-u", creds.Username, "-p", creds.Password, "--eval", "'db.isMaster().ismaster'",
619+
mongoClient, "--quiet", "-u", creds.Username, "-p", creds.Password, "--eval", "'db.hello().isWritablePrimary'",
620620
"|", "tail", "-n", "1",
621621
"|", "grep", "-Eo", "'(true|false)'",
622622
}, " ")

0 commit comments

Comments
 (0)