Skip to content

Commit

Permalink
Add doctests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Apr 2, 2020
1 parent 9c338e9 commit 2410a66
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 130 deletions.
20 changes: 0 additions & 20 deletions .ci/certs/ca.crt

This file was deleted.

20 changes: 0 additions & 20 deletions .ci/certs/ca.pem

This file was deleted.

20 changes: 0 additions & 20 deletions .ci/certs/testnode_san.crt

This file was deleted.

27 changes: 0 additions & 27 deletions .ci/certs/testnode_san.key

This file was deleted.

33 changes: 5 additions & 28 deletions .ci/run-elasticsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ CLUSTER_NAME=${CLUSTER_NAME-${moniker}${suffix}}
HTTP_PORT=${HTTP_PORT-9200}

ELASTIC_PASSWORD=${ELASTIC_PASSWORD-changeme}
SSL_CERT=${SSL_CERT-"${SCRIPT_PATH}/certs/testnode_san.crt"}
SSL_KEY=${SSL_KEY-"${SCRIPT_PATH}/certs/testnode_san.key"}
SSL_CA=${SSL_CA-"${SCRIPT_PATH}/certs/ca.crt"}
SSL_CA_PEM=${SSL_CA-"${SCRIPT_PATH}/certs/ca.pem"}

DETACH=${DETACH-false}
CLEANUP=${CLEANUP-false}
Expand Down Expand Up @@ -122,35 +118,16 @@ if [[ "$ELASTICSEARCH_VERSION" != *oss* ]]; then
environment+=($(cat <<-END
--env ELASTIC_PASSWORD=$ELASTIC_PASSWORD
--env xpack.license.self_generated.type=trial
--env xpack.security.enabled=true
--env xpack.security.http.ssl.enabled=true
--env xpack.security.http.ssl.verification_mode=certificate
--env xpack.security.http.ssl.key=certs/testnode_san.key
--env xpack.security.http.ssl.certificate=certs/testnode_san.crt
--env xpack.security.http.ssl.certificate_authorities=certs/ca.crt
--env xpack.security.transport.ssl.enabled=true
--env xpack.security.transport.ssl.key=certs/testnode_san.key
--env xpack.security.transport.ssl.certificate=certs/testnode_san.crt
--env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt
END
))
volumes+=($(cat <<-END
--volume $SSL_CERT:/usr/share/elasticsearch/config/certs/testnode_san.crt
--volume $SSL_KEY:/usr/share/elasticsearch/config/certs/testnode_san.key
--volume $SSL_CA:/usr/share/elasticsearch/config/certs/ca.crt
--volume $SSL_CA_PEM:/usr/share/elasticsearch/config/certs/ca.pem
--env xpack.security.enabled=false
--env xpack.security.http.ssl.enabled=false
--env xpack.security.transport.ssl.enabled=false
END
))
fi

url="http://$NODE_NAME"
if [[ "$ELASTICSEARCH_VERSION" != *oss* ]]; then
url="https://elastic:$ELASTIC_PASSWORD@$NODE_NAME"
fi

cert_validation_flags="--insecure"
if [[ "$NODE_NAME" == "es1" ]]; then
cert_validation_flags="--cacert /usr/share/elasticsearch/config/certs/ca.pem --resolve ${NODE_NAME}:443:127.0.0.1"
url="http://elastic:$ELASTIC_PASSWORD@$NODE_NAME"
fi

echo -e "\033[34;1mINFO:\033[0m Starting container $NODE_NAME \033[0m"
Expand All @@ -165,7 +142,7 @@ docker run \
--ulimit nofile=65536:65536 \
--ulimit memlock=-1:-1 \
--detach="$DETACH" \
--health-cmd="curl $cert_validation_flags --fail $url:9200/_cluster/health || exit 1" \
--health-cmd="curl --insecure --fail $url:9200/_cluster/health || exit 1" \
--health-interval=2s \
--health-retries=20 \
--health-timeout=2s \
Expand Down
8 changes: 4 additions & 4 deletions .ci/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ set -euxo pipefail


TEST_SUITE=${TEST_SUITE-xpack}
NODE_NAME=es1
NODE_NAME=localhost


elasticsearch_image=elasticsearch
elasticsearch_url=https://elastic:changeme@${NODE_NAME}:9200
elasticsearch_url=http://elastic:changeme@${NODE_NAME}:9200
if [[ $TEST_SUITE != "xpack" ]]; then
elasticsearch_image=elasticsearch-${TEST_SUITE}
elasticsearch_url=http://${NODE_NAME}:9200
Expand Down Expand Up @@ -44,14 +44,14 @@ echo -e "\033[1m>>>>> Start [$ELASTICSEARCH_VERSION container] >>>>>>>>>>>>>>>>>

ELASTICSEARCH_VERSION=${elasticsearch_image}:${ELASTICSEARCH_VERSION} \
NODE_NAME=${NODE_NAME} \
NETWORK_NAME=elasticsearch \
NETWORK_NAME=host \
DETACH=true \
bash .ci/run-elasticsearch.sh

echo -e "\033[1m>>>>> Repository specific tests >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

ELASTICSEARCH_CONTAINER=${elasticsearch_image}:${ELASTICSEARCH_VERSION} \
NETWORK_NAME=elasticsearch \
NETWORK_NAME=host \
NODE_NAME=${NODE_NAME} \
ELASTICSEARCH_URL=${elasticsearch_url} \
TEST_SUITE=${TEST_SUITE} \
Expand Down
11 changes: 1 addition & 10 deletions eland/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,8 @@
# Define client to use in tests
TEST_SUITE = os.environ.get("TEST_SUITE", "xpack")
if TEST_SUITE == "xpack":
print("Running xpack tests requires SSL. Setting up SSL enabled client")
certpath = os.path.abspath(
os.path.join(os.path.dirname(__file__), "../../.ci/certs/ca.crt")
)
print(certpath)
ES_TEST_CLIENT = Elasticsearch(
ELASTICSEARCH_HOST,
http_auth=("elastic", "changeme"),
use_ssl=True,
verify_certs=True,
ca_certs=certpath,
ELASTICSEARCH_HOST, http_auth=("elastic", "changeme"),
)
else:
ES_TEST_CLIENT = Elasticsearch(ELASTICSEARCH_HOST)
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def lint(session):
def test(session):
session.install("-r", "requirements-dev.txt")
session.run("python", "-m", "eland.tests.setup_tests")
session.run("pytest", *(session.posargs or ("eland/tests/",)))
session.run("pytest", "--doctest-modules", *(session.posargs or ("eland/",)))

0 comments on commit 2410a66

Please sign in to comment.