Skip to content

Commit 6d8b895

Browse files
author
Cloud User
committed
resyncing specs test?
1 parent 65f7c54 commit 6d8b895

File tree

66 files changed

+13728
-1370
lines changed

Some content is hidden

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

66 files changed

+13728
-1370
lines changed

.evergreen/all.patch

Lines changed: 2107 additions & 0 deletions
Large diffs are not rendered by default.

.evergreen/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,22 @@ post:
4242
- func: "upload mo artifacts"
4343
- func: "upload test results"
4444
- func: "cleanup"
45+
46+
tasks:
47+
- name: resync_specs
48+
commands:
49+
- command: subprocess.exec
50+
params:
51+
binary: bash
52+
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN]
53+
args:
54+
- .evergreen/scripts/resync-all-specs.sh
55+
working_dir: src
56+
57+
buildvariants:
58+
- name: resync_specs
59+
display_name: "Resync Specs"
60+
run_on: rhel80-small
61+
patchable: true
62+
tasks:
63+
- name: resync_specs

.evergreen/resync-specs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ then
4545
fi
4646

4747
# Ensure the JSON files are up to date.
48-
cd $SPECS/source
49-
make
50-
cd -
48+
if ! [ -n "${CI:-}" ]
49+
then
50+
cd $SPECS/source
51+
make
52+
cd -
53+
fi
5154
# cpjson unified-test-format/tests/invalid unified-test-format/invalid
5255
# * param1: Path to spec tests dir in specifications repo
5356
# * param2: Path to where the corresponding tests live in Python.

.evergreen/scripts/create-pr.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
tools="../drivers-evergreen-tools"
4+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $tools
5+
body="$(cat "$1")"
6+
7+
pushd $tools/.evergreen/github_app
8+
9+
owner="mongodb"
10+
repo="mongo-python-driver"
11+
12+
# Bootstrap the app.
13+
echo "bootstrapping"
14+
source utils.sh
15+
bootstrap drivers/comment-bot
16+
17+
# Run the app.
18+
source ./secrets-export.sh
19+
20+
# Get a github access token for the git checkout.
21+
echo "Getting github token..."
22+
23+
token=$(bash ./get-access-token.sh $repo $owner)
24+
if [ -z "${token}" ]; then
25+
echo "Failed to get github access token!"
26+
popd
27+
exit 1
28+
fi
29+
echo "Getting github token... done."
30+
popd
31+
32+
# Make the git checkout and create a new branch.
33+
echo "Creating the git checkout..."
34+
branch="spec-resync-"$(date '+%m-%d-%Y')
35+
36+
#git config user.email "167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com"
37+
#git config user.name "mongodb-dbx-release-bot[bot]"
38+
git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git
39+
git checkout -b $branch "origin/master"
40+
git add ./test
41+
git apply -R .evergreen/specs.patch
42+
git commit -am "resyncing specs test?"
43+
echo "Creating the git checkout... done."
44+
45+
echo "THIS IS THE BODY"
46+
echo "$body"
47+
git push origin $branch
48+
echo "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"$(cat "$1")\",\"head\":\"${branch}\",\"base\":\"master\"}"
49+
resp=$(curl -L \
50+
-X POST \
51+
-H "Accept: application/vnd.github+json" \
52+
-H "Authorization: Bearer $token" \
53+
-H "X-GitHub-Api-Version: 2022-11-28" \
54+
-d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"$(cat "$1")\",\"head\":\"${branch}\",\"base\":\"master\"}" \
55+
--url https://api.github.com/repos/$owner/$repo/pulls)
56+
echo $resp
57+
echo $resp | jq '.html_url'
58+
echo "Creating the PR... done."
59+
60+
rm -rf $tools
61+
62+
# use file names or reg-ex patterns
63+
# or automate which version of the spec we support (like schema version)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
import pathlib
3+
import subprocess
4+
5+
print("in resync all specs py")
6+
directory = pathlib.Path("./test")
7+
succeeded: list[str] = []
8+
errored: dict[str, str] = {}
9+
print("right before for loop?")
10+
for entry in os.scandir(directory):
11+
if not entry.is_dir():
12+
continue
13+
14+
print(entry.path)
15+
spec_name = entry.path.split("/")[-1]
16+
if spec_name in ["asynchronous"]:
17+
continue
18+
process = subprocess.run(
19+
["bash", "./.evergreen/resync-specs.sh", spec_name],
20+
capture_output=True,
21+
text=True)
22+
print(process.returncode)
23+
if process.returncode == 0:
24+
succeeded.append(spec_name)
25+
else:
26+
errored[spec_name] = process.stdout
27+
pr_body = ""
28+
if len(succeeded) == 0 and len(errored.keys()) == 0:
29+
# no changes made and no errors
30+
pass
31+
if len(succeeded) > 0:
32+
pr_body += "The following specs were changed:\n- "
33+
pr_body += "\n- ".join(succeeded)
34+
pr_body += "\n"
35+
if len(errored) > 0:
36+
pr_body += "The following spec syncs encountered errors:"
37+
for k, v in errored.items():
38+
# pr_body += f"\n- {k}\n```{v}```"
39+
pr_body += f"\n- {k}"
40+
print("THIS IS PR BODY")
41+
print(pr_body)
42+
43+
with open("spec_sync.txt", "w") as f:
44+
f.write(pr_body.replace("\n", "\\n"))
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env bash
2+
# Run spec syncing script and create PR
3+
SPEC_DEST="$(realpath -s "./test")"
4+
SRC_URL="https://github.com/mongodb/specifications.git"
5+
# needs to be set for resunc-specs.sh
6+
SPEC_SRC="$(realpath -s "../specifications")"
7+
SCRIPT="$(realpath -s "./.evergreen/resync-specs.sh")"
8+
BRANCH_NAME="spec-resync-"$(date '+%m-%d-%Y')
9+
10+
# List of directories to skip
11+
SKIP_DIRECTORIES=("asynchronous" "__pycache__")
12+
# we have a list of specs that we manually override *if the git diff is that specific line, then don't change it
13+
# *ask in python channel
14+
SKIP_FILES=()
15+
# ask steve for how to create PR from evergreen account(?)
16+
# for now, treat it like a command line thing and git add *, git commit, git push
17+
18+
# Clone the repo if the directory does not exist
19+
if [[ ! -d $SPEC_SRC ]]; then
20+
git clone $SRC_URL $SPEC_SRC
21+
if [[ $? -ne 0 ]]; then
22+
echo "Error: Failed to clone repository."
23+
exit 1
24+
fi
25+
fi
26+
27+
# Set environment variable to the cloned repo for resync-specs.sh
28+
export MDB_SPECS="$SPEC_SRC"
29+
30+
# Check that resync script exists and is executable
31+
if [[ ! -x $SCRIPT ]]; then
32+
echo "Error: $SCRIPT not found or is not executable."
33+
exit 1
34+
fi
35+
36+
/opt/devtools/bin/python3.11 ./.evergreen/scripts/resync-all-specs.py
37+
38+
39+
## List to store names of specs that were changed or errored during change
40+
#changed_specs=()
41+
#errored_specs=()
42+
#
43+
## Create branch and switch to it
44+
##git checkout -b $BRANCH_NAME 2>/dev/null || git checkout $BRANCH_NAME
45+
#
46+
#for item in "$SPEC_DEST"/*; do
47+
# item_name=$(basename "$item")
48+
# if [[ " ${SKIP_DIRECTORIES[*]} " =~ ${item_name} ]]; then
49+
# continue
50+
# fi
51+
#
52+
# # Check that item is not a python file
53+
# if [[ $item != *.py ]]; then
54+
# echo " doing $item_name"
55+
# output=$($SCRIPT "$item_name" 2>&1)
56+
# # Check if the script ran successfully
57+
# if [[ $? -ne 0 ]]; then
58+
# echo "an error occurred"
59+
## errored_specs+=("$item_name\n\`\`\`$output\`\`\`\n\n")
60+
# errored_specs+=("$item_name\n")
61+
# fi
62+
# fi
63+
#done
64+
#
65+
## change this to python, call the python script here, then pass it forward to create-pr script.
66+
#
67+
## Output the list of changed specs
68+
#if git diff --quiet && [[ ${#errored_specs[@]} -eq 0 ]]; then
69+
# # no changes made and no errors
70+
# exit 0
71+
#fi
72+
#
73+
#pr_body='Spec sync results:\n\n'
74+
#if ! git diff --quiet; then
75+
# pr_body+="The following specs were changed:\n"
76+
# pr_body+="$(git diff --name-only | awk -F'/' '{print $2}' | sort | uniq | tr '\n' '\\n')"
77+
#fi
78+
#
79+
## Output the list of errored specs
80+
#if [[ ${#errored_specs[@]} -gt 0 ]]; then
81+
# pr_body+="\n\nThe following spec syncs encountered errors:\n"
82+
# for spec in "${errored_specs[@]}"; do
83+
# pr_body+=" - $spec\n"
84+
# done
85+
#else
86+
# pr_body+="\nNo errors were encountered in any specs syncs.\n"
87+
#fi
88+
#
89+
## Output the PR body (optional step for verification)
90+
#echo "PR body"
91+
#echo "$pr_body" | tr '\n' '\\n'
92+
#echo "$pr_body" | tr '\n' '\\n' >> spec_sync.txt
93+
#
94+
#echo "BEGINNING OF DIFF"
95+
#git diff
96+
#echo "END OF DIFF"
97+
#
98+
# call scrypt to create PR for us
99+
.evergreen/scripts/create-pr.sh spec_sync.txt
100+
#
101+
#rm spec_sync.txt
102+
#git add $SPEC_DEST
103+
#git commit -m $BRANCH_NAME
104+
#git push -u origin $BRANCH_NAME
105+
#gh pr create --title "[Spec Resync] $(date '+%m-%d-%Y')" --body "Resyncing specs for review" --base main --head $BRANCH_NAME --draft
106+
107+
# just get it working, we can identify pain points later after we have something to work with

.evergreen/specs.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/test/load_balancer/cursors.json b/test/load_balancer/cursors.json
2+
index 27aaddd5..b11bf2c6 100644
3+
--- a/test/load_balancer/cursors.json
4+
+++ b/test/load_balancer/cursors.json
5+
@@ -385,7 +385,7 @@
6+
]
7+
},
8+
{
9+
- "description": "pinned connections are returned after an network error during getMore",
10+
+ "description": "pinned connections are not returned after an network error during getMore",
11+
"operations": [
12+
{
13+
"name": "failPoint",
14+
@@ -449,7 +449,7 @@
15+
"object": "testRunner",
16+
"arguments": {
17+
"client": "client0",
18+
- "connections": 0
19+
+ "connections": 1
20+
}
21+
},
22+
{
23+
@@ -677,7 +677,7 @@
24+
]
25+
},
26+
{
27+
- "description": "pinned connections are returned to the pool after a non-network error on getMore",
28+
+ "description": "pinned connections are not returned to the pool after a non-network error on getMore",
29+
"operations": [
30+
{
31+
"name": "failPoint",
32+
@@ -733,7 +733,7 @@
33+
"object": "testRunner",
34+
"arguments": {
35+
"client": "client0",
36+
- "connections": 0
37+
+ "connections": 1
38+
}
39+
},
40+
{
41+
diff --git a/test/server_selection_logging/operation-id.json b/test/server_selection_logging/operation-id.json
42+
index ccc26231..72ebff60 100644
43+
--- a/test/server_selection_logging/operation-id.json
44+
+++ b/test/server_selection_logging/operation-id.json
45+
@@ -197,7 +197,7 @@
46+
}
47+
},
48+
{
49+
- "level": "debug",
50+
+ "level": "info",
51+
"component": "serverSelection",
52+
"data": {
53+
"message": "Waiting for suitable server to become available",
54+
@@ -383,7 +383,7 @@
55+
}
56+
},
57+
{
58+
- "level": "debug",
59+
+ "level": "info",
60+
"component": "serverSelection",
61+
"data": {
62+
"message": "Waiting for suitable server to become available",
63+
diff --git a/test/server_selection_logging/replica-set.json b/test/server_selection_logging/replica-set.json
64+
index 830b1ea5..5eba784b 100644
65+
--- a/test/server_selection_logging/replica-set.json
66+
+++ b/test/server_selection_logging/replica-set.json
67+
@@ -184,7 +184,7 @@
68+
}
69+
},
70+
{
71+
- "level": "debug",
72+
+ "level": "info",
73+
"component": "serverSelection",
74+
"data": {
75+
"message": "Waiting for suitable server to become available",
76+
diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/sharded.json
77+
index 346c050f..d42fba91 100644
78+
--- a/test/server_selection_logging/sharded.json
79+
+++ b/test/server_selection_logging/sharded.json
80+
@@ -193,7 +193,7 @@
81+
}
82+
},
83+
{
84+
- "level": "debug",
85+
+ "level": "info",
86+
"component": "serverSelection",
87+
"data": {
88+
"message": "Waiting for suitable server to become available",

test/bson_binary_vector/packed_bit.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
"padding": 3,
3030
"canonical_bson": "1600000005766563746F7200040000000910037F0800"
3131
},
32+
{
33+
"description": "PACKED_BIT with inconsistent padding",
34+
"valid": false,
35+
"vector": [127, 7],
36+
"dtype_hex": "0x10",
37+
"dtype_alias": "PACKED_BIT",
38+
"padding": 3,
39+
"canonical_bson": "1600000005766563746F7200040000000910037F0700"
40+
},
3241
{
3342
"description": "Empty Vector PACKED_BIT",
3443
"valid": true,

test/bson_corpus/datetime.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
{
2525
"description" : "Y10K",
2626
"canonical_bson" : "1000000009610000DC1FD277E6000000",
27+
"relaxed_extjson" : "{\"a\":{\"$date\":{\"$numberLong\":\"253402300800000\"}}}",
2728
"canonical_extjson" : "{\"a\":{\"$date\":{\"$numberLong\":\"253402300800000\"}}}"
2829
},
2930
{

0 commit comments

Comments
 (0)