-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement runner for e2e tests (#548)
* implement a runner for e2e tests * move e2e tests to a Docker container * integrate e2e tests into build pipelines * add tests for multi-namespace support and logical backup jobs * @FxKu implement the first e2e test for failovers
- Loading branch information
1 parent
ec5b1d4
commit 69af2d6
Showing
11 changed files
with
507 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
exclude=.git,__pycache__ | ||
max-line-length=120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM ubuntu:18.04 | ||
LABEL maintainer="Team ACID @ Zalando <[email protected]>" | ||
|
||
WORKDIR /e2e | ||
|
||
COPY manifests ./manifests | ||
COPY e2e/requirements.txt e2e/tests ./ | ||
|
||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
python3 \ | ||
python3-setuptools \ | ||
python3-pip \ | ||
curl \ | ||
&& pip3 install --no-cache-dir -r requirements.txt \ | ||
&& curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/linux/amd64/kubectl \ | ||
&& chmod +x ./kubectl \ | ||
&& mv ./kubectl /usr/local/bin/kubectl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
CMD ["python3", "-m", "unittest", "discover", "--start-directory", ".", "-v"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Cluster | ||
apiVersion: kind.sigs.k8s.io/v1alpha3 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kubernetes==9.0.0 | ||
timeout_decorator==0.4.1 | ||
pyyaml==5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
# enable unofficial bash strict mode | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
IFS=$'\n\t' | ||
|
||
readonly cluster_name="postgres-operator-e2e-tests" | ||
readonly operator_image=$(docker images --filter=reference="registry.opensource.zalan.do/acid/postgres-operator" --format "{{.Repository}}:{{.Tag}}" | head -1) | ||
readonly e2e_test_image=${cluster_name} | ||
readonly kubeconfig_path="/tmp/kind-config-${cluster_name}" | ||
|
||
|
||
function start_kind(){ | ||
|
||
# avoid interference with previous test runs | ||
if [[ $(kind-linux-amd64 get clusters | grep "^${cluster_name}*") != "" ]] | ||
then | ||
kind-linux-amd64 delete cluster --name ${cluster_name} | ||
fi | ||
|
||
kind-linux-amd64 create cluster --name ${cluster_name} --config ./e2e/kind-cluster-postgres-operator-e2e-tests.yaml | ||
kind-linux-amd64 load docker-image "${operator_image}" --name ${cluster_name} | ||
KUBECONFIG="$(kind-linux-amd64 get kubeconfig-path --name=${cluster_name})" | ||
export KUBECONFIG | ||
} | ||
|
||
function set_kind_api_server_ip(){ | ||
# use the actual kubeconfig to connect to the 'kind' API server | ||
# but update the IP address of the API server to the one from the Docker 'bridge' network | ||
cp "${KUBECONFIG}" /tmp | ||
readonly local kind_api_server_port=6443 # well-known in the 'kind' codebase | ||
readonly local kind_api_server=$(docker inspect --format "{{ .NetworkSettings.IPAddress }}:${kind_api_server_port}" "${cluster_name}"-control-plane) | ||
sed -i "s/server.*$/server: https:\/\/$kind_api_server/g" "${kubeconfig_path}" | ||
} | ||
|
||
function run_tests(){ | ||
docker run --rm --mount type=bind,source="$(readlink -f ${kubeconfig_path})",target=/root/.kube/config -e OPERATOR_IMAGE="${operator_image}" "${e2e_test_image}" | ||
} | ||
|
||
function clean_up(){ | ||
unset KUBECONFIG | ||
kind-linux-amd64 delete cluster --name ${cluster_name} | ||
rm -rf ${kubeconfig_path} | ||
} | ||
|
||
function main(){ | ||
|
||
trap "clean_up" QUIT TERM EXIT | ||
|
||
start_kind | ||
set_kind_api_server_ip | ||
run_tests | ||
exit 0 | ||
} | ||
|
||
main "$@" |
Oops, something went wrong.