Skip to content

Commit 0660f32

Browse files
authored
PYTHON-3761 Add e2e testing against Atlas to the search index management API (#1337)
1 parent b8c1364 commit 0660f32

File tree

8 files changed

+260
-17
lines changed

8 files changed

+260
-17
lines changed

.evergreen/config.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ functions:
442442
params:
443443
working_dir: "src"
444444
script: |
445-
set -o xtrace
445+
# Disable xtrace
446+
set +x
446447
if [ -n "${set_xtrace_on}" ]; then
447448
export SET_XTRACE_ON="${set_xtrace_on}"
448449
fi
@@ -488,6 +489,12 @@ functions:
488489
export SINGLE_MONGOS_LB_URI="${MONGODB_URI}"
489490
export MULTI_MONGOS_LB_URI="${MONGODB_URI}"
490491
fi
492+
if [ -n "${TEST_INDEX_MANAGEMENT}" ]; then
493+
export TEST_INDEX_MANAGEMENT=1
494+
export MONGODB_URI="${TEST_INDEX_URI}"
495+
export DB_USER="${DRIVERS_ATLAS_LAMBDA_USER}"
496+
export DB_PASSWORD="${DRIVERS_ATLAS_LAMBDA_PASSWORD}"
497+
fi
491498
492499
export PYTHON_BINARY=${PYTHON_BINARY}
493500
if [ -z "$PYTHON_BINARY" ]; then
@@ -1293,6 +1300,46 @@ task_groups:
12931300
tasks:
12941301
- testazurekms-task
12951302

1303+
- name: test_atlas_task_group_search_indexes
1304+
setup_group:
1305+
- func: fetch source
1306+
- func: prepare resources
1307+
- func: fix absolute paths
1308+
- func: make files executable
1309+
- command: subprocess.exec
1310+
params:
1311+
working_dir: src
1312+
binary: bash
1313+
add_expansions_to_env: true
1314+
env:
1315+
MONGODB_VERSION: "7.0"
1316+
args:
1317+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
1318+
- command: expansions.update
1319+
params:
1320+
file: src/atlas-expansion.yml
1321+
- command: shell.exec
1322+
params:
1323+
working_dir: src
1324+
shell: bash
1325+
script: |-
1326+
echo "TEST_INDEX_URI: ${MONGODB_URI}" > atlas-expansion.yml
1327+
- command: expansions.update
1328+
params:
1329+
file: src/atlas-expansion.yml
1330+
teardown_group:
1331+
- command: subprocess.exec
1332+
params:
1333+
working_dir: src
1334+
binary: bash
1335+
add_expansions_to_env: true
1336+
args:
1337+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
1338+
setup_group_can_fail_task: true
1339+
setup_group_timeout_secs: 1800
1340+
tasks:
1341+
- test-search-index-helpers
1342+
12961343
tasks:
12971344
# Wildcard task. Do you need to find out what tools are available and where?
12981345
# Throw it here, and execute this task on all buildvariants
@@ -1666,6 +1713,16 @@ tasks:
16661713
TOPOLOGY: "server"
16671714
- func: "run enterprise auth tests"
16681715

1716+
- name: "test-search-index-helpers"
1717+
commands:
1718+
- func: "bootstrap mongo-orchestration"
1719+
vars:
1720+
VERSION: "latest"
1721+
TOPOLOGY: "replica_set"
1722+
- func: "run tests"
1723+
vars:
1724+
TEST_INDEX_MANAGEMENT: "1"
1725+
16691726
- name: "mod-wsgi-standalone"
16701727
tags: ["mod_wsgi"]
16711728
commands:
@@ -3103,6 +3160,14 @@ buildvariants:
31033160
tasks:
31043161
- name: "test-enterprise-auth"
31053162

3163+
- matrix_name: "test-search-index-helpers"
3164+
matrix_spec:
3165+
platform: rhel8
3166+
python-version: "3.8"
3167+
display_name: "Search Index Helpers ${platform}"
3168+
tasks:
3169+
- name: "test_atlas_task_group_search_indexes"
3170+
31063171
- matrix_name: "tests-mod-wsgi"
31073172
matrix_spec:
31083173
platform: ubuntu-20.04

.evergreen/run-tests.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
164164
fi
165165
fi
166166

167+
if [ -n "$TEST_INDEX_MANAGEMENT" ]; then
168+
TEST_ARGS="test/test_index_management.py"
169+
fi
170+
167171
if [ -n "$TEST_DATA_LAKE" ] && [ -z "$TEST_ARGS" ]; then
168172
TEST_ARGS="test/test_data_lake.py"
169173
fi
@@ -190,7 +194,7 @@ if [ -z "$GREEN_FRAMEWORK" ]; then
190194
python -c "from bson import _cbson; from pymongo import _cmessage"
191195
fi
192196

193-
python -m pytest $TEST_ARGS
197+
python -m pytest -v $TEST_ARGS
194198
else
195199
python -m pip install $GREEN_FRAMEWORK
196200
python green_framework_test.py $GREEN_FRAMEWORK

test/index_management/createSearchIndex.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
}
5555
},
5656
"expectError": {
57-
"isError": true
57+
"isError": true,
58+
"errorContains": "Search index commands are only supported with Atlas"
5859
}
5960
}
6061
],
@@ -100,7 +101,8 @@
100101
}
101102
},
102103
"expectError": {
103-
"isError": true
104+
"isError": true,
105+
"errorContains": "Search index commands are only supported with Atlas"
104106
}
105107
}
106108
],

test/index_management/createSearchIndexes.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"models": []
4949
},
5050
"expectError": {
51-
"isError": true
51+
"isError": true,
52+
"errorContains": "Search index commands are only supported with Atlas"
5253
}
5354
}
5455
],
@@ -87,7 +88,8 @@
8788
]
8889
},
8990
"expectError": {
90-
"isError": true
91+
"isError": true,
92+
"errorContains": "Search index commands are only supported with Atlas"
9193
}
9294
}
9395
],
@@ -135,7 +137,8 @@
135137
]
136138
},
137139
"expectError": {
138-
"isError": true
140+
"isError": true,
141+
"errorContains": "Search index commands are only supported with Atlas"
139142
}
140143
}
141144
],

test/index_management/dropSearchIndex.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"name": "test index"
4949
},
5050
"expectError": {
51-
"isError": true
51+
"isError": true,
52+
"errorContains": "Search index commands are only supported with Atlas"
5253
}
5354
}
5455
],

test/index_management/listSearchIndexes.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"name": "listSearchIndexes",
4646
"object": "collection0",
4747
"expectError": {
48-
"isError": true
48+
"isError": true,
49+
"errorContains": "Search index commands are only supported with Atlas"
4950
}
5051
}
5152
],
@@ -79,7 +80,8 @@
7980
"name": "test index"
8081
},
8182
"expectError": {
82-
"isError": true
83+
"isError": true,
84+
"errorContains": "Search index commands are only supported with Atlas"
8385
}
8486
}
8587
],
@@ -119,7 +121,8 @@
119121
}
120122
},
121123
"expectError": {
122-
"isError": true
124+
"isError": true,
125+
"errorContains": "Search index commands are only supported with Atlas"
123126
}
124127
}
125128
],

test/index_management/updateSearchIndex.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"definition": {}
5050
},
5151
"expectError": {
52-
"isError": true
52+
"isError": true,
53+
"errorContains": "Search index commands are only supported with Atlas"
5354
}
5455
}
5556
],

0 commit comments

Comments
 (0)