Skip to content

Commit e37063d

Browse files
committed
Merge pull request #1260
2 parents 6eaa91b + cfac8b8 commit e37063d

File tree

88 files changed

+1048
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1048
-274
lines changed

.evergreen/config.yml

+44-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ functions:
385385
working_dir: "src"
386386
script: |
387387
${PREPARE_SHELL}
388-
API_VERSION=${API_VERSION} TESTS=${TESTS} SSL=${SSL} MONGODB_URI="${MONGODB_URI}${APPEND_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
388+
MOCK_SERVICE_ID=${MOCK_SERVICE_ID} API_VERSION=${API_VERSION} TESTS=${TESTS} SSL=${SSL} MONGODB_URI="${MONGODB_URI}${APPEND_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
389389
390390
"cleanup":
391391
- command: shell.exec
@@ -445,6 +445,24 @@ functions:
445445
script: |
446446
openssl aes-256-cbc -S "${encrypted_uris_salt}" -K "${encrypted_uris_key}" -iv "${encrypted_uris_iv}" -in ${PROJECT_DIRECTORY}/.evergreen/atlas-uris.txt.enc -out ${PROJECT_DIRECTORY}/.evergreen/atlas-uris.txt -d
447447
448+
"start load balancer":
449+
- command: shell.exec
450+
params:
451+
script: |
452+
MONGODB_URI="${MONGODB_URI}" ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh start
453+
- command: expansions.update
454+
params:
455+
file: lb-expansion.yml
456+
457+
"stop load balancer":
458+
- command: shell.exec
459+
params:
460+
script: |
461+
# Only run if a load balancer was started
462+
if [ -n "${SINGLE_MONGOS_LB_URI}" ]; then
463+
${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
464+
fi
465+
448466
pre:
449467
- func: "fetch source"
450468
- func: "prepare resources"
@@ -458,6 +476,7 @@ post:
458476
- func: "upload working dir"
459477
- func: "upload mo artifacts"
460478
- func: "upload test results"
479+
- func: "stop load balancer"
461480
- func: "stop mongo-orchestration"
462481
- func: "cleanup"
463482

@@ -583,6 +602,24 @@ tasks:
583602
vars:
584603
TESTS: "tests/atlas.phpt"
585604

605+
- name: "test-loadBalanced"
606+
tags: ["loadbalanced"]
607+
commands:
608+
- func: "compile driver"
609+
- func: "bootstrap mongo-orchestration"
610+
vars:
611+
TOPOLOGY: "sharded_cluster"
612+
SSL: "yes"
613+
- func: "start load balancer"
614+
- func: "run tests"
615+
vars:
616+
# Testing with HAProxy requires service ID mocking
617+
MOCK_SERVICE_ID: 1
618+
# Note: loadBalanced=true should already be appended to SINGLE_MONGOS_LB_URI
619+
MONGODB_URI: "${SINGLE_MONGOS_LB_URI}"
620+
SSL: "yes"
621+
# Note: "stop load balancer" will be called from "post"
622+
586623
- name: "test-requireApiVersion"
587624
tags: ["versioned_api"]
588625
commands:
@@ -1218,3 +1255,9 @@ buildvariants:
12181255
display_name: "Versioned API - ${versions}"
12191256
tasks:
12201257
- name: "test-requireApiVersion"
1258+
1259+
- matrix_name: "test-loadBalanced"
1260+
matrix_spec: { "os-php7": "debian92-test", "versions": ["5.0", "latest"], "php-versions": "7.3" }
1261+
display_name: "Load balanced - ${versions}"
1262+
tasks:
1263+
- name: "test-loadBalanced"

.evergreen/run-tests.sh

+16-7
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,40 @@
22
set -o errexit # Exit the script with error if any of the commands fail
33

44
# Supported/used environment variables:
5-
# SSL Set to enable SSL. Defaults to "nossl"
6-
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
5+
# SSL Set to "yes" to enable SSL. Defaults to "nossl"
6+
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
7+
# TESTS Optional TESTS environment variable for run-tests.php
8+
# API_VERSION Optional API_VERSION environment variable for run-tests.php
9+
# MOCK_SERVICE_ID Set to "1" to enable service ID mocking for load balancers. Defaults to empty string.
710

8-
9-
AUTH=${AUTH:-noauth}
1011
SSL=${SSL:-nossl}
1112
MONGODB_URI=${MONGODB_URI:-}
1213
TESTS=${TESTS:-}
1314
API_VERSION=${API_VERSION:-}
15+
MOCK_SERVICE_ID=${MOCK_SERVICE_ID:-}
1416

1517
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
1618
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
1719

1820
export REPORT_EXIT_STATUS=1
1921

22+
# Determine if MONGODB_URI already has a query string
23+
SUFFIX=$(echo "$MONGODB_URI" | grep -Eo "\?(.*)" | cat)
24+
2025
if [ "$SSL" = "yes" ]; then
21-
MONGODB_URI="${MONGODB_URI}/?ssl=true&sslallowinvalidcertificates=true"
26+
if [ -z "$SUFFIX" ]; then
27+
MONGODB_URI="${MONGODB_URI}/?ssl=true&sslallowinvalidcertificates=true"
28+
else
29+
MONGODB_URI="${MONGODB_URI}&ssl=true&sslallowinvalidcertificates=true"
30+
fi
2231
fi
2332

24-
echo "Running $AUTH tests, connecting to $MONGODB_URI"
33+
echo "Running tests with URI: $MONGODB_URI"
2534

2635
# Run the tests, and store the results in a junit result file
2736
case "$OS" in
2837
*)
29-
API_VERSION="${API_VERSION}" TEST_PHP_JUNIT="${PROJECT_DIRECTORY}/test-results.xml" TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test TESTS=$TESTS
38+
MOCK_SERVICE_ID="${MOCK_SERVICE_ID}" API_VERSION="${API_VERSION}" TEST_PHP_JUNIT="${PROJECT_DIRECTORY}/test-results.xml" TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test TESTS=$TESTS
3039
;;
3140
esac
3241

config.m4

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ if test "$PHP_MONGODB" != "no"; then
106106
src/bson.c \
107107
src/bson-encode.c \
108108
src/phongo_apm.c \
109+
src/phongo_ini.c \
109110
src/BSON/Binary.c \
110111
src/BSON/BinaryInterface.c \
111112
src/BSON/DBPointer.c \

config.w32

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ if (PHP_MONGODB != "no") {
118118
var PHP_MONGODB_MONGOC_SOURCES="mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-generation-map.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-openssl.c mongoc-optional.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c";
119119

120120
EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
121-
MONGODB_ADD_SOURCES("/src", "bson.c bson-encode.c phongo_apm.c");
121+
MONGODB_ADD_SOURCES("/src", "bson.c bson-encode.c phongo_apm.c phongo_ini.c");
122122
MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c");
123123
MONGODB_ADD_SOURCES("/src/MongoDB", "BulkWrite.c ClientEncryption.c Command.c Cursor.c CursorId.c CursorInterface.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c ServerApi.c Session.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c");
124124
MONGODB_ADD_SOURCES("/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c CommandException.c ConnectionException.c ConnectionTimeoutException.c EncryptionException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c");

phongo_compat.h

+13
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@
169169
} while (0)
170170
#endif /* PHP_VERSION_ID < 70300 */
171171

172+
#if PHP_VERSION_ID < 70300
173+
static inline zend_bool zend_ini_parse_bool(zend_string* str)
174+
{
175+
if (zend_string_equals_literal_ci(str, "true") ||
176+
zend_string_equals_literal_ci(str, "yes") ||
177+
zend_string_equals_literal_ci(str, "on")) {
178+
return 1;
179+
} else {
180+
return atoi(ZSTR_VAL(str)) != 0;
181+
}
182+
}
183+
#endif /* PHP_VERSION_ID < 70300 */
184+
172185
/* Compatibility macros to override error handling logic */
173186
#define PHONGO_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
174187
do { \

0 commit comments

Comments
 (0)