Skip to content

Commit

Permalink
PMM-12712 Alias for shell in older versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Jan 2, 2024
1 parent 73fe6b7 commit 74745d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ jobs:
- name: Test
run: |
TEST_MONGODB_IMAGE=${{ matrix.image }} make test-cluster
sleep 30
sleep 120
make test-race
make test-cluster-clean
9 changes: 4 additions & 5 deletions docker/scripts/init-shard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ readarray -d . -t verarr <<< "${VERSION}"
readarray -d : -t version <<< "${verarr[0]}"
echo "Mongo version: ${version[1]}"

alias mongoShell="mongo"
if [ ${version[1]} -gt 4 ]
if ((${version[1]} < 4))
then
alias mongoShell="mongosh"
echo -e 'mongo' > /usr/bin/mongosh && chmod +x /usr/bin/mongosh
fi

mongodb1=`getent hosts ${MONGOS} | awk '{ print $1 }'`
Expand All @@ -27,15 +26,15 @@ mongodb33=`getent hosts ${MONGO33} | awk '{ print $1 }'`
port=${PORT:-27017}

echo "Waiting for startup.."
until mongoShell --host ${mongodb1}:${port} --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' &>/dev/null; do
until mongosh --host ${mongodb1}:${port} --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' &>/dev/null; do
printf '.'
sleep 1
done

echo "Started.."

echo init-shard.sh time now: `date +"%T" `
mongoShell --host ${mongodb1}:${port} <<EOF
mongosh --host ${mongodb1}:${port} <<EOF
sh.addShard( "${RS1}/${mongodb11}:${PORT1},${mongodb12}:${PORT2},${mongodb13}:${PORT3}" );
sh.addShard( "${RS2}/${mongodb21}:${PORT1},${mongodb22}:${PORT2},${mongodb23}:${PORT3}" );
sh.status();
Expand Down
11 changes: 5 additions & 6 deletions docker/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ readarray -d . -t verarr <<< "${VERSION}"
readarray -d : -t version <<< "${verarr[0]}"
echo "Mongo version: ${version[1]}"

alias mongoShell="mongo"
if [ ${version[1]} -gt 4 ]
if ((${version[1]} < 4))
then
alias mongoShell="mongosh"
echo -e 'mongo' > /usr/bin/mongosh && chmod +x /usr/bin/mongosh
fi

mongodb1=`getent hosts ${MONGO1} | awk '{ print $1 }'`
Expand All @@ -18,7 +17,7 @@ arbiter=`getent hosts ${ARBITER} | awk '{ print $1 }'`
port=${PORT:-27017}

echo "Waiting for startup.."
until mongoShell --host ${mongodb1}:${port} --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' &>/dev/null; do
until mongosh --host ${mongodb1}:${port} --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' &>/dev/null; do
printf '.'
sleep 1
done
Expand All @@ -30,7 +29,7 @@ echo setup.sh time now: `date +"%T" `

function cnf_servers() {
echo "setup cnf servers"
mongoShell --host ${mongodb1}:${port} <<EOF
mongosh --host ${mongodb1}:${port} <<EOF
var cfg = {
"_id": "${RS}",
"protocolVersion": 1,
Expand All @@ -57,7 +56,7 @@ EOF

function general_servers() {
echo "setup servers"
mongoShell --host ${mongodb1}:${port} <<EOF
mongosh --host ${mongodb1}:${port} <<EOF
var cfg = {
"_id": "${RS}",
"protocolVersion": 1,
Expand Down

0 comments on commit 74745d6

Please sign in to comment.