mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 07:41:52 +02:00
End 2 End tests speedup (#1180)
* Improving end 2 end tests, especially speed of execution and error, by implementing proper eventual asserts and timeouts. * Add documentation for running individual tests * Fixed String encoding in Patorni state check and error case * Printing config as multi log line entity, makes it readable and grepable on startup * Cosmetic changes to logs. Removed quotes from diff. Move all object diffs to text diff. Enabled padding for log level. * Mount script with tools for easy logaccess and watching objects. * Set proper update strategy for Postgres operator deployment. * Move long running test to end. Move pooler test to new functions. * Remove quote from valid K8s identifiers.
This commit is contained in:
+24
-19
@@ -9,6 +9,10 @@ IFS=$'\n\t'
|
||||
readonly cluster_name="postgres-operator-e2e-tests"
|
||||
readonly kubeconfig_path="/tmp/kind-config-${cluster_name}"
|
||||
readonly spilo_image="registry.opensource.zalan.do/acid/spilo-12:1.6-p5"
|
||||
readonly e2e_test_runner_image="registry.opensource.zalan.do/acid/postgres-operator-e2e-tests-runner:0.3"
|
||||
|
||||
export GOPATH=${GOPATH-~/go}
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
|
||||
echo "Clustername: ${cluster_name}"
|
||||
echo "Kubeconfig path: ${kubeconfig_path}"
|
||||
@@ -19,12 +23,7 @@ function pull_images(){
|
||||
then
|
||||
docker pull registry.opensource.zalan.do/acid/postgres-operator:latest
|
||||
fi
|
||||
|
||||
operator_image=$(docker images --filter=reference="registry.opensource.zalan.do/acid/postgres-operator" --format "{{.Repository}}:{{.Tag}}" | head -1)
|
||||
|
||||
# this image does not contain the tests; a container mounts them from a local "./tests" dir at start time
|
||||
e2e_test_runner_image="registry.opensource.zalan.do/acid/postgres-operator-e2e-tests-runner:latest"
|
||||
docker pull ${e2e_test_runner_image}
|
||||
}
|
||||
|
||||
function start_kind(){
|
||||
@@ -36,12 +35,17 @@ function start_kind(){
|
||||
fi
|
||||
|
||||
export KUBECONFIG="${kubeconfig_path}"
|
||||
kind create cluster --name ${cluster_name} --config kind-cluster-postgres-operator-e2e-tests.yaml
|
||||
kind load docker-image "${operator_image}" --name ${cluster_name}
|
||||
kind create cluster --name ${cluster_name} --config kind-cluster-postgres-operator-e2e-tests.yaml
|
||||
docker pull "${spilo_image}"
|
||||
kind load docker-image "${spilo_image}" --name ${cluster_name}
|
||||
}
|
||||
|
||||
function load_operator_image() {
|
||||
echo "Loading operator image"
|
||||
export KUBECONFIG="${kubeconfig_path}"
|
||||
kind load docker-image "${operator_image}" --name ${cluster_name}
|
||||
}
|
||||
|
||||
function set_kind_api_server_ip(){
|
||||
echo "Setting up kind API server ip"
|
||||
# use the actual kubeconfig to connect to the 'kind' API server
|
||||
@@ -52,8 +56,7 @@ function set_kind_api_server_ip(){
|
||||
}
|
||||
|
||||
function run_tests(){
|
||||
echo "Running tests..."
|
||||
|
||||
echo "Running tests... image: ${e2e_test_runner_image}"
|
||||
# tests modify files in ./manifests, so we mount a copy of this directory done by the e2e Makefile
|
||||
|
||||
docker run --rm --network=host -e "TERM=xterm-256color" \
|
||||
@@ -61,11 +64,11 @@ function run_tests(){
|
||||
--mount type=bind,source="$(readlink -f manifests)",target=/manifests \
|
||||
--mount type=bind,source="$(readlink -f tests)",target=/tests \
|
||||
--mount type=bind,source="$(readlink -f exec.sh)",target=/exec.sh \
|
||||
-e OPERATOR_IMAGE="${operator_image}" "${e2e_test_runner_image}"
|
||||
|
||||
--mount type=bind,source="$(readlink -f scripts)",target=/scripts \
|
||||
-e OPERATOR_IMAGE="${operator_image}" "${e2e_test_runner_image}" ${E2E_TEST_CASE-} $@
|
||||
}
|
||||
|
||||
function clean_up(){
|
||||
function cleanup(){
|
||||
echo "Executing cleanup"
|
||||
unset KUBECONFIG
|
||||
kind delete cluster --name ${cluster_name}
|
||||
@@ -73,14 +76,16 @@ function clean_up(){
|
||||
}
|
||||
|
||||
function main(){
|
||||
echo "Entering main function..."
|
||||
[[ -z ${NOCLEANUP-} ]] && trap "cleanup" QUIT TERM EXIT
|
||||
pull_images
|
||||
[[ ! -f ${kubeconfig_path} ]] && start_kind
|
||||
load_operator_image
|
||||
set_kind_api_server_ip
|
||||
|
||||
trap "clean_up" QUIT TERM EXIT
|
||||
|
||||
time pull_images
|
||||
time start_kind
|
||||
time set_kind_api_server_ip
|
||||
run_tests
|
||||
shift
|
||||
run_tests $@
|
||||
exit 0
|
||||
}
|
||||
|
||||
"$@"
|
||||
"$1" $@
|
||||
|
||||
Reference in New Issue
Block a user