Skip to content

Commit b7ef7c9

Browse files
Julien-Benfealebenpae
authored andcommitted
CLOUDP-301110 Ensure E2E tests correctly run in static mode (#4111)
# Summary The following tests were running in non-static mode despite having a static context activated: - `operator_upgrade_sharded_cluster` - `multi_cluster_appdb_state_operator_upgrade_downgrade` - `e2e_olm_operator_upgrade` - `e2e_olm_operator_upgrade_with_resources` To fix OLM tests, the variable `MDB_DEFAULT_ARCHITECTURE` is explicitly passed to the operator env in the test. OLM tests context was also updated to run with OM70. For the two other tests, the variable is passed in the `install_official_operator` method, as an helm argument. ## Proof of Work In Evergreen, we see in the pod descriptions of deployed MongoDB resources that the environment variables contain `MDB_STATIC_CONTAINERS_ARCHITECTURE: true`, and agent images pulled are suffixed with the operator version. In static variants only. Example: [Sharded pod description](REDACTED)
1 parent 6b5e5af commit b7ef7c9

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ def is_multi_cluster():
5555
return len(os.getenv("MEMBER_CLUSTERS", "")) > 0
5656

5757

58-
def is_static_containers_architecture():
58+
def is_static_containers_architecture() -> bool:
5959
return os.getenv("MDB_DEFAULT_ARCHITECTURE", "non-static") == "static"
6060

6161

62+
def get_static_containers_architecture() -> str:
63+
return "static" if is_static_containers_architecture() else "non-static"
64+
65+
6266
skip_if_static_containers = pytest.mark.skipif(
6367
is_static_containers_architecture(),
6468
reason="Skip if this test is executed using the Static Containers architecture",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ def install_official_operator(
844844
helm_args = {
845845
"registry.imagePullSecrets": operator_installation_config["registry.imagePullSecrets"],
846846
"managedSecurityContext": managed_security_context,
847+
"operator.mdbDefaultArchitecture": operator_installation_config["operator.mdbDefaultArchitecture"],
847848
}
848849
name = "mongodb-enterprise-operator"
849850

docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from kubernetes.client.rest import ApiException
33
from kubetester import MongoDB, read_service, wait_for_webhook
44
from kubetester.kubetester import fixture as yaml_fixture
5+
from kubetester.kubetester import (
6+
get_static_containers_architecture,
7+
is_static_containers_architecture,
8+
)
59
from kubetester.opsmanager import MongoDBOpsManager
610
from tests.olm.olm_test_commons import (
711
get_catalog_image,
@@ -31,6 +35,7 @@ def test_upgrade_operator_only(namespace: str, version_id: str):
3135
)
3236
catalog_source_resource.update()
3337

38+
static_value = get_static_containers_architecture()
3439
subscription = get_subscription_custom_object(
3540
"mongodb-enterprise-operator",
3641
namespace,
@@ -46,6 +51,7 @@ def test_upgrade_operator_only(namespace: str, version_id: str):
4651
"env": [
4752
{"name": "MANAGED_SECURITY_CONTEXT", "value": "false"},
4853
{"name": "OPERATOR_ENV", "value": "dev"},
54+
{"name": "MDB_DEFAULT_ARCHITECTURE", "value": static_value},
4955
]
5056
},
5157
},

docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade_with_resources.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
from kubetester.certs import create_sharded_cluster_certs
1212
from kubetester.kubetester import ensure_ent_version
1313
from kubetester.kubetester import fixture as yaml_fixture
14-
from kubetester.kubetester import run_periodically
14+
from kubetester.kubetester import (
15+
get_static_containers_architecture,
16+
is_static_containers_architecture,
17+
run_periodically,
18+
)
1519
from kubetester.mongodb import Phase
1620
from kubetester.mongodb_user import MongoDBUser
1721
from kubetester.opsmanager import MongoDBOpsManager
@@ -58,6 +62,7 @@ def catalog_source(namespace: str, version_id: str):
5862

5963
@fixture
6064
def subscription(namespace: str, catalog_source: CustomObject):
65+
static_value = get_static_containers_architecture()
6166
return get_subscription_custom_object(
6267
"mongodb-enterprise-operator",
6368
namespace,
@@ -73,6 +78,7 @@ def subscription(namespace: str, catalog_source: CustomObject):
7378
"env": [
7479
{"name": "MANAGED_SECURITY_CONTEXT", "value": "false"},
7580
{"name": "OPERATOR_ENV", "value": "dev"},
81+
{"name": "MDB_DEFAULT_ARCHITECTURE", "value": static_value},
7682
]
7783
},
7884
},

scripts/dev/contexts/e2e_static_kind_olm_ubi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ script_name=$(readlink -f "${BASH_SOURCE[0]}")
66
script_dir=$(dirname "${script_name}")
77

88
source "${script_dir}/root-context"
9-
source "${script_dir}/variables/om60"
9+
source "${script_dir}/variables/om70"
1010

1111
export KUBE_ENVIRONMENT_NAME=kind
12-
export CUSTOM_MDB_VERSION=5.0.5
1312
export CUSTOM_MDB_PREV_VERSION=4.4.20
1413
export MDB_DEFAULT_ARCHITECTURE=static

0 commit comments

Comments
 (0)