Skip to content

Commit a34db60

Browse files
lsierantfealebenpae
authored andcommitted
Deflaking e2e tests (#3820)
This patch contains a number of improvements tried in order to deflake e2e tests. Overally result is quite successful: [100% green EVG](https://spruce.mongodb.com/version/66f81d4d24506900071e3563/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC) and progress with [flakes](https://ui.honeycomb.io/mongodb-4b/environments/production/result/8p2zFkfJ2Pz) Changes: - deleting kind clusters before creating kind clusters; controllable by new DELETE_KIND_NETWORK env, which is true only in EVG run (set in evg-private-context only). This one is actually of a dubious value as we're doing docker prune in teardown already. But it's useful also for our own evg hosts as we've never cleared docker network once created. - setting the subnet for docker network explicitly to 172.18.0.0/16. We hardcode usage of this subnet locally, and docker network in evg started to assign subnets on different IPs. That's why sometimes our "interconnected" tests were passing - when docker network created in evg got lucky subnet (172.18)! - added ttl and refresh to coredns config map - cannot harm, not sure if helps - changed the order of CreateOrUpdate to always update first and if 404 then create. Previously we had get first which was susceptible to not refreshed informers and CreateOrUpdate was going directly to Create which was failing. Details in [PR in MCO](mongodb/mongodb-kubernetes-operator#1623)
1 parent 44365f4 commit a34db60

File tree

11 files changed

+46
-7
lines changed

11 files changed

+46
-7
lines changed

docker/mongodb-enterprise-tests/tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,8 @@ def coredns_config(tld: str, mappings: str):
13661366
debug
13671367
hosts /etc/coredns/customdomains.db {tld} {{
13681368
{mappings}
1369+
ttl 10
1370+
reload 1m
13691371
fallthrough
13701372
}}
13711373
}}

docker/mongodb-enterprise-tests/tests/multicluster/multi_cluster_tls_no_mesh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_create_mongodb_multi(
212212
member_cluster_clients: List[MultiClusterClient],
213213
member_cluster_names: List[str],
214214
):
215-
mongodb_multi.assert_reaches_phase(Phase.Running, timeout=2400)
215+
mongodb_multi.assert_reaches_phase(Phase.Running, timeout=2400, ignore_errors=True)
216216

217217

218218
@mark.e2e_multi_cluster_tls_no_mesh

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/go-retryablehttp v0.7.7
1212
github.com/hashicorp/vault/api v1.14.0
1313
github.com/imdario/mergo v0.3.15
14-
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240821171907-8e1a37b82521
14+
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240930083228-a6075d415434
1515
github.com/pkg/errors v0.9.1
1616
github.com/prometheus/client_golang v1.19.1
1717
github.com/r3labs/diff/v3 v3.0.1

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
143143
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
144144
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240821171907-8e1a37b82521 h1:vpqPRUa6NorJ5q4BqyPHWUK4qO6K4om4uMJUXybQEXk=
145145
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240821171907-8e1a37b82521/go.mod h1:2w08xx8V5vHfD+nrKp+DtHxOVrTZ/G+ebm0I8Q4faXo=
146+
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240928135849-f79c8434fc8c h1:WQdcKGXKlqHqPaQkJeP5aQPgR6KwD+yiDWQU1yYFnRo=
147+
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240928135849-f79c8434fc8c/go.mod h1:2w08xx8V5vHfD+nrKp+DtHxOVrTZ/G+ebm0I8Q4faXo=
148+
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240930083228-a6075d415434 h1:xCKFXj5J2VcSRREC/H6JoAl5Iv75E5H90NtBOX6Dmvk=
149+
github.com/mongodb/mongodb-kubernetes-operator v0.11.1-0.20240930083228-a6075d415434/go.mod h1:2w08xx8V5vHfD+nrKp+DtHxOVrTZ/G+ebm0I8Q4faXo=
146150
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
147151
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
148152
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

scripts/dev/contexts/evg-private-context

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,5 @@ export BUILD_VARIANT="${build_variant:-"unknown"}"
9898
# var used in pipeline.py to determine if we're running on EVG host
9999
# used to discern between local pipeline image build and the build in pipeline
100100
export RUNNING_IN_EVG="true"
101+
102+
export DELETE_KIND_NETWORK="true"

scripts/dev/evg_host.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ recreate-kind-cluster() {
112112
get-kubeconfig
113113
}
114114

115-
116115
tunnel() {
117116
shift 1
118117
# shellcheck disable=SC2016

scripts/dev/recreate_kind_cluster.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
set -Eeou pipefail
44

55
source scripts/dev/set_env_context.sh
6+
source scripts/funcs/kubernetes
67

78
cluster_name=$1
89
if [[ -z ${cluster_name} ]]; then
910
echo "Usage: recreate_kind_cluster.sh <cluster_name>"
1011
exit 1
1112
fi
1213

14+
if [[ "${DELETE_KIND_NETWORK:-"false"}" == "true" ]]; then
15+
delete_kind_network
16+
fi
17+
1318
scripts/dev/setup_kind_cluster.sh -r -e -n "${cluster_name}" -l "172.18.255.200-172.18.255.250" -c "$CLUSTER_DOMAIN"
1419
CTX_CLUSTER1=${cluster_name}-kind scripts/dev/install_csi_driver.sh

scripts/dev/recreate_kind_clusters.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
set -Eeou pipefail
33

44
source scripts/dev/set_env_context.sh
5+
source scripts/funcs/kubernetes
56

67
kind delete clusters --all
78

9+
if [[ "${DELETE_KIND_NETWORK:-"false"}" == "true" ]]; then
10+
delete_kind_network
11+
fi
12+
813
# first script prepares registry, so to avoid race it have to finish running before we execute subsequent ones in parallel
914
# To future maintainers: whenever modifying this bit, make sure you also update coredns.yaml
1015
scripts/dev/setup_kind_cluster.sh -n "e2e-operator" -p "10.244.0.0/16" -s "10.96.0.0/16" -l "172.18.255.200-172.18.255.210" -c "$CLUSTER_DOMAIN"

scripts/dev/setup_kind_cluster.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ shift "$((OPTIND - 1))"
5757

5858
kubeconfig_path="$HOME/.kube/${cluster_name}"
5959

60-
# create the kind network early unless it already exists.
61-
# it would normally be created automatically by kind but we
62-
# need it earlier to get the IP address of our registry.
63-
docker network create kind || true
60+
# We create docker network primarily so that all kind clusters use the same network.
61+
# We hardcode 172.18/16 subnet in few places, so we must ensure the network uses that subnet:
62+
# - we set IP ranges for MetalLB
63+
# - we write into coredns config map with IP used for exposing pods externally and for no-mesh test
64+
# In case of any errors, verify if any other subnet is not already using that subnet.
65+
docker network create --subnet=172.18.0.0/16 kind || true
6466

6567
# adapted from https://kind.sigs.k8s.io/docs/user/local-registry/
6668
# create registry container unless it already exists

scripts/evergreen/setup_kubernetes_environment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -Eeou pipefail
33

44
source scripts/dev/set_env_context.sh
5+
source scripts/funcs/kubernetes
56

67
# shellcheck disable=SC2154
78
bindir="${workdir}/bin"

0 commit comments

Comments
 (0)