Skip to content

Commit 54a17fe

Browse files
Use const for helm_chart local chart dir (#532)
# Summary The local helm chart directory (`helm_chart`) that we use to install the operator is being used at a lot of places and we were using the dir name in line without using the defined constant. This would make it harder to use any other dir as helm chart dir/URL, that we are going to do when we start installing helm chart from OCI registry. This PR changes that and tries to use the const everywhere we used the local chart dir (`helm_chart`). edit: To make this work I had to move all constants from `tests.conftest` to `tests.constants` file to remove circular dependency. ## Proof of Work CI in the PR. ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details --------- Co-authored-by: Maciej Karaś <6159874+MaciejKaras@users.noreply.github.com> Co-authored-by: Maciej Karaś <maciej.karas@mongodb.com>
1 parent 78e9a13 commit 54a17fe

39 files changed

+112
-88
lines changed

docker/mongodb-kubernetes-tests/kubetester/operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import logging
43
import time
54
from typing import Dict, List, Optional
65

@@ -18,6 +17,7 @@
1817
helm_upgrade,
1918
)
2019
from tests import test_logger
20+
from tests.constants import LOCAL_HELM_CHART_DIR
2121

2222
OPERATOR_CRDS = (
2323
"mongodb.mongodb.com",
@@ -43,7 +43,7 @@ def __init__(
4343
namespace: str,
4444
helm_args: Optional[Dict] = None,
4545
helm_options: Optional[List[str]] = None,
46-
helm_chart_path: Optional[str] = "helm_chart",
46+
helm_chart_path: Optional[str] = LOCAL_HELM_CHART_DIR,
4747
name: Optional[str] = "mongodb-kubernetes-operator",
4848
api_client: Optional[client.api_client.ApiClient] = None,
4949
):

docker/mongodb-kubernetes-tests/kubetester/opsmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
multi_cluster_service_names,
3636
)
3737
from tests.conftest import (
38-
LEGACY_CENTRAL_CLUSTER_NAME,
3938
get_central_cluster_client,
4039
get_member_cluster_api_client,
4140
get_member_cluster_client_map,
4241
is_member_cluster,
4342
read_deployment_state,
4443
)
44+
from tests.constants import LEGACY_CENTRAL_CLUSTER_NAME
4545

4646
logger = test_logger.get_test_logger(__name__)
4747
TRACER = trace.get_tracer("evergreen-agent")

docker/mongodb-kubernetes-tests/tests/authentication/replica_set_feature_controls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from kubetester.mongodb import MongoDB
55
from kubetester.phase import Phase
66
from pytest import fixture, mark
7-
from tests.conftest import OPERATOR_NAME
7+
from tests.constants import OPERATOR_NAME
88

99

1010
@fixture(scope="function")

docker/mongodb-kubernetes-tests/tests/common/ops_manager/multi_cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from kubetester.kubetester import fixture as yaml_fixture
44
from kubetester.opsmanager import MongoDBOpsManager
55
from tests.common.constants import S3_BLOCKSTORE_NAME, S3_OPLOG_NAME
6-
from tests.conftest import AWS_REGION
6+
from tests.constants import AWS_REGION
77

88

99
def ops_manager_multi_cluster_with_tls_s3_backups(

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

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,49 +31,29 @@
3131
from pymongo.errors import ServerSelectionTimeoutError
3232
from pytest import fixture
3333
from tests import test_logger
34+
from tests.constants import (
35+
CLUSTER_HOST_MAPPING,
36+
KUBECONFIG_FILEPATH,
37+
LEGACY_CENTRAL_CLUSTER_NAME,
38+
LEGACY_DEPLOYMENT_STATE_VERSION,
39+
LEGACY_OPERATOR_CHART,
40+
LEGACY_OPERATOR_IMAGE_NAME,
41+
LEGACY_OPERATOR_NAME,
42+
LOCAL_HELM_CHART_DIR,
43+
MCK_HELM_CHART,
44+
MONITOR_APPDB_E2E_DEFAULT,
45+
MULTI_CLUSTER_CONFIG_DIR,
46+
MULTI_CLUSTER_OPERATOR_NAME,
47+
OFFICIAL_OPERATOR_IMAGE_NAME,
48+
OPERATOR_NAME,
49+
)
3450
from tests.multicluster import prepare_multi_cluster_namespaces
3551

3652
try:
3753
kubernetes.config.load_kube_config()
3854
except Exception:
3955
kubernetes.config.load_incluster_config()
4056

41-
AWS_REGION = "us-east-1"
42-
43-
KUBECONFIG_FILEPATH = "/etc/config/kubeconfig"
44-
MULTI_CLUSTER_CONFIG_DIR = "/etc/multicluster"
45-
# AppDB monitoring is disabled by default for e2e tests.
46-
# If monitoring is needed use monitored_appdb_operator_installation_config / operator_with_monitored_appdb
47-
MONITOR_APPDB_E2E_DEFAULT = "true"
48-
CLUSTER_HOST_MAPPING = {
49-
"us-central1-c_central": "https://35.232.85.244",
50-
"us-east1-b_member-1a": "https://35.243.222.230",
51-
"us-east1-c_member-2a": "https://34.75.94.207",
52-
"us-west1-a_member-3a": "https://35.230.121.15",
53-
}
54-
55-
LEGACY_CENTRAL_CLUSTER_NAME: str = "__default"
56-
LEGACY_DEPLOYMENT_STATE_VERSION: str = "1.27.0"
57-
58-
# Helm charts
59-
LEGACY_OPERATOR_CHART = "mongodb/enterprise-operator"
60-
MCK_HELM_CHART = "mongodb/mongodb-kubernetes"
61-
LOCAL_HELM_CHART_DIR = "helm_chart"
62-
63-
OFFICIAL_OPERATOR_IMAGE_NAME = "mongodb-kubernetes"
64-
LEGACY_OPERATOR_IMAGE_NAME = "mongodb-enterprise-operator-ubi"
65-
66-
# Names for operator and RBAC
67-
OPERATOR_NAME = "mongodb-kubernetes-operator"
68-
MULTI_CLUSTER_OPERATOR_NAME = OPERATOR_NAME + "-multi-cluster"
69-
LEGACY_OPERATOR_NAME = "mongodb-enterprise-operator"
70-
LEGACY_MULTI_CLUSTER_OPERATOR_NAME = LEGACY_OPERATOR_NAME + "-multi-cluster"
71-
APPDB_SA_NAME = "mongodb-kubernetes-appdb"
72-
DATABASE_SA_NAME = "mongodb-kubernetes-database-pods"
73-
OM_SA_NAME = "mongodb-kubernetes-ops-manager"
74-
TELEMETRY_CONFIGMAP_NAME = LEGACY_OPERATOR_NAME + "-telemetry"
75-
MULTI_CLUSTER_MEMBER_LIST_CONFIGMAP = OPERATOR_NAME + "-member-list"
76-
7757
logger = test_logger.get_test_logger(__name__)
7858

7959

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
AWS_REGION = "us-east-1"
2+
3+
KUBECONFIG_FILEPATH = "/etc/config/kubeconfig"
4+
MULTI_CLUSTER_CONFIG_DIR = "/etc/multicluster"
5+
# AppDB monitoring is disabled by default for e2e tests.
6+
# If monitoring is needed use monitored_appdb_operator_installation_config / operator_with_monitored_appdb
7+
MONITOR_APPDB_E2E_DEFAULT = "true"
8+
CLUSTER_HOST_MAPPING = {
9+
"us-central1-c_central": "https://35.232.85.244",
10+
"us-east1-b_member-1a": "https://35.243.222.230",
11+
"us-east1-c_member-2a": "https://34.75.94.207",
12+
"us-west1-a_member-3a": "https://35.230.121.15",
13+
}
14+
15+
LEGACY_CENTRAL_CLUSTER_NAME: str = "__default"
16+
LEGACY_DEPLOYMENT_STATE_VERSION: str = "1.27.0"
17+
18+
# Helm charts
19+
LEGACY_OPERATOR_CHART = "mongodb/enterprise-operator"
20+
MCK_HELM_CHART = "mongodb/mongodb-kubernetes"
21+
LOCAL_HELM_CHART_DIR = "helm_chart"
22+
23+
OFFICIAL_OPERATOR_IMAGE_NAME = "mongodb-kubernetes"
24+
LEGACY_OPERATOR_IMAGE_NAME = "mongodb-enterprise-operator-ubi"
25+
26+
# Names for operator and RBAC
27+
OPERATOR_NAME = "mongodb-kubernetes-operator"
28+
MULTI_CLUSTER_OPERATOR_NAME = OPERATOR_NAME + "-multi-cluster"
29+
LEGACY_OPERATOR_NAME = "mongodb-enterprise-operator"
30+
LEGACY_MULTI_CLUSTER_OPERATOR_NAME = LEGACY_OPERATOR_NAME + "-multi-cluster"
31+
APPDB_SA_NAME = "mongodb-kubernetes-appdb"
32+
DATABASE_SA_NAME = "mongodb-kubernetes-database-pods"
33+
OM_SA_NAME = "mongodb-kubernetes-ops-manager"
34+
TELEMETRY_CONFIGMAP_NAME = LEGACY_OPERATOR_NAME + "-telemetry"
35+
MULTI_CLUSTER_MEMBER_LIST_CONFIGMAP = OPERATOR_NAME + "-member-list"

docker/mongodb-kubernetes-tests/tests/multicluster/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from kubetester.helm import helm_template
66
from kubetester.multicluster_client import MultiClusterClient
77
from tests import test_logger
8+
from tests.constants import LOCAL_HELM_CHART_DIR
89

910
logger = test_logger.get_test_logger(__name__)
1011

@@ -15,7 +16,7 @@ def prepare_multi_cluster_namespaces(
1516
member_cluster_clients: List[MultiClusterClient],
1617
central_cluster_name: str,
1718
skip_central_cluster: bool = True,
18-
helm_chart_path="helm_chart",
19+
helm_chart_path=LOCAL_HELM_CHART_DIR,
1920
):
2021
"""create a new namespace and configures all necessary service accounts there"""
2122

docker/mongodb-kubernetes-tests/tests/multicluster/multi_cluster_cli_recover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from kubetester.operator import Operator
1010
from kubetester.phase import Phase
1111
from tests.conftest import (
12-
MULTI_CLUSTER_OPERATOR_NAME,
1312
run_kube_config_creation_tool,
1413
run_multi_cluster_recovery_tool,
1514
)
15+
from tests.constants import MULTI_CLUSTER_OPERATOR_NAME
1616
from tests.multicluster.conftest import cluster_spec_list
1717

1818
RESOURCE_NAME = "multi-replica-set"

docker/mongodb-kubernetes-tests/tests/multicluster/multi_cluster_clusterwide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from kubetester.phase import Phase
1414
from pytest import fixture, mark
1515
from tests.conftest import (
16-
MULTI_CLUSTER_OPERATOR_NAME,
1716
_install_multi_cluster_operator,
1817
run_kube_config_creation_tool,
1918
)
2019

20+
from ..constants import MULTI_CLUSTER_OPERATOR_NAME
2121
from . import prepare_multi_cluster_namespaces
2222
from .conftest import cluster_spec_list, create_namespace
2323

docker/mongodb-kubernetes-tests/tests/multicluster/multi_cluster_reconcile_races.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
from kubetester.opsmanager import MongoDBOpsManager
1616
from kubetester.phase import Phase
1717
from tests.conftest import (
18-
MULTI_CLUSTER_OPERATOR_NAME,
19-
TELEMETRY_CONFIGMAP_NAME,
2018
get_central_cluster_client,
2119
get_custom_mdb_version,
2220
get_member_cluster_names,
2321
)
22+
from tests.constants import MULTI_CLUSTER_OPERATOR_NAME, TELEMETRY_CONFIGMAP_NAME
2423
from tests.multicluster.conftest import cluster_spec_list
2524

2625

0 commit comments

Comments
 (0)