Skip to content

Commit 2cd6a3d

Browse files
committed
Add DEFAULT_HELM_CHART_PATH env var
1 parent 91a6b65 commit 2cd6a3d

File tree

8 files changed

+27
-47
lines changed

8 files changed

+27
-47
lines changed

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import uuid
66
from typing import Dict, List, Optional, Tuple
77

8-
from kubetester.consts import (
8+
from tests import test_logger
9+
from tests.constants import (
10+
DEFAULT_HELM_CHART_PATH_ENV_VAR_NAME,
911
OCI_HELM_REGION_ENV_VAR_NAME,
1012
OCI_HELM_REGISTRY_ENV_VAR_NAME,
11-
OCI_HELM_REPOSITORY_ENV_VAR_NAME,
12-
OCI_HELM_VERSION,
13+
OCI_HELM_VERSION_ENV_VAR_NAME,
1314
)
14-
from tests import test_logger
1515

1616
logger = test_logger.get_test_logger(__name__)
1717

@@ -241,19 +241,6 @@ def helm_upgrade(
241241
process_run_and_check(command, check=True, capture_output=True, shell=True)
242242

243243

244-
# oci_chart_info returns the respective registry/repo and region information
245-
# based on the build scenario (dev/staging) tests are being run in. These are
246-
# read from build_info.json and then set to the tests image as env vars.
247-
def oci_chart_info():
248-
registry = os.environ.get(OCI_HELM_REGISTRY_ENV_VAR_NAME)
249-
repository = os.environ.get(OCI_HELM_REPOSITORY_ENV_VAR_NAME)
250-
region = os.environ.get(OCI_HELM_REGION_ENV_VAR_NAME)
251-
252-
logger.info(f"oci chart details in test image is registry {registry}, repo {repository}, region {region}")
253-
254-
return registry, f"{repository}/mongodb-kubernetes", region
255-
256-
257244
def apply_crds_from_chart(crds_dir: str):
258245
crd_files = glob.glob(os.path.join(crds_dir, "*.yaml"))
259246

@@ -308,28 +295,22 @@ def _create_helm_args(helm_args: Dict[str, str], helm_options: Optional[List[str
308295
# based on the caller. In most of the cases we will install chart from OCI registry but for the tests where we would like
309296
# to install MEKO's specific version or MCK's specific version, we would expect `helm_chart_path` to set already.
310297
def helm_chart_path_and_version(helm_chart_path: str, operator_version: str) -> tuple[str, str]:
311-
# these are imported here to resolve import cycle issue
312-
from tests.conftest import LOCAL_HELM_CHART_DIR, local_operator
313-
314-
if local_operator():
315-
return LOCAL_HELM_CHART_DIR, ""
316-
317-
# helm_chart_path not being passed would mean we would like to install helm chart from OCI registry.
298+
# if helm_chart_path is not passed, use the default value from DEFAULT_HELM_CHART_PATH
318299
if not helm_chart_path:
300+
helm_chart_path = os.getenv(DEFAULT_HELM_CHART_PATH_ENV_VAR_NAME)
301+
302+
if helm_chart_path.startswith("oci://"):
319303
# If operator_version is not passed, we want to install the current version.
320304
if not operator_version:
321-
operator_version = os.environ.get(OCI_HELM_VERSION)
305+
operator_version = os.environ.get(OCI_HELM_VERSION_ENV_VAR_NAME)
322306

323-
registry, repository, region = oci_chart_info()
307+
registry = os.environ.get(OCI_HELM_REGISTRY_ENV_VAR_NAME)
324308
# If ECR we need to login first to the OCI container registry
325309
if registry == OCI_HELM_REGISTRY_ECR:
310+
region = os.environ.get(OCI_HELM_REGION_ENV_VAR_NAME)
326311
try:
327312
helm_registry_login_to_ecr(registry, region)
328313
except Exception as e:
329314
raise Exception(f"Failed to login to ECR helm registry {registry}. Error: {e}")
330315

331-
# figure out the registry URI, based on dev/staging scenario
332-
chart_uri = f"oci://{registry}/{repository}"
333-
helm_chart_path = chart_uri
334-
335316
return helm_chart_path, operator_version

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
helm_upgrade,
1919
)
2020
from tests import test_logger
21-
from tests.constants import LOCAL_HELM_CHART_DIR
2221

2322
OPERATOR_CRDS = (
2423
"mongodb.mongodb.com",

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
LEGACY_OPERATOR_CHART,
4545
LEGACY_OPERATOR_IMAGE_NAME,
4646
LEGACY_OPERATOR_NAME,
47-
LOCAL_HELM_CHART_DIR,
4847
MCK_HELM_CHART,
4948
MONITOR_APPDB_E2E_DEFAULT,
5049
MULTI_CLUSTER_CONFIG_DIR,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
LEGACY_DEPLOYMENT_STATE_VERSION: str = "1.27.0"
1717

1818
# Helm charts
19+
DEFAULT_HELM_CHART_PATH_ENV_VAR_NAME = "DEFAULT_HELM_CHART_PATH"
20+
21+
OCI_HELM_VERSION_ENV_VAR_NAME = "OCI_HELM_VERSION"
22+
OCI_HELM_REGISTRY_ENV_VAR_NAME = "OCI_HELM_REGISTRY"
23+
OCI_HELM_REPOSITORY_ENV_VAR_NAME = "OCI_HELM_REPOSITORY"
24+
OCI_HELM_REGION_ENV_VAR_NAME = "OCI_HELM_REGION"
25+
1926
LEGACY_OPERATOR_CHART = "mongodb/enterprise-operator"
2027
MCK_HELM_CHART = "mongodb/mongodb-kubernetes"
2128
LOCAL_HELM_CHART_DIR = "helm_chart"

scripts/dev/contexts/local-defaults-context

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ export ALWAYS_REMOVE_TESTING_NAMESPACE="true"
4040
# MCO settings
4141
## whether we want to run cleanup after the run
4242
export PERFORM_CLEANUP=false
43+
44+
# Specifies default local path to the helm charts if not specified explicitly in e2e test.
45+
export DEFAULT_HELM_CHART_PATH="${PROJECT_DIR}/helm_chart"

scripts/dev/contexts/private-context-template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ export PRERELEASE_PULLSECRET_DOCKERCONFIGJSON="<dockerconfigjson secret>"
101101

102102
# uncomment to enable license update with pre-commit script
103103
# export MDB_UPDATE_LICENSES=true
104+
105+
# Uncomment to specify a custom path to the helm chart if not specified explicitly in e2e test.
106+
# It can point to OCI registry, GitHub pages based url or custom directory.
107+
# export DEFAULT_HELM_CHART_PATH=""

scripts/evergreen/deployments/test-app/templates/mongodb-enterprise-tests.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,16 @@ spec:
174174
- name: OM_DEBUG_HTTP
175175
value: "{{ .Values.omDebugHttp }}"
176176
{{ end }}
177-
{{ if .Values.helm.oci.version }}
178177
- name: OCI_HELM_VERSION
179178
value: "{{ .Values.helm.oci.version }}"
180-
{{ end }}
181-
{{ if .Values.helm.oci.registry }}
182179
- name: OCI_HELM_REGISTRY
183180
value: "{{ .Values.helm.oci.registry }}"
184-
{{ end }}
185-
{{ if .Values.helm.oci.repository }}
186181
- name: OCI_HELM_REPOSITORY
187182
value: "{{ .Values.helm.oci.repository }}"
188-
{{ end }}
189-
{{ if .Values.helm.oci.region }}
190183
- name: OCI_HELM_REGION
191184
value: "{{ .Values.helm.oci.region }}"
192-
{{ end }}
185+
- name: DEFAULT_HELM_CHART_PATH
186+
value: "oci://{{ .Values.helm.oci.registry }}/{{ .Values.helm.oci.repository }}/mongodb-kubernetes"
193187
- name: ops_manager_version
194188
value: "{{ .Values.opsManagerVersion }}"
195189
- name: cognito_user_pool_id

0 commit comments

Comments
 (0)