1#!/usr/bin/env bash
2# parameters are available to this script
3
4# STACK_VERSION -- version e.g Major.Minor.Patch(-Prelease)
5# TEST_SUITE -- which test suite to run: oss or xpack
6# ELASTICSEARCH_URL -- The url at which elasticsearch is reachable, a default is composed based on STACK_VERSION and TEST_SUITE
7# PHP_VERSION -- PHP version (defined in test-matrix.yml, a default is hardcoded here)
8script_path=$(dirname $(realpath -s $0))
9source $script_path/functions/imports.sh
10set -euo pipefail
11
12PHP_VERSION=${PHP_VERSION-7.4-cli}
13ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"}
14elasticsearch_container=${elasticsearch_container-}
15
16echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
17echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
18echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
19echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m"
20echo -e "\033[34;1mINFO:\033[0m PHP_VERSION ${PHP_VERSION}\033[0m"
21
22echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
23
24docker build \
25  --no-cache \
26  --file .ci/Dockerfile \
27  --tag elastic/elasticsearch-php \
28  --build-arg PHP_VERSION=${PHP_VERSION} \
29  .
30
31echo -e "\033[1m>>>>> Run test:integration >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
32
33repo=$(realpath $(dirname $(realpath -s $0))/../)
34
35docker run \
36  --network=${network_name} \
37  --workdir="/usr/src/app" \
38  --volume=${repo}/tests:/usr/src/app/tests \
39  --env STACK_VERSION=${STACK_VERSION} \
40  --env TEST_SUITE=${TEST_SUITE} \
41  --env PHP_VERSION=${PHP_VERSION} \
42  --env ELASTICSEARCH_URL=${ELASTICSEARCH_URL} \
43  --ulimit nofile=65535:65535 \
44  --name elasticsearch-php \
45  --rm \
46  elastic/elasticsearch-php