-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
BREAKING CHANGES - Remove Tripod\Mongo\Config::getConnStr, getTransactionLogConnStr - These were public methods but weren't part of the interface. Instead, getDatabase or getCollectionFor<X> should be used. Features - Allow MongoDB connection string to include options - Add missing methods to IConfigInstance - Don't force default connectTimeoutMS if already set in connection string - Correct config instance type in docblocks - Correct Labeller type in MongoGraph - Test against PHP 7.4, MongoDB replica sets - Add test to cover JobBase::getTripodConfig
- Loading branch information
1 parent
d89fdc0
commit 4fa81cc
Showing
26 changed files
with
431 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,155 @@ | ||
version: 2.1 | ||
|
||
jobs: | ||
test: | ||
commands: | ||
setup_replica_set: | ||
parameters: | ||
php_version: | ||
set_name: | ||
type: string | ||
member_hosts: | ||
type: string | ||
docker: | ||
- image: talis/tripod-php:<< parameters.php_version >>-latest | ||
environment: | ||
RESQUE_SERVER: redis | ||
- image: mongo:3.2.21 | ||
name: mongodb | ||
- image: redis:6.2.6 | ||
name: redis | ||
steps: | ||
- checkout | ||
- run: composer install | ||
- run: | ||
name: Setup a replica set | ||
no_output_timeout: "2m" | ||
environment: | ||
RS_NAME: << parameters.set_name >> | ||
MEMBERS: << parameters.member_hosts >> | ||
command: | | ||
IFS=',' read -r -a MEMBERS_ARR \<<<"$MEMBERS" | ||
INITIATOR=${MEMBERS_ARR[0]} | ||
MEMBERS_JS='' | ||
for i in "${!MEMBERS_ARR[@]}"; do | ||
MEMBERS_JS="${MEMBERS_JS}$(printf '{ _id: %d, host: "%s" },' $i "${MEMBERS_ARR[$i]}")" | ||
done | ||
MONGO_CLI="$(command -v mongosh mongo | head -n1)" | ||
_mongo() { "$MONGO_CLI" --quiet --host "$@"; } | ||
for member in "${MEMBERS_ARR[@]}"; do | ||
echo "Waiting for $member" | ||
until _mongo "$member" \<<<'db.adminCommand("ping")' | grep 'ok'; do | ||
sleep 1 | ||
done | ||
done | ||
echo "Initiating replica set $RS_NAME..." | ||
_mongo "$INITIATOR" \<<<"$(printf 'rs.initiate({ _id: "%s", members: [%s] })' "$RS_NAME" "$MEMBERS_JS")" | tee /dev/stderr | grep -E 'ok|already initialized' | ||
echo "Waiting for primary..." | ||
_mongo "$INITIATOR" \<<<'while (true) { if (rs.status().members.some(({ state }) => state === 1)) { break; } sleep(1000); }' | ||
echo "Waiting for secondaries..." | ||
_mongo "$INITIATOR" \<<<'while (true) { if (rs.status().members.every(({state}) => state == 1 || state == 2)) { break; } sleep(1000); }' | ||
echo "Checking status..." | ||
_mongo "$INITIATOR" \<<<'rs.status();' | tee /dev/stderr | grep "$RS_NAME" | ||
echo "Replica set configured!" | ||
check_mongodb_lib_version: | ||
steps: | ||
- run: | ||
name: Check mongodb ext+lib parity | ||
command: | | ||
php -r 'echo phpversion("mongodb"), PHP_EOL;' | ||
grep '"name": "mongodb/mongodb",' composer.lock -A1 | ||
run_test: | ||
steps: | ||
- run: composer test -- --log-junit test-results/junit.xml | ||
- store_test_results: | ||
path: test-results/junit.xml | ||
- store_artifacts: | ||
path: test-results/junit.xml | ||
|
||
jobs: | ||
test: | ||
parameters: | ||
php_version: { type: string } | ||
mongo_version: { type: string } | ||
docker: | ||
- image: talis/tripod-php:<< parameters.php_version >>-latest | ||
- { name: mongodb, image: mongo:<< parameters.mongo_version >> } | ||
- { name: redis, image: redis:6.2.6 } | ||
environment: | ||
RESQUE_SERVER: redis | ||
steps: | ||
- checkout | ||
- run: composer install | ||
- check_mongodb_lib_version | ||
- run_test | ||
|
||
test-multiple-stores: | ||
docker: | ||
- image: talis/tripod-php:php74-latest | ||
- { name: mongo1, image: mongo:4.4.29 } | ||
- { name: mongo2, image: mongo:5.0.28 } | ||
- { name: redis, image: redis:6.2.6 } | ||
environment: | ||
RESQUE_SERVER: redis | ||
TRIPOD_DATASOURCE_RS1_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo1:27017/", "replicaSet":""} | ||
TRIPOD_DATASOURCE_RS2_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo2:27017/", "replicaSet":""} | ||
steps: | ||
- checkout | ||
- run: composer install | ||
- check_mongodb_lib_version | ||
- run_test | ||
|
||
test-replica-set-mmap: | ||
docker: | ||
- image: talis/tripod-php:php74-latest | ||
- { name: mongo1, image: mongo:3.6.23, command: mongod --storageEngine mmapv1 --smallfiles --replSet=tripod-rs } | ||
- { name: mongo2, image: mongo:3.6.23, command: mongod --storageEngine mmapv1 --smallfiles --replSet=tripod-rs } | ||
- { name: redis, image: redis:6.2.6 } | ||
environment: | ||
RESQUE_SERVER: redis | ||
TRIPOD_DATASOURCE_RS1_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo1,mongo2/?retryWrites=false", "replicaSet":"tripod-rs"} | ||
TRIPOD_DATASOURCE_RS2_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo1,mongo2/?retryWrites=false", "replicaSet":"tripod-rs"} | ||
steps: | ||
- checkout | ||
- setup_replica_set: | ||
set_name: tripod-rs | ||
member_hosts: mongo1,mongo2 | ||
- run: composer install | ||
- check_mongodb_lib_version | ||
- run_test | ||
|
||
test-replica-set-wiredtiger: | ||
docker: | ||
- image: talis/tripod-php:php74-latest | ||
- { name: mongo1, image: mongo:5.0.28, command: mongod --replSet=tripod-rs } | ||
- { name: mongo2, image: mongo:5.0.28, command: mongod --replSet=tripod-rs } | ||
- { name: redis, image: redis:6.2.6 } | ||
environment: | ||
RESQUE_SERVER: redis | ||
TRIPOD_DATASOURCE_RS1_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo1,mongo2/admin?replicaSet=tripod-rs", "replicaSet":""} | ||
TRIPOD_DATASOURCE_RS2_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongo1,mongo2/admin?replicaSet=tripod-rs", "replicaSet":""} | ||
steps: | ||
- checkout | ||
- setup_replica_set: | ||
set_name: tripod-rs | ||
member_hosts: mongo1,mongo2 | ||
- run: composer install | ||
- check_mongodb_lib_version | ||
- run_test | ||
|
||
workflows: | ||
build_and_test: | ||
jobs: | ||
- test: | ||
matrix: | ||
parameters: | ||
php_version: | ||
- php55 | ||
- php73 | ||
name: test-php55 | ||
php_version: php55 | ||
mongo_version: 3.2.21 | ||
- test: | ||
name: test-php73 | ||
php_version: php73 | ||
mongo_version: 3.6.23 | ||
- test: | ||
name: test-php74 | ||
php_version: php74 | ||
mongo_version: 4.0.28 | ||
- test-multiple-stores | ||
- test-replica-set-mmap | ||
- test-replica-set-wiredtiger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# An override file to test Tripod on multiple clusters. | ||
# Usage: | ||
# docker compose -f docker-compose.yml -f docker-compose.clusters.yml run --rm -it php74 vendor/bin/phpunit | ||
|
||
services: | ||
php74: | ||
depends_on: | ||
- mongodb2 | ||
environment: | ||
TRIPOD_DATASOURCE_RS1_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongodb:27017/", "replicaSet":""} | ||
TRIPOD_DATASOURCE_RS2_CONFIG: | | ||
{"type":"mongo", "connection":"mongodb://mongodb2:27017/", "replicaSet":""} | ||
mongodb2: | ||
image: mongo:4.4.29 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
version: "3.7" | ||
|
||
x-base-config: &base-config | ||
volumes: | ||
- ./:/var/tripod-php | ||
- ./vendor:/var/tripod-php/vendor:delegated | ||
links: | ||
- "mongo32:mongodb" | ||
- redis | ||
depends_on: | ||
- mongo32 | ||
- mongodb | ||
- redis | ||
working_dir: /var/tripod-php | ||
env_file: .env | ||
|
||
services: | ||
php55: | ||
# build: | ||
# context: ./docker | ||
# dockerfile: Dockerfile-php55 | ||
build: | ||
context: ./docker | ||
dockerfile: Dockerfile-php55 | ||
image: talis/tripod-php:php55-latest | ||
<<: *base-config | ||
|
||
php73: | ||
# build: | ||
# context: ./docker | ||
# dockerfile: Dockerfile-php73 | ||
build: | ||
context: ./docker | ||
dockerfile: Dockerfile-php73 | ||
image: talis/tripod-php:php73-latest | ||
<<: *base-config | ||
|
||
mongo32: | ||
image: mongo:3.2.21 | ||
php74: | ||
build: | ||
context: ./docker | ||
dockerfile: Dockerfile-php74 | ||
image: talis/tripod-php:php74-latest | ||
<<: *base-config | ||
|
||
mongodb: | ||
image: mongo:3.6.23 | ||
|
||
redis: | ||
image: redis:6.2.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM php:7.4.33-cli | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
unzip \ | ||
zip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sLo /tmp/mongosh.deb https://downloads.mongodb.com/compass/mongodb-mongosh_2.2.15_amd64.deb \ | ||
&& dpkg -i /tmp/mongosh.deb \ | ||
&& rm /tmp/mongosh.deb | ||
|
||
COPY --from=mlocati/php-extension-installer:2.3.2 /usr/bin/install-php-extensions /usr/local/bin/ | ||
COPY --from=composer:2.7.7 /usr/bin/composer /usr/local/bin/ | ||
|
||
RUN install-php-extensions pcntl mongodb-1.19.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.