Skip to content

Commit 244f41a

Browse files
committed
JAVA-2350: Configure GSSAPI authentication tests for Evergreen
1 parent b4602ef commit 244f41a

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

.evergreen/.evg.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,22 @@ functions:
220220
- command: shell.exec
221221
type: test
222222
params:
223+
silent: true
223224
working_dir: "src"
224225
script: |
225-
${PREPARE_SHELL}
226+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
226227
JDK="jdk8" MONGODB_URI="${plain_auth_mongodb_uri}" .evergreen/run-plain-auth-test.sh
227228
229+
"run gssapi auth test":
230+
- command: shell.exec
231+
type: test
232+
params:
233+
silent: true
234+
working_dir: "src"
235+
script: |
236+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
237+
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} JDK=${JDK} MONGODB_URI=${gssapi_auth_mongodb_uri} KDC=${gssapi_auth_kdc} REALM=${gssapi_auth_realm} KEYTAB_BASE64=${gssapi_auth_keytab_base64} .evergreen/run-gssapi-auth-test.sh
238+
228239
"publish snapshot":
229240
- command: shell.exec
230241
type: test
@@ -336,10 +347,21 @@ tasks:
336347
commands:
337348
- func: "run plain auth test"
338349

350+
- name: "gssapi-auth-test"
351+
depends_on:
352+
- variant: "static-checks"
353+
name: "static-analysis"
354+
commands:
355+
- func: "run gssapi auth test"
356+
339357
- name: publish-snapshot
340358
depends_on:
341359
- variant: ".tests-variant"
342360
name: "test"
361+
- variant: ".test-gssapi-variant"
362+
name: "gssapi-auth-test"
363+
- variant: "plain-auth-test"
364+
name: "plain-auth-test"
343365
commands:
344366
- func: "publish snapshot"
345367

@@ -453,6 +475,13 @@ buildvariants:
453475
tasks:
454476
- name: "test"
455477

478+
- matrix_name: "test-gssapi"
479+
matrix_spec: { jdk: "*", os: "rhel62" }
480+
display_name: "GSSAPI (Kerberos) Auth test ${jdk} ${os} "
481+
tags: ["test-gssapi-variant"]
482+
tasks:
483+
- name: "gssapi-auth-test"
484+
456485
- name: plain-auth-test
457486
display_name: "PLAIN (LDAP) Auth test"
458487
run_on:

.evergreen/run-gssapi-auth-test.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# Don't trace since the URI contains a password that shouldn't show up in the logs
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
# Supported/used environment variables:
7+
# MONGODB_URI Set the URI, including username/password to use to connect to the server via PLAIN authentication mechanism
8+
# JDK Set the version of java to be used. Java versions can be set from the java toolchain /opt/java
9+
# "jdk5", "jdk6", "jdk7", "jdk8"
10+
# KDC The KDC
11+
# REALM The realm
12+
# KEYTAB_BASE64 The BASE64-encoded keytab
13+
# PROJECT_DIRECTORY The project directory
14+
15+
JDK=${JDK:-jdk}
16+
JAVA_HOME="/opt/java/${JDK}"
17+
18+
############################################
19+
# Main Program #
20+
############################################
21+
22+
echo "Running GSSAPI authentication tests"
23+
24+
echo ${KEYTAB_BASE64} | base64 -d > ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab
25+
26+
cat << EOF > .evergreen/java.login.drivers.config
27+
com.sun.security.jgss.krb5.initiate {
28+
com.sun.security.auth.module.Krb5LoginModule required
29+
doNotPrompt=true useKeyTab=true keyTab="${PROJECT_DIRECTORY}/.evergreen/drivers.keytab" principal=drivers;
30+
};
31+
EOF
32+
33+
echo "Compiling java driver with jdk8"
34+
35+
# We always compile with the latest version of java
36+
export JAVA_HOME="/opt/java/jdk8"
37+
./gradlew -version
38+
./gradlew --info driver-core:classes driver-core:testClasses
39+
40+
echo "Running tests with ${JDK}"
41+
JAVA_HOME="/opt/java/${JDK}"
42+
./gradlew -version
43+
44+
./gradlew --stacktrace --info \
45+
-Dorg.mongodb.test.uri=${MONGODB_URI} \
46+
-Pgssapi.enabled=true -Psun.security.krb5.debug=true -Pauth.login.config=file://${PROJECT_DIRECTORY}/.evergreen/java.login.drivers.config \
47+
-Pkrb5.kdc=${KDC} -Pkrb5.realm=${REALM} -Psun.security.krb5.debug=true \
48+
-Dtest.single=GSSAPIAuthenticationSpecification -x classes -x testClasses --rerun-tasks driver-core:test

.evergreen/run-plain-auth-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "Compiling java driver with jdk8"
2121
# We always compile with the latest version of java
2222
export JAVA_HOME="/opt/java/jdk8"
2323
./gradlew -version
24-
./gradlew --info classes testClasses
24+
./gradlew --info driver-core:classes driver-core:testClasses
2525

2626
echo "Running tests with ${JDK}"
2727
JAVA_HOME="/opt/java/${JDK}"

0 commit comments

Comments
 (0)