Remove resolve-ip dependency for integration-tests (#9065)

* Remove resolve-ip dependency for integration-tests

* use host hostname and fallback to dscacheutil

* better shell script comparisons
This commit is contained in:
Suneet Saldanha 2019-12-19 14:53:36 -08:00 committed by Jonathan Wei
parent 256b8f69b6
commit 176bc8fd97
9 changed files with 54 additions and 10 deletions

View File

@ -36,7 +36,8 @@ Integration Testing Using Docker
For running integration tests using docker there are 2 approaches.
If your platform supports docker natively, you can simply set `DOCKER_IP`
environment variable to localhost and skip to [Running tests](#running-tests) section.
environment variable to localhost and skip to [Running tests](#running-tests) section. Ensure that you have
at least 4GiB of memory allocated to the docker engine (This can be set under Preferences > Advanced).
```
export DOCKER_IP=127.0.0.1

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
cat <<EOT > expired_csr.conf
[req]

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
cat <<EOT > csr.conf
[req]

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
# Generate a client cert with an incorrect hostname for testing
cat <<EOT > invalid_hostname_csr.conf

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
cat <<EOT > invalid_ca_intermediate.conf
[req]

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
# Generate a client cert that will be revoked
cat <<EOT > revoked_csr.conf

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
cat <<EOT > csr_another_root.conf
[req]

View File

@ -15,7 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
export DOCKER_HOST_IP=$(resolveip -s $HOSTNAME)
tls_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=set-docker-host-ip.sh
source "$tls_dir/set-docker-host-ip.sh"
cat <<EOT > ca_intermediate.conf
[req]

View File

@ -0,0 +1,29 @@
#!/bin/bash -eu
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DOCKER_HOST_IP="$(host "$(hostname)" | perl -nle '/has address (.*)/ && print $1')"
if [ -z "$DOCKER_HOST_IP" ]; then
# Mac specific way to get host ip
DOCKER_HOST_IP="$(dscacheutil -q host -a name "$(HOSTNAME)" | perl -nle '/ip_address: (.*)/ && print $1')"
fi
if [ -z "$DOCKER_HOST_IP" ]; then
>&2 echo "Could not set docker host IP - integration tests can not run"
exit 1
fi
export DOCKER_HOST_IP