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

fix Fifo queue delivers duplicate message(s) #3538

Merged
merged 6 commits into from
Dec 13, 2020

Conversation

irahulranjan
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Dec 11, 2020

Coverage Status

Coverage increased (+0.001%) to 94.57% when pulling 8fb538a on irahulranjan:localstack_issue_3339 into effb075 on spulec:master.

moto/sqs/models.py Outdated Show resolved Hide resolved
- move deduplication time to constants
- make tests parameterized
- update tests as per review comments
@irahulranjan
Copy link
Contributor Author

irahulranjan commented Dec 13, 2020

@BeyondEvil can you please help me out with the CI failure? I have run the tests in my machine using python 2.7, 3.6, 3.7, and 3.8 and all the tests are passing. I am having a hard time figuring out why it is failing in Travis.
Thanks..

@bblommers
Copy link
Collaborator

Hey @irahulranjan, the test are all failing in server mode, where Moto is run in a standalone Docker container.
The @mock.patch has no effect there, as it wouldn't change the value of DEDUPLICATION_TIME_IN_SECONDS inside the Docker container.

I don't really see how we would be able to test this inside a Docker container, so we can skip it in server mode like this:
https://github.com/spulec/moto/blob/master/tests/test_sqs/test_sqs.py#L1491

@irahulranjan
Copy link
Contributor Author

@bblommers Thanks for the help.

@BeyondEvil
Copy link

BeyondEvil commented Dec 13, 2020

Hey @irahulranjan, the test are all failing in server mode, where Moto is run in a standalone Docker container.
The @mock.patch has no effect there, as it wouldn't change the value of DEDUPLICATION_TIME_IN_SECONDS inside the Docker container.

I don't really see how we would be able to test this inside a Docker container, so we can skip it in server mode like this:
https://github.com/spulec/moto/blob/master/tests/test_sqs/test_sqs.py#L1491

Not exactly sure how the docker setup works, but you could change the DEDUPLICATION_TIME_IN_SECONDS to try and get it's value from the environment instead:

DEDUPLICATION_TIME_IN_SECONDS = os.getenv('DEDUPLICATION_TIME_IN_SECONDS', 300)

Then the test can set the env var to 1, either that will then get picked up by the docker runner automagically or it can be passed to the container when started.

Hope that makes sense @irahulranjan @bblommers

Edit:

Here you can add -e DEDUPLICATION_TIME_IN_SECONDS=1

Also, this is weird. It's first set to false and then to true? 🤔 🧐

@bblommers
Copy link
Collaborator

@BeyondEvil True, there are ways around it, but none of them pretty.
Changing the constant to read the environment variable means changing the code to make it more testable - which is always a code smell.
Passing the env-var to the Docker container means that value is set for the duration of the container lifetime - and we really only want to change it for the duration of a single test.

The weird travis.yml-notation is not setting the variable, but is used as a list of configurations. Travis will execute the tests once per configuration option (per python-version). That's why the list of test suites is executed twice per language, one with the env var set to True, one set to False.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @irahulranjan!

@bblommers bblommers merged commit 7b97141 into getmoto:master Dec 13, 2020
@BeyondEvil
Copy link

@BeyondEvil True, there are ways around it, but none of them pretty.
Changing the constant to read the environment variable means changing the code to make it more testable - which is always a code smell.

Fair enough.

Passing the env-var to the Docker container means that value is set for the duration of the container lifetime - and we really only want to change it for the duration of a single test.

True.

It's already merged. But does moto support some type of configuration framework? I guess something like that could've been leveraged in a scenario like this.

The weird travis.yml-notation is not setting the variable, but is used as a list of configurations. Travis will execute the tests once per configuration option (per python-version). That's why the list of test suites is executed twice per language, one with the env var set to True, one set to False.

Oh, really. Wow, that is weird. 😅

Thanks for taking the time to explain. 🙏

@bblommers
Copy link
Collaborator

It's already merged. But does moto support some type of configuration framework? I guess something like that could've been leveraged in a scenario like this.

No, not yet! I agree that would be useful, and will become more useful as we're getting more config options. One day.. 🤞

@bblommers
Copy link
Collaborator

This is now part of moto >= 1.3.16.dev181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants