Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2237: Run KMS KMIP spec and prose tests in Evergreen #816

Merged
merged 9 commits into from Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 97 additions & 1 deletion .evergreen/config.yml
Expand Up @@ -835,7 +835,39 @@ functions:
background: true
script: |
cd ${DRIVERS_TOOLS}/.evergreen/csfle
./kmstlsvenv/bin/python3 -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/${CERT_FILE} --port 8000
./kmstlsvenv/bin/python3 -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/${CERT_FILE} --port ${PORT}

start-kms-mock-server-require-client-cert:
- command: shell.exec
params:
script: |
${PREPARE_SHELL}

cd ${DRIVERS_TOOLS}/.evergreen/csfle
. ./activate_venv.sh
- command: shell.exec
params:
background: true
script: |
cd ${DRIVERS_TOOLS}/.evergreen/csfle
./kmstlsvenv/bin/python3 -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/${CERT_FILE} --port ${PORT} --require_client_cert

start-kms-kmip-server:
- command: shell.exec
params:
script: |
${PREPARE_SHELL}

cd ${DRIVERS_TOOLS}/.evergreen/csfle
. ./activate_venv.sh
# TODO: Stabilize this pip install with a non-forked version of PyKMIP in https://jira.mongodb.org/browse/GODRIVER-2239
pip install git+https://github.com/kevinAlbs/PyKMIP.git@expand_tls12_ciphers
benjirewis marked this conversation as resolved.
Show resolved Hide resolved
- command: shell.exec
params:
background: true
script: |
cd ${DRIVERS_TOOLS}/.evergreen/csfle
./kmstlsvenv/bin/python3 -u kms_kmip_server.py --port 5698

run-kms-tls-test:
- command: shell.exec
Expand Down Expand Up @@ -864,6 +896,35 @@ functions:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH

run-kmip-tests:
- command: shell.exec
type: test
params:
working_dir: src/go.mongodb.org/mongo-driver
script: |
${PREPARE_SHELL}
export KMS_MOCK_SERVERS_RUNNING="true"

export GOFLAGS=-mod=vendor
AUTH="${AUTH}" \
SSL="${SSL}" \
MONGODB_URI="${MONGODB_URI}" \
TOPOLOGY="${TOPOLOGY}" \
MONGO_GO_DRIVER_COMPRESSOR=${MONGO_GO_DRIVER_COMPRESSOR} \
BUILD_TAGS="-tags cse" \
AWS_ACCESS_KEY_ID="${cse_aws_access_key_id}" \
AWS_SECRET_ACCESS_KEY="${cse_aws_secret_access_key}" \
AZURE_TENANT_ID="${cse_azure_tenant_id}" \
AZURE_CLIENT_ID="${cse_azure_client_id}" \
AZURE_CLIENT_SECRET="${cse_azure_client_secret}" \
GCP_EMAIL="${cse_gcp_email}" \
GCP_PRIVATE_KEY="${cse_gcp_private_key}" \
CSFLE_TLS_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
CSFLE_TLS_CERTIFICATE_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
make evg-test-kmip \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH

pre:
- func: fetch-source
- func: prepare-resources
Expand Down Expand Up @@ -1693,6 +1754,7 @@ tasks:
- func: start-kms-mock-server
vars:
CERT_FILE: "expired.pem"
PORT: 8000
- func: run-kms-tls-test
vars:
KMS_TLS_TESTCASE: "INVALID_CERT"
Expand All @@ -1711,13 +1773,41 @@ tasks:
- func: start-kms-mock-server
vars:
CERT_FILE: "wrong-host.pem"
PORT: 8000
- func: run-kms-tls-test
vars:
KMS_TLS_TESTCASE: "INVALID_HOSTNAME"
TOPOLOGY: "server"
AUTH: "noauth"
SSL: "nossl"

- name: "test-kms-kmip"
tags: ["kms-kmip"]
commands:
- func: bootstrap-mongo-orchestration
vars:
TOPOLOGY: "server"
AUTH: "noauth"
SSL: "nossl"
- func: start-kms-mock-server
vars:
CERT_FILE: "expired.pem"
PORT: 8000
- func: start-kms-mock-server
vars:
CERT_FILE: "wrong-host.pem"
PORT: 8001
- func: start-kms-mock-server-require-client-cert
vars:
CERT_FILE: "server.pem"
PORT: 8002
- func: start-kms-kmip-server
- func: run-kmip-tests
vars:
TOPOLOGY: "server"
AUTH: "noauth"
SSL: "nossl"

- name: "test-serverless"
tags: ["serverless"]
commands:
Expand Down Expand Up @@ -2075,3 +2165,9 @@ buildvariants:
display_name: "Serverless ${os-ssl-40}"
tasks:
- "serverless_task_group"

- matrix_name: "kms-kmip-test"
matrix_spec: { version: ["latest"], os-ssl-40: ["ubuntu1804-64-go-1-16"] }
display_name: "KMS KMIP ${os-ssl-40}"
tasks:
- name: ".kms-kmip"
8 changes: 8 additions & 0 deletions Makefile
Expand Up @@ -164,6 +164,14 @@ evg-test-load-balancers:
evg-test-kms:
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/kms_tls_tests >> test.suite

.PHONY: evg-test-kmip
evg-test-kmip:
kevinAlbs marked this conversation as resolved.
Show resolved Hide resolved
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionSpec/kmipKMS >> test.suite
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/data_key_and_double_encryption >> test.suite
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/corpus >> test.suite
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/custom_endpoint >> test.suite
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s ./mongo/integration -run TestClientSideEncryptionProse/kms_tls_options_test >> test.suite

.PHONY: evg-test-serverless
evg-test-serverless:
go test $(BUILD_TAGS) ./mongo/integration -run TestCrudSpec -v -timeout $(TEST_TIMEOUT)s >> test.suite
Expand Down
15 changes: 15 additions & 0 deletions mongo/integration/client_side_encryption_prose_test.go
Expand Up @@ -140,6 +140,9 @@ func TestClientSideEncryptionProse(t *testing.T) {
}
for _, tc := range testCases {
mt.Run(tc.provider, func(mt *mtest.T) {
if tc.provider == "kmip" && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
var startedEvents []*event.CommandStartedEvent
monitor := &event.CommandMonitor{
Started: func(_ context.Context, evt *event.CommandStartedEvent) {
Expand Down Expand Up @@ -398,6 +401,9 @@ func TestClientSideEncryptionProse(t *testing.T) {
"expected error '%v' to contain substring '%v'", errStr, viewErrSubstr)
})
mt.RunOpts("corpus", noClientOpts, func(mt *mtest.T) {
if "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
corpusSchema := readJSONFile(mt, "corpus-schema.json")
localSchemaMap := map[string]interface{}{
"db.coll": corpusSchema,
Expand Down Expand Up @@ -772,6 +778,9 @@ func TestClientSideEncryptionProse(t *testing.T) {
}
for _, tc := range testCases {
mt.Run(tc.name, func(mt *mtest.T) {
if strings.Contains(tc.name, "kmip") && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
cpt := setup(mt, nil, defaultKvClientOptions, validClientEncryptionOptions)
defer cpt.teardown(mt)

Expand Down Expand Up @@ -1168,6 +1177,9 @@ func TestClientSideEncryptionProse(t *testing.T) {
// These tests only run when 3 KMS HTTP servers and 1 KMS KMIP server are running. See specification for port numbers and necessary arguments:
// https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#kms-tls-options-tests
mt.RunOpts("kms tls options tests", noClientOpts, func(mt *mtest.T) {
if os.Getenv("KMS_MOCK_SERVERS_RUNNING") == "" {
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
validKmsProviders := map[string]map[string]interface{}{
"aws": {
"accessKeyId": awsAccessKeyID,
Expand Down Expand Up @@ -1332,6 +1344,9 @@ func TestClientSideEncryptionProse(t *testing.T) {

for _, tc := range testCases {
mt.Run(tc.name, func(mt *mtest.T) {
if tc.name == "kmip" && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
mt.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
// call CreateDataKey with CEO no TLS with each provider and corresponding master key
cpt := setup(mt, nil, defaultKvClientOptions, validClientEncryptionOptionsWithoutClientCert)
defer cpt.teardown(mt)
Expand Down
4 changes: 4 additions & 0 deletions mongo/integration/client_side_encryption_spec_test.go
Expand Up @@ -9,6 +9,7 @@
package integration

import (
"os"
"path"
"testing"
)
Expand Down Expand Up @@ -52,6 +53,9 @@ func TestClientSideEncryptionSpec(t *testing.T) {

for _, fileName := range jsonFilesInDir(t, path.Join(dataPath, encryptionSpecName)) {
t.Run(fileName, func(t *testing.T) {
if fileName == "kmipKMS.json" && "" == os.Getenv("KMS_MOCK_SERVERS_RUNNING") {
t.Skipf("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set")
}
runSpecTestFile(t, encryptionSpecName, fileName)
})
}
Expand Down