Skip to content

Conversation

lsierant
Copy link
Contributor

@lsierant lsierant commented Jun 3, 2025

Summary

This patch allows to deploy more than one database managed by cloud-qa in a single e2e test.
Currently it's only possible under Ops Manager tests which deploys it in the same test. With cloud-qa single test always used one project for the whole test with project_name=$NAMESPACE.

Deploying more than one database resource was therefore difficult and required manually crafting my-project config maps.

Additionally, this PR allows to reuse the whole test in both OM and cloud-qa tests with little changes to the code.

How does it work for OM?
Multiple mdb resources under OM are possible thanks to resource.configure() function, which requires to pass MongoDBOpsManager resource. It creates -project config map and credentials secret by using api keys that are available because there is an OM instance deployed in the same test.

How it was for cloud-qa tests?
Our tests were able to use only one "my-project" config map and credentials, which is created before the test pod is scheduled (configure_operator.sh). It contains fixed project name, which equals to the current namespace (a random string in CI). Reusing this config map leads to attempting to deploy mdb resource in the same cloud-qa project, which then the operator rejects.

What this PR changes for cloud-qa tests?
We hook into configure function allowing for passing None as ops manager resource. In this case we clone my-project config map and overwrite projectId to '{namespace}-{resourceName}'. The operator will then create a new cloud-qa project with that name allowing for running multiple cloud-qa-managed resources in one test.

Refactored existing tests

Some tests were refactored to remove unnecessary manual project config maps:

  • docker/mongodb-kubernetes-tests/tests/authentication/mongodb_custom_roles.py
  • docker/mongodb-kubernetes-tests/tests/multicluster/multi_cluster_scale_up_cluster.py
  • docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py
  • docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_snippets.py
  • docker/mongodb-kubernetes-tests/tests/replicaset/replica_set_agent_flags.py

Proof of Work

project config map was created (the default my-project is not used)
evg link

- apiVersion: v1
  data:
    baseUrl: http://om-backup-tls-svc.a-1758578405-qd641twddhz.svc.cluster.local:8080/
    orgId: ""
    projectName: sh-disaster-recovery
  kind: ConfigMap
  metadata:
    creationTimestamp: "2025-09-22T22:19:40Z"
    name: sh-disaster-recovery-config
    namespace: a-1758578405-qd641twddhz
    resourceVersion: "3609"

    uid: 86dd4283-6d2e-44cb-84dc-d87b3fc57cae

which is automatically referenced in MongoDB resource
evg link

  opsManager:
      configMapRef:
        name: sh-disaster-recovery-config

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?

Reminder (Please remove this when merging)

  • Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible
  • Our Short Guide for PRs: Link
  • Remember the following Communication Standards - use comment prefixes for clarity:
    • blocking: Must be addressed before approval.
    • follow-up: Can be addressed in a later PR or ticket.
    • q: Clarifying question.
    • nit: Non-blocking suggestions.
    • note: Side-note, non-actionable. Example: Praise
    • --> no prefix is considered a question

@lsierant lsierant mentioned this pull request Jun 3, 2025
3 tasks
@lsierant lsierant force-pushed the lsierant/pytest-refactor branch from 043f6e7 to 93baf39 Compare June 3, 2025 11:29
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch from 4ba55b0 to 8515b05 Compare June 3, 2025 11:30
@lsierant lsierant force-pushed the lsierant/pytest-refactor branch from 93baf39 to 35c3435 Compare June 4, 2025 06:38
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch from 8515b05 to 5ee79b4 Compare June 4, 2025 06:38
@lsierant
Copy link
Contributor Author

lsierant commented Jun 4, 2025

evergreen retry

lsierant added a commit that referenced this pull request Jun 4, 2025
# Summary

This PR contains no functional changes - only moving functions around. 
It's extracting common bits imported from different places to their own
files which resolves *some* cyclic dependencies in the code.
It's by no means a complete refactor, it's an extracted refactor from
the followup change (#173) which triggered cyclic dependencies in the
first place.

## Proof of Work

[Green
EVG](https://spruce.mongodb.com/version/683fe9d44e8b7f0007877a9e/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC)

## Checklist
- [ ] Have you linked a jira ticket and/or is the ticket in the title?
- [ ] Have you checked whether your jira ticket required DOCSP changes?
- [ ] Have you checked for release_note changes?

## Reminder (Please remove this when merging)
- Please try to Approve or Reject Changes the PR, keep PRs in review as
short as possible
- Our Short Guide for PRs:
[Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0)
- Remember the following Communication Standards - use comment prefixes
for clarity:
  * **blocking**: Must be addressed before approval.
  * **follow-up**: Can be addressed in a later PR or ticket.
  * **q**: Clarifying question.
  * **nit**: Non-blocking suggestions.
  * **note**: Side-note, non-actionable. Example: Praise 
  * --> no prefix is considered a question
Base automatically changed from lsierant/pytest-refactor to master June 4, 2025 18:05
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch 2 times, most recently from 5bd8491 to 94a69a9 Compare June 9, 2025 21:55
@lsierant
Copy link
Contributor Author

evergreen refresh

@lsierant
Copy link
Contributor Author

Try to use this in docker/mongodb-kubernetes-tests/tests/authentication/mongodb_custom_roles.py when #54 is merged

@lsierant
Copy link
Contributor Author

lsierant commented Jul 1, 2025

Adjust it here after #206 is merged as well

@lsierant lsierant mentioned this pull request Jul 1, 2025
3 tasks
@lsierant
Copy link
Contributor Author

lsierant commented Jul 2, 2025

q from @nammn: can you check whether those new projects are properly cleaned up in cloudmanager?

@lsierant lsierant mentioned this pull request Sep 18, 2025
3 tasks
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch from 94a69a9 to b053f96 Compare September 18, 2025 21:18
Copy link

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.4.1 Release Notes

@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch 2 times, most recently from 8689e2c to 5509206 Compare September 22, 2025 19:18
@lsierant lsierant added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Sep 22, 2025
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch 2 times, most recently from f262059 to 4964f58 Compare September 22, 2025 20:18
cat > "${wrapper_script}" << EOF
#!/bin/bash
# Define kubectl function to include the context
set -x
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this saves tons of log spamming when deploying csi drivers while creating kind clusters


func (m *MongoDBMultiCluster) GetProjectConfigMapName() string {
return m.Spec.OpsManagerConfig.ConfigMapRef.Name
return m.Spec.GetProject()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is release notes worthy. It was a bug that caused that MongoDBMultiCluster could handle only spec.opsManager field, but in MongoDB we handle both spec.opsManager and spec.cloudManager via GetProject()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah its a bug fix, should be in RN.

@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch 4 times, most recently from 6245e5c to f432eb6 Compare September 23, 2025 07:19
@lsierant lsierant marked this pull request as ready for review September 23, 2025 07:32
@lsierant lsierant requested a review from a team as a code owner September 23, 2025 07:32
@lsierant lsierant requested review from m1kola and nammn September 23, 2025 07:32
@lsierant lsierant force-pushed the lsierant/multi-cloud-qa branch from fa19d3d to de8fd69 Compare September 23, 2025 20:30
Copy link
Collaborator

@nammn nammn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

PTAL at my comments


func (m *MongoDBMultiCluster) GetProjectConfigMapName() string {
return m.Spec.OpsManagerConfig.ConfigMapRef.Name
return m.Spec.GetProject()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah its a bug fix, should be in RN.

export TEST_MODE=opsmanager
export OPS_MANAGER_REGISTRY="${BASE_REPO_URL}"

export ops_manager_version="${CUSTOM_OM_VERSION}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only here? Was it missing on the other variables? could we just rely on CUSTOM_OM_VERSION everywhere instead and remove ops_manager_version everywhere else instead?

om: Optional[MongoDBOpsManager],
project_name: str,
api_client: Optional[client.ApiClient] = None,
) -> MongoDB:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about a log line -> "we are running om vs cloudqa"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Use this label in Pull Request to not require new changelog entry file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants