Skip to content

Commit 510c1c3

Browse files
authored
CDRIVER-4134 Use simple HTTP server for /http tests (#1237)
* Add simple_http_server.py script for /http tests * Add missing package requirement "packaging" * Use simple HTTP server for /http tests * Reuse result of find_python3 across config
1 parent 4c32173 commit 510c1c3

File tree

13 files changed

+306
-55
lines changed

13 files changed

+306
-55
lines changed

.evergreen/config_generator/components/funcs/fetch_det.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from shrub.v3.evg_command import EvgCommandType
2+
from shrub.v3.evg_command import expansions_update
23

34
from config_generator.etc.function import Function
45
from config_generator.etc.utils import bash_exec
@@ -15,6 +16,21 @@ class FetchDET(Function):
1516
fi
1617
''',
1718
),
19+
20+
# python is used frequently enough by many tasks that it is worth
21+
# running find_python3 once here and reusing the result.
22+
bash_exec(
23+
command_type=EvgCommandType.SETUP,
24+
script='''\
25+
set -o errexit
26+
. drivers-evergreen-tools/.evergreen/find-python3.sh
27+
echo "PYTHON3_BINARY: $(find_python3)" >|python3_binary.yml
28+
''',
29+
),
30+
expansions_update(
31+
command_type=EvgCommandType.SETUP,
32+
file='python3_binary.yml',
33+
),
1834
]
1935

2036
@classmethod
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from shrub.v3.evg_command import EvgCommandType
2+
3+
from config_generator.etc.function import Function
4+
from config_generator.etc.utils import bash_exec
5+
6+
7+
class RunSimpleHTTPServer(Function):
8+
name = 'run-simple-http-server'
9+
command_type = EvgCommandType.SETUP
10+
commands = [
11+
bash_exec(
12+
command_type=command_type,
13+
background=True,
14+
working_dir='mongoc',
15+
script='''\
16+
set -o errexit
17+
echo "Starting simple HTTP server..."
18+
command -V "${PYTHON3_BINARY}" >/dev/null
19+
"${PYTHON3_BINARY}" .evergreen/scripts/simple_http_server.py
20+
echo "Starting simple HTTP server... done."
21+
''',
22+
),
23+
]
24+
25+
@classmethod
26+
def call(cls, **kwargs):
27+
return cls.default_call(**kwargs)
28+
29+
30+
def functions():
31+
return RunSimpleHTTPServer.defn()

.evergreen/config_generator/etc/sanitizers/test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration
1313
from config_generator.components.funcs.fetch_build import FetchBuild
1414
from config_generator.components.funcs.fetch_det import FetchDET
15+
from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer
1516
from config_generator.components.funcs.run_mock_kms_servers import RunMockKMSServers
1617
from config_generator.components.funcs.run_tests import RunTests
1718

@@ -30,7 +31,10 @@ def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS
3031
MORE_VARS = MORE_VARS if MORE_VARS else {}
3132

3233
for distro_name, compiler, arch, sasl, auths, topologies, server_vers in MATRIX:
33-
tags = [TAG, 'test', distro_name, compiler, f'sasl-{sasl}'] + MORE_COMPILE_TAGS
34+
tags = [
35+
TAG, 'test', distro_name, compiler, f'sasl-{sasl}'
36+
] + MORE_COMPILE_TAGS
37+
3438
test_distro = find_small_distro(distro_name)
3539

3640
compile_vars = []
@@ -77,6 +81,7 @@ def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS
7781
test_commands.append(expansions_update(updates=updates))
7882
test_commands.append(FetchDET.call())
7983
test_commands.append(BootstrapMongoOrchestration.call())
84+
test_commands.append(RunSimpleHTTPServer.call())
8085

8186
if 'cse' in MORE_COMPILE_TAGS:
8287
test_commands.append(RunMockKMSServers.call())

.evergreen/config_generator/etc/sasl/test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration
1313
from config_generator.components.funcs.fetch_build import FetchBuild
1414
from config_generator.components.funcs.fetch_det import FetchDET
15+
from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer
1516
from config_generator.components.funcs.run_tests import RunTests
1617

1718

@@ -56,6 +57,7 @@ def generate_test_tasks(SSL, TAG, MATRIX):
5657
test_commands.append(expansions_update(updates=updates))
5758
test_commands.append(FetchDET.call())
5859
test_commands.append(BootstrapMongoOrchestration.call())
60+
test_commands.append(RunSimpleHTTPServer.call())
5961
test_commands.append(RunTests.call())
6062

6163
res.append(

.evergreen/config_generator/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-e git+https://github.com/mongodb-labs/drivers-evergreen-tools#egg=evergreen_config_generator&subdirectory=evergreen_config_generator
22
git-url-parse==1.2.2
3+
packaging==23.1
34
pbr==5.11.1
45
pydantic==1.10.4
56
PyYAML==5.4.1

.evergreen/generated_configs/functions.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ functions:
173173
if [[ ! -d drivers-evergreen-tools ]]; then
174174
git clone --depth=1 [email protected]:mongodb-labs/drivers-evergreen-tools.git
175175
fi
176+
- command: subprocess.exec
177+
type: setup
178+
params:
179+
binary: bash
180+
args:
181+
- -c
182+
- |
183+
set -o errexit
184+
. drivers-evergreen-tools/.evergreen/find-python3.sh
185+
echo "PYTHON3_BINARY: $(find_python3)" >|python3_binary.yml
186+
- command: expansions.update
187+
type: setup
188+
params:
189+
file: python3_binary.yml
176190
fetch-source:
177191
- command: git.get_project
178192
type: setup
@@ -318,6 +332,21 @@ functions:
318332
python -u kms_kmip_server.py &
319333
deactivate
320334
echo "Starting mock KMS TLS servers... done."
335+
run-simple-http-server:
336+
- command: subprocess.exec
337+
type: setup
338+
params:
339+
binary: bash
340+
working_dir: mongoc
341+
background: true
342+
args:
343+
- -c
344+
- |
345+
set -o errexit
346+
echo "Starting simple HTTP server..."
347+
command -V "${PYTHON3_BINARY}" >/dev/null
348+
"${PYTHON3_BINARY}" .evergreen/scripts/simple_http_server.py
349+
echo "Starting simple HTTP server... done."
321350
run-tests:
322351
- command: subprocess.exec
323352
type: test

.evergreen/generated_configs/legacy-config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ tasks:
11651165
MONGODB_VERSION: latest
11661166
SSL: openssl
11671167
TOPOLOGY: replica_set
1168+
- func: run-simple-http-server
11681169
- func: fetch-det
11691170
- func: run-mock-kms-servers
11701171
- func: run-tests
@@ -1326,6 +1327,7 @@ tasks:
13261327
AUTH: noauth
13271328
ORCHESTRATION_FILE: zlib
13281329
SSL: nossl
1330+
- func: run-simple-http-server
13291331
- func: run-tests
13301332
vars:
13311333
AUTH: noauth
@@ -1348,6 +1350,7 @@ tasks:
13481350
AUTH: noauth
13491351
ORCHESTRATION_FILE: snappy
13501352
SSL: nossl
1353+
- func: run-simple-http-server
13511354
- func: run-tests
13521355
vars:
13531356
AUTH: noauth
@@ -1370,6 +1373,7 @@ tasks:
13701373
AUTH: noauth
13711374
ORCHESTRATION_FILE: zstd
13721375
SSL: nossl
1376+
- func: run-simple-http-server
13731377
- func: run-tests
13741378
vars:
13751379
AUTH: noauth
@@ -1394,6 +1398,7 @@ tasks:
13941398
AUTH: noauth
13951399
ORCHESTRATION_FILE: snappy-zlib-zstd
13961400
SSL: nossl
1401+
- func: run-simple-http-server
13971402
- func: run-tests
13981403
vars:
13991404
AUTH: noauth
@@ -1411,6 +1416,7 @@ tasks:
14111416
vars:
14121417
MONGODB_VERSION: latest
14131418
TOPOLOGY: server
1419+
- func: run-simple-http-server
14141420
- func: run-tests
14151421
vars:
14161422
URI: mongodb://localhost/?retryWrites=true
@@ -1429,6 +1435,7 @@ tasks:
14291435
vars:
14301436
MONGODB_VERSION: latest
14311437
TOPOLOGY: server
1438+
- func: run-simple-http-server
14321439
- func: run-tests
14331440
vars:
14341441
URI: null
@@ -1556,6 +1563,7 @@ tasks:
15561563
REQUIRE_API_VERSION: 'true'
15571564
SSL: ssl
15581565
TOPOLOGY: server
1566+
- func: run-simple-http-server
15591567
- func: run-tests
15601568
vars:
15611569
AUTH: auth
@@ -1578,6 +1586,7 @@ tasks:
15781586
ORCHESTRATION_FILE: versioned-api-testing
15791587
SSL: nossl
15801588
TOPOLOGY: server
1589+
- func: run-simple-http-server
15811590
- func: run-tests
15821591
vars:
15831592
AUTH: noauth
@@ -1718,6 +1727,7 @@ tasks:
17181727
- func: bootstrap-mongo-orchestration
17191728
vars:
17201729
IPV4_ONLY: 'off'
1730+
- func: run-simple-http-server
17211731
- func: run-tests
17221732
vars:
17231733
IPV4_ONLY: 'off'
@@ -1739,6 +1749,7 @@ tasks:
17391749
- func: bootstrap-mongo-orchestration
17401750
vars:
17411751
IPV4_ONLY: 'off'
1752+
- func: run-simple-http-server
17421753
- func: run-tests
17431754
vars:
17441755
IPV4_ONLY: 'off'
@@ -1760,6 +1771,7 @@ tasks:
17601771
- func: bootstrap-mongo-orchestration
17611772
vars:
17621773
IPV4_ONLY: 'on'
1774+
- func: run-simple-http-server
17631775
- func: run-tests
17641776
vars:
17651777
IPV4_ONLY: 'on'
@@ -1781,6 +1793,7 @@ tasks:
17811793
- func: bootstrap-mongo-orchestration
17821794
vars:
17831795
IPV4_ONLY: 'on'
1796+
- func: run-simple-http-server
17841797
- func: run-tests
17851798
vars:
17861799
IPV4_ONLY: 'on'
@@ -8958,6 +8971,7 @@ tasks:
89588971
MONGODB_VERSION: '5.0'
89598972
SSL: ssl
89608973
TOPOLOGY: sharded_cluster
8974+
- func: run-simple-http-server
89618975
- func: start load balancer
89628976
vars:
89638977
MONGODB_URI: mongodb://localhost:27017,localhost:27018
@@ -8985,6 +8999,7 @@ tasks:
89858999
MONGODB_VERSION: latest
89869000
SSL: ssl
89879001
TOPOLOGY: sharded_cluster
9002+
- func: run-simple-http-server
89889003
- func: start load balancer
89899004
vars:
89909005
MONGODB_URI: mongodb://localhost:27017,localhost:27018
@@ -9012,6 +9027,7 @@ tasks:
90129027
MONGODB_VERSION: '5.0'
90139028
SSL: nossl
90149029
TOPOLOGY: sharded_cluster
9030+
- func: run-simple-http-server
90159031
- func: start load balancer
90169032
vars:
90179033
MONGODB_URI: mongodb://localhost:27017,localhost:27018
@@ -9039,6 +9055,7 @@ tasks:
90399055
MONGODB_VERSION: latest
90409056
SSL: nossl
90419057
TOPOLOGY: sharded_cluster
9058+
- func: run-simple-http-server
90429059
- func: start load balancer
90439060
vars:
90449061
MONGODB_URI: mongodb://localhost:27017,localhost:27018

0 commit comments

Comments
 (0)