Skip to content

Commit d4170f7

Browse files
alcaeusjmikola
andauthored
PHPC-2356: Remove explicit env variables (#1514)
* Remove evergreen expansions from shell.exec commands * Remove 5.0 OCSP tasks from Debian 11 * Refactor retrieving Atlas Connectivity URLs * Read encrypted URI list from environment * Remove obsolete file from gitignore * Refactor appending test specific URI options * Update tests/utils/skipif.php Co-authored-by: Jeremy Mikola <jmikola@gmail.com> --------- Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
1 parent a304fbe commit d4170f7

File tree

9 files changed

+65
-33
lines changed

9 files changed

+65
-33
lines changed

.evergreen/atlas-uris.txt.enc

-2.33 KB
Binary file not shown.

.evergreen/config/functions.yml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,19 @@ functions:
167167
"bootstrap mongo-orchestration":
168168
- command: shell.exec
169169
params:
170+
include_expansions_in_env:
171+
- MONGODB_VERSION
172+
- TOPOLOGY
173+
- AUTH
174+
- SSL
175+
- STORAGE_ENGINE
176+
- LOAD_BALANCER
177+
- REQUIRE_API_VERSION
178+
- ORCHESTRATION_FILE
170179
script: |
171180
${PREPARE_SHELL}
172-
SKIP_LEGACY_SHELL=true MONGODB_VERSION=${MONGODB_VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} LOAD_BALANCER=${LOAD_BALANCER} REQUIRE_API_VERSION=${REQUIRE_API_VERSION} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
181+
SKIP_LEGACY_SHELL=true \
182+
sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
173183
# run-orchestration generates expansion file with MONGODB_URI and CRYPT_SHARED_LIB_PATH
174184
- command: expansions.update
175185
params:
@@ -185,28 +195,32 @@ functions:
185195
"run OCSP responder":
186196
- command: shell.exec
187197
params:
198+
include_expansions_in_env:
199+
- TEST_COLUMN
200+
- CERT_TYPE
201+
- USE_DELEGATE
188202
shell: bash
189203
script: |
190204
${PREPARE_SHELL}
191-
TEST_COLUMN=${TEST_COLUMN} \
192-
CERT_TYPE=${CERT_TYPE} \
193-
USE_DELEGATE=${USE_DELEGATE} \
194205
${PROJECT_DIRECTORY}/.evergreen/run-ocsp-responder.sh
195206
196207
"run tests":
197208
- command: shell.exec
198209
type: test
199210
params:
211+
include_expansions_in_env:
212+
- API_VERSION
213+
- ATLAS_CONNECTIVITY_URIS
214+
- CRYPT_SHARED_LIB_PATH
215+
- MONGODB_URI
216+
- APPEND_URI
217+
- SKIP_CRYPT_SHARED
218+
- SSL
219+
- SSL_DIR
220+
- TESTS
200221
working_dir: "src"
201222
script: |
202223
${PREPARE_SHELL}
203-
API_VERSION=${API_VERSION} \
204-
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
205-
MONGODB_URI="${MONGODB_URI}${APPEND_URI}" \
206-
SKIP_CRYPT_SHARED=${SKIP_CRYPT_SHARED} \
207-
SSL=${SSL} \
208-
SSL_DIR=${SSL_DIR} \
209-
TESTS=${TESTS} \
210224
sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
211225
212226
"cleanup":
@@ -242,12 +256,6 @@ functions:
242256
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
243257
[ -f "$file" ] && sh $file || echo "$file not available, skipping"
244258
245-
"decrypt atlas URI list":
246-
- command: shell.exec
247-
params:
248-
script: |
249-
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
250-
251259
"start load balancer":
252260
- command: shell.exec
253261
params:

.evergreen/config/test-tasks.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ tasks:
22
- name: "test-atlas-connectivity"
33
tags: ["atlas", "nodb"]
44
commands:
5-
- func: "decrypt atlas URI list"
65
- func: "run tests"
76
vars:
87
TESTS: "tests/atlas.phpt"

.evergreen/config/test-variants.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildvariants:
1919
- ".sharded .local !.3.6 !.4.0 !.4.2 !.4.4 !.5.0"
2020
- ".loadbalanced .local !.3.6 !.4.0 !.4.2 !.4.4 !.5.0"
2121
- "test-atlas-connectivity"
22-
- ".ocsp !.4.4"
22+
- ".ocsp !.4.4 !.5.0"
2323
display_tasks:
2424
- name: "test-ocsp-latest"
2525
execution_tasks:

.evergreen/run-tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -o errexit # Exit the script with error if any of the commands fail
55
API_VERSION=${API_VERSION:-} # Optional API_VERSION environment variable for run-tests.php
66
CRYPT_SHARED_LIB_PATH="${CRYPT_SHARED_LIB_PATH:-}" # Optional path to crypt_shared library
77
MONGODB_URI=${MONGODB_URI:-} # Connection string (including credentials and topology info)
8+
APPEND_URI=${APPEND_URI:-} # Additional URI options to append to the URI. Used in OCSP tests
89
SKIP_CRYPT_SHARED="${SKIP_CRYPT_SHARED:-no}" # Specify "yes" to ignore CRYPT_SHARED_LIB_PATH. Defaults to "no"
910
SSL=${SSL:-no} # Specify "yes" to enable SSL. Defaults to "no"
1011
SSL_DIR=${SSL_DIR-} # Optional SSL_DIR environment variable for run-tests.php
@@ -15,6 +16,9 @@ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
1516

1617
export REPORT_EXIT_STATUS=1
1718

19+
# Append test-specific URI options
20+
MONGODB_URI=${MONGODB_URI}${APPEND_URI}
21+
1822
# Determine if MONGODB_URI already has a query string
1923
SUFFIX=$(echo "$MONGODB_URI" | grep -Eo "\?(.*)" | cat)
2024

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ php.ini
5252
!.github/
5353
!tests/utils/*.php
5454
!.evergreen
55-
.evergreen/atlas-uris.txt
5655

5756

5857
!scripts

tests/atlas.phpt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
--TEST--
22
Atlas Connectivity Tests
33
--SKIPIF--
4-
<?php
5-
if (!file_exists('.evergreen/atlas-uris.txt')) { echo "skip Atlas URIs not found\n"; }
6-
if (filesize('.evergreen/atlas-uris.txt') < 10) { echo "skip Atlas URI file empty\n"; }
7-
if (getenv('TESTS') !== 'tests/atlas.phpt') { echo "skip Atlas tests not wanted\n"; }
8-
?>
4+
<?php require __DIR__ . "/utils/basic-skipif.inc"; ?>
5+
<?php skip_if_no_atlas_connectivity_urls(); ?>
6+
<?php if (getenv('TESTS') !== 'tests/atlas.phpt') { die('skip Atlas tests not wanted'); } ?>
97
--FILE--
108
<?php
11-
$urls = explode("\n", file_get_contents('.evergreen/atlas-uris.txt'));
9+
require_once __DIR__ . "/utils/basic.inc";
1210

1311
$command = new \MongoDB\Driver\Command(['ping' => 1]);
1412
$query = new \MongoDB\Driver\Query([]);
1513

16-
foreach ($urls as $url) {
17-
$url = trim($url);
18-
19-
if ($url == '') {
20-
continue;
21-
}
22-
14+
foreach (getAtlasConnectivityUrls() as $url) {
2315
if (strpos($url, '#') === 0) {
2416
echo trim(substr($url, 1)), "\n";
2517
continue;

tests/utils/skipif.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,10 @@ function skip_if_no_crypt_shared()
494494
exit('skip crypt_shared is not available');
495495
}
496496
}
497+
498+
function skip_if_no_atlas_connectivity_urls()
499+
{
500+
if (getAtlasConnectivityUrls() === []) {
501+
exit('skip No Atlas URIs found');
502+
}
503+
}

tests/utils/tools.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,3 +853,26 @@ function failGetMore(Manager $manager)
853853

854854
throw new Exception("Trying to configure a getMore fail point for a server version ($version) that doesn't support it");
855855
}
856+
857+
function getAtlasConnectivityUrls(): array
858+
{
859+
$atlasUriString = getenv('ATLAS_CONNECTIVITY_URIS') ?: '';
860+
if (!$atlasUriString) {
861+
return [];
862+
}
863+
864+
$rawUrls = explode("\n", $atlasUriString);
865+
866+
$urls = [];
867+
foreach ($rawUrls as $url) {
868+
$url = trim($url);
869+
870+
if ($url == '') {
871+
continue;
872+
}
873+
874+
$urls[] = $url;
875+
}
876+
877+
return $urls;
878+
}

0 commit comments

Comments
 (0)