Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set EDXAPP_TEST_MONGO_HOST=mongodb in openedx-dev #1083

Merged

Conversation

kdmccormick
Copy link
Collaborator

Currently, we are asking devs to set this env var manually before they run tests.

Why not just set it in the development image for them?

@kdmccormick kdmccormick requested a review from regisb June 24, 2024 19:49
@@ -275,6 +275,9 @@ RUN pip install -e "/mnt/{{ name }}"
# Add ipdb as default PYTHONBREAKPOINT
ENV PYTHONBREAKPOINT=ipdb.set_trace

# Point unit tests at the MongoDB container
ENV EDXAPP_TEST_MONGO_HOST=mongodb
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to point to {{ MONGODB_HOST }}, and not "mongodb", in case MongoDB runs outside of Tutor. Same for MONGO_PORT_NUM = {{ MONGODB_PORT }}. But then, we don't want to make the image build depend on user configuration, so we should not store these settings here...

I don't have a better alternative to offer that does not break compatibility with devstack... I think that test settings should be overridable, and that xmodule/modulestore/tests/mongo_connection.py should not read EDXAPP_TEST_MONGO_HOST. But that would break the current behaviour.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But then, we don't want to make the image build depend on user configuration, so we should not store these settings here...

I'm not sure I follow. There are several other points in the Dockerfile that depend on user configuration. As long as the setting has a reasonable default value that most people will use (i.e., mongodb), it seems fine to me to build that into the image, no?

I don't have a better alternative to offer that does not break compatibility with devstack... I think that test settings should be overridable, and that xmodule/modulestore/tests/mongo_connection.py should not read EDXAPP_TEST_MONGO_HOST. But that would break the current behaviour.

Agreed, the tests ought to use the MONGO_HOST and MONGO_PORT_NUM Django settings. The way that they currently ignore the settings and look up the env vars directly is so very wrong.

Devstack is deprecated, and starting right after that Sumac cut, we are no longer obligated to avoid breaking it. Regardless of whether you accept this PR, let's make the upstream fix this October.

Copy link
Contributor

@DawoudSheraz DawoudSheraz Jul 9, 2024

Choose a reason for hiding this comment

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

Régis has already added his comment/context. Once those are resolved, this will be good to go.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kdmccormick Hi, what's plan for this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@regisb

I think we want to point to {{ MONGODB_HOST }}, and not "mongodb", in case MongoDB runs outside of Tutor. Same for MONGO_PORT_NUM = {{ MONGODB_PORT }}.

Done 👍🏻

I don't have a better alternative to offer that does not break compatibility with devstack... I think that test settings should be overridable, and that xmodule/modulestore/tests/mongo_connection.py should not read EDXAPP_TEST_MONGO_HOST. But that would break the current behaviour.

I poked around at simplifying this. I think that the only proper fix is to drop the EDXAPP_TEST_MONGO_* env vars and get rid of the MONGO_* Django settings, as they are all only used in tests. What prod uses is DOC_STORE_CONFIG -- test settings should override pieces of that. Unfortunately that's too much for me to bite off right now, but I'm hoping I can address this (and other bad config patterns) in openedx/edx-platform#35146

In the meantime, I still think this simplification would be valuable to Tutor users. Can you re-review @regisb ?

@DawoudSheraz DawoudSheraz self-requested a review June 25, 2024 09:06
@kdmccormick kdmccormick requested a review from regisb August 20, 2024 15:36
@@ -0,0 +1 @@
[Improvement] Set `EDXAPP_TEST_MONGO_HOST` env var in the openedx-dev image so that it no longer needs to be set by hand when running edx-platform unit tests (by @kdmccormick).
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a changelog entry for this, considering this is only meant for dev/testing and wont impact the operators as such?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since Tutor is both an operator tool and a developer tool, I think it is good to make not of the improvements we make for developers too.

@kdmccormick kdmccormick merged commit 6cdeddd into overhangio:master Aug 27, 2024
2 checks passed
@kdmccormick kdmccormick deleted the kdmccormick/test-mongo-host branch August 27, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants