Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active July 2, 2025 12:40
Show Gist options
  • Save sandromello/2d4a67d3addc451ba28d2ab2d3f4ba0f to your computer and use it in GitHub Desktop.
Save sandromello/2d4a67d3addc451ba28d2ab2d3f4ba0f to your computer and use it in GitHub Desktop.
Test Mongo Script

Add test Mongo Scripts into the agent

Open a bash session to the agent and add the following scripts to the /tmp folder

hoop connect bash

cat - > /tmp/mongo1 <<'EOF'
#!/bin/bash

set -eo pipefail

MONGO_BIN=/usr/bin/mongo
$MONGO_BIN $@
EOF

cat - > /tmp/mongo2 <<'EOF'
#!/bin/bash
set -eo pipefail

/usr/bin/mongo $@
EOF

cat - > /tmp/mongo3 <<'EOF'
#!/bin/bash

/usr/bin/mongo $@
EOF

cat - > /tmp/mongo4 <<'EOF'
#!/bin/bash

/usr/bin/mongo "$@"
EOF

cat - > /tmp/mongo5 <<'EOF'
#!/bin/bash

MONGO_BIN=/usr/bin/mongo
$MONGO_BIN "$@"
EOF

chmod +x /tmp/mongo*

Create test Connections for each script

hoop admin create conn mongo1-test -a default --type database/mongodb \
    -e CONNECTION_STRING="" \
    -- /tmp/mongo1 --quiet '$CONNECTION_STRING'

hoop admin create conn mongo2-test -a default --type database/mongodb \
    -e CONNECTION_STRING="" \
    -- /tmp/mongo2 --quiet '$CONNECTION_STRING'

hoop admin create conn mongo3-test -a default --type database/mongodb \
    -e CONNECTION_STRING="" \
    -- /tmp/mongo3 --quiet '$CONNECTION_STRING'

hoop admin create conn mongo4-test -a default --type database/mongodb \
    -e CONNECTION_STRING="" \
    -- /tmp/mongo4 --quiet '$CONNECTION_STRING'

hoop admin create conn mongo5-test -a default --type database/mongodb \
    -e CONNECTION_STRING="" \
    -- /tmp/mongo5 --quiet '$CONNECTION_STRING'
  • Test listing the tables in the editor for each connection and see which one fails

Wipe Tests

hoop admin delete conn mongo1-test
hoop admin delete conn mongo2-test
hoop admin delete conn mongo3-test
hoop admin delete conn mongo4-test
hoop admin delete conn mongo5-test

hoop connect bash
rm -f /tmp/mongo*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment