Skip to content

Add failing test for broker url priority ref issue #4284 - #4285

Closed
Checkroth wants to merge 2 commits into
celery:masterfrom
Checkroth:master
Closed

Checkroth wants to merge 2 commits into
celery:masterfrom
Checkroth:master

Conversation

@Checkroth

Copy link
Copy Markdown

Description

This PR is to assist in showing the issue described here: #4284

All this PR does is add a failing test that should be passing, if the issue above is resolved.

This PR does not solve the issue mentioned. I leave that up to the discretion of a more knowledgeable party, if they decide that it is indeed an issue at all. I do not expect this PR to be merged unless the issue is resolved and you want this test to remain in the repository.

Comment thread t/unit/app/test_utils.py
self.app.conf.broker_url = prepatch_broker_url
monkeypatch.setenv('CELERY_BROKER_URL',
'memory://thisshouldntbethebroker')
assert self.app.conf.broker_url == prepatch_broker_url

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The application configuration has already been resolved at this stage, so I think this test case does not actually prove the issue. Configuration cannot be changed dynamically.

@Checkroth Checkroth Sep 25, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I got that feeling when I wrote this, however calling self.app.conf.broker_url after setting it to prepatch_broker_url, but before setting CELERY_BROKER_URL in the environment, it does return the prepatch_broker_url string

I've added a second test demonstrating this

@auvipy auvipy added this to the v4.2 milestone Dec 19, 2017

@auvipy auvipy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

whats the status of the test? seems 2nd testcase was added @georgepsarakis

@georgepsarakis

Copy link
Copy Markdown
Contributor

@Checkroth @auvipy I think the configuration works as expected. Please consider the following:

import os
from celery.app.utils import Settings  # sub-class of celery.utils.collections.ConfigurationView
configuration = Settings(dict(broker_url='amqp://hello.world'))
print configuration.broker_url  # amqp://hello.world
os.environ['CELERY_BROKER_URL'] = 'amqp://hello.world.from.environment.variable'
print configuration.broker_url  # amqp://hello.world.from.environment.variable

I hope the priority is clearer now.

However your test seems to raise another question regarding the behavior of ConfigurationView and properties in sub-classes such as Settings.broker_url; an exception should have been raised when you try to set a value for broker_url and this does not happen. Perhaps AttributeDictMixin is responsible for this.

@auvipy auvipy modified the milestones: v4.2, v5.0.0 Jan 13, 2018
@Checkroth

Copy link
Copy Markdown
Author

@georgepsarakis Thank you for clarifying.

My initial issue was that, when explicitly setting your Celery config, the broker url would read from your environment variables rather than your explicit setting if CELERY_BROKER_URL was set.

It appears that this is by design, so this pull request adds no value to Celery. I will write my thoughts on the issue over at #4284 , because I still feel that there is something to be done to avoid this confusion in the future.

@Checkroth Checkroth closed this Apr 24, 2018
@auvipy auvipy removed this from the v5.0.0 milestone May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants