Skip to content

Commit

Permalink
add task
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Nov 13, 2024
1 parent 02a60a5 commit 12a1530
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 11 deletions.
57 changes: 57 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,42 @@ functions:
KMS_MOCK_SERVERS_RUNNING: "true"
args: [*task-runner, evg-test-kmip]

start-kms-failpoint-server:
- command: ec2.assume_role
params:
role_arn: ${aws_test_secrets_role}
- command: subprocess.exec
params:
working_dir: src/go.mongodb.org/mongo-driver
binary: bash
background: true
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "DRIVERS_TOOLS"]
# This cannot use task because it will hang on Windows.
args: [etc/setup-encryption.sh]
- command: subprocess.exec
params:
binary: python3
background: true
args: ["-u", "${DRIVERS_TOOLS}/.evergreen/csfle/kms_failpoint_server.py", "--port", "9003"]

run-retry-kms-requests:
- command: subprocess.exec
type: test
params:
binary: "bash"
env:
GO_BUILD_TAGS: cse
include_expansions_in_env: [AUTH, SSL, MONGODB_URI, TOPOLOGY,
MONGO_GO_DRIVER_COMPRESSOR]
args: [*task-runner, setup-test]
- command: subprocess.exec
type: test
params:
binary: "bash"
env:
KMS_FAILPOINT_SERVERS_RUNNING: "true"
args: [*task-runner, evg-test-retry-kms-requests]

run-fuzz-tests:
- command: subprocess.exec
type: test
Expand Down Expand Up @@ -1486,6 +1522,21 @@ tasks:
AUTH: "noauth"
SSL: "nossl"

- name: "test-retry-kms-requests"
tags: ["retry-kms-requests"]
commands:
- func: bootstrap-mongo-orchestration
vars:
TOPOLOGY: "server"
AUTH: "noauth"
SSL: "nossl"
- func: start-kms-failpoint-server
- func: run-retry-kms-requests
vars:
TOPOLOGY: "server"
AUTH: "noauth"
SSL: "nossl"

- name: "test-serverless"
tags: ["serverless"]
commands:
Expand Down Expand Up @@ -2195,6 +2246,12 @@ buildvariants:
tasks:
- name: ".kms-kmip"

- matrix_name: "retry-kms-requests-test"
matrix_spec: { version: ["7.0"], os-ssl-40: ["rhel87-64"] }
display_name: "Retry KMS Requests ${os-ssl-40}"
tasks:
- name: ".retry-kms-requests"

- matrix_name: "fuzz-test"
matrix_spec: { version: ["5.0"], os-ssl-40: ["rhel87-64"] }
display_name: "Fuzz ${version} ${os-ssl-40}"
Expand Down
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ tasks:
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 ./internal/integration -run TestClientSideEncryptionProse/kms_tls_tests >> test.suite

evg-test-retry-kms-requests:
- go test -exec "env PKG_CONFIG_PATH=${PKG_CONFIG_PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" ${BUILD_TAGS} -v -timeout {{.TEST_TIMEOUT}}s ./internal/integration -run TestClientSideEncryptionProse/kms_retry_tests >> test.suite

evg-test-load-balancers:
# Load balancer should be tested with all unified tests as well as tests in the following
# components: retryable reads, retryable writes, change streams, initial DNS seedlist discovery.
Expand Down
21 changes: 10 additions & 11 deletions internal/integration/client_side_encryption_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"bytes"
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -2983,7 +2982,12 @@ func TestClientSideEncryptionProse(t *testing.T) {
})
})

mt.RunOpts("24. KMS Retry Tests", qeRunOpts22, func(mt *mtest.T) {
mt.RunOpts("24. kms retry tests", noClientOpts, func(mt *mtest.T) {
kmsTlsTestcase := os.Getenv("KMS_FAILPOINT_SERVERS_RUNNING")
if kmsTlsTestcase == "" {
mt.Skipf("Skipping test as KMS_FAILPOINT_SERVERS_RUNNING is not set")
}

setFailPoint := func(failure string, count int) error {
url := fmt.Sprintf("https://localhost:9003/set_failpoint/%s", failure)
var payloadBuf bytes.Buffer
Expand All @@ -2994,18 +2998,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
return err
}

cert, err := ioutil.ReadFile(os.Getenv("CSFLE_TLS_CA_FILE"))
if err != nil {
return err
}

certPool := x509.NewCertPool()
certPool.AppendCertsFromPEM(cert)

client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,
InsecureSkipVerify: true,
},
},
}
Expand Down Expand Up @@ -3036,6 +3032,9 @@ func TestClientSideEncryptionProse(t *testing.T) {
keyID, err = clientEncryption.CreateDataKey(context.Background(), "aws", dkOpts)
require.NoError(mt, err, "error in CreateDataKey: %v", err)

err = setFailPoint("http", 1)
require.NoError(mt, err, "mock server error: %v", err)

testVal := bson.RawValue{Type: bson.TypeInt32, Value: bsoncore.AppendInt32(nil, 123)}
eo := options.Encrypt().
SetKeyID(keyID).
Expand Down

0 comments on commit 12a1530

Please sign in to comment.