Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
kevinAlbs / calc_release_version_selftest.sh
Created May 25, 2023 21:50
Proposed self tests of calc_release_version.py
# calc_release_version_selftest.sh is used to test output of calc_release_version.py.
# run with:
# cd build
# ./calc_release_version_selftest.sh
function assert_eq () {
a="$1"
b="$2"
if [[ "$a" != "$b" ]]; then
echo "Assertion failed: $a != $b"
@kevinAlbs
kevinAlbs / validate.py
Created May 21, 2023 14:05
Validate that all tasks in an Evergreen config are used.
import sys
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
# Load evaluated Evergreen config.
# `evaluated.yml` was created by running: `evergreen evaluate ./.evergreen/config.yml > evaluated.yml`
with open("evaluated.yml", "r") as file:
@kevinAlbs
kevinAlbs / getMore-changestream.json
Created March 3, 2023 14:47
Sample change stream reply
{
"cursor": {
"nextBatch": [
{
"_id": {
"_data": "826402082C000000022B042C0100296E5A1004F5EE0D4649F9441FBB3F8068DB145455463C6F7065726174696F6E54797065003C64656C6574650046646F63756D656E744B657900461E5F69640029000004"
},
"operationType": "delete",
"clusterTime": {
@kevinAlbs
kevinAlbs / openssl_static.py
Last active February 8, 2023 19:43
Suggested alternative for OpenSSL static testing. See https://github.com/mongodb/mongo-c-driver/pull/1201
from shrub.v3.evg_build_variant import BuildVariant
from shrub.v3.evg_task import EvgTaskRef
from config_generator.etc.distros import find_large_distro
from config_generator.etc.distros import make_distro_str
from config_generator.etc.distros import to_cc
from config_generator.etc.utils import EvgTaskWithRunOn
from config_generator.etc.sasl.compile import CompileCommon
from config_generator.components.funcs.upload_build import UploadBuild
PR=${PR:-}
REPO=${REPO:-}
ORG=${ORG:-mongodb}
if [[ "$(basename $(pwd))" != "review" ]]; then
echo "Must be in 'review' directory";
exit 1;
fi
if [[ -z "$PR" ]]; then
PR=${PR:-}
REPO=${REPO:-}
ORG=${ORG:-mongodb}
if [[ "$(basename $(pwd))" != "review" ]]; then
echo "Must be in 'review' directory";
exit 1;
fi
if [[ -z "$PR" ]]; then
import sys
import re
contents = sys.stdin.read()
lines = contents.splitlines ()
inraw = False
rawstr = ""
import textwrap
print ("""// This is a copy of test vectors from the mongodb/mongo repository.""")
import sys
import re
contents = sys.stdin.read()
# Here is a sample input:
# contents = """
# {&getEdgesDouble, 0.00000000000000000, boost::none, boost::none, 1, {
# "1",
# "10",
# "100",
@kevinAlbs
kevinAlbs / SSLWrapper.py
Last active July 28, 2022 01:33
A class to wrap an SSLSocket in another SSLObject.
class SSLWrapper:
"""
SSLWrapper wraps an SSLSocket in an SSLObject.
This may be used to tunnel an SSL session inside another SSL session.
Example usage:
sslctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)
ssock = socket.create_connection(("proxy.example", 443))
ssock = sslctx.wrap_socket(ssock, server_hostname="localhost")
@kevinAlbs
kevinAlbs / mongoc-env.sh
Last active January 26, 2022 14:17
A script for loading test CSFLE credentials for C and C++ driver tests.
export MONGOC_TEST_AWS_ACCESS_KEY_ID=$(cat ~/.csfle/kms_providers.json | jq -r ".aws.accessKeyId")
export MONGOC_TEST_AWS_SECRET_ACCESS_KEY=$(cat ~/.csfle/kms_providers.json | jq -r ".aws.secretAccessKey")
export MONGOC_TEST_MONGOCRYPTD_BYPASS_SPAWN=ON
export MONGOC_TEST_AZURE_TENANT_ID=$(cat ~/.csfle/kms_providers.json | jq -r ".azure.tenantId")
export MONGOC_TEST_AZURE_CLIENT_ID=$(cat ~/.csfle/kms_providers.json | jq -r ".azure.clientId")
export MONGOC_TEST_AZURE_CLIENT_SECRET=$(cat ~/.csfle/kms_providers.json | jq -r ".azure.clientSecret")
export MONGOC_TEST_GCP_EMAIL=$(cat ~/.csfle/kms_providers.json | jq -r ".gcp.email")
export MONGOC_TEST_GCP_PRIVATEKEY=$(cat ~/.csfle/kms_providers.json | jq -r ".gcp.privateKey")