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

win_get_url - Make checksum work more like ansible.builtin.get_url #718

Merged

Conversation

KBjorndal-VizRT
Copy link
Contributor

SUMMARY

Makes checksum handling behave more like ansible.builtin.get_url

Fixes #717

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

win_get_url

ADDITIONAL INFORMATION

I'm not 100% sure about the logic to trigger collecting $dest_checksum, it is technically called in some circumstances it wasn't before, though if I read the code right that was only in error cases since all normal exits would calculate it at the end of the script.

@KBjorndal-VizRT KBjorndal-VizRT force-pushed the 717-win_get_url-checksum branch from dc9c0da to 52c681b Compare January 2, 2025 08:19
Copy link
Collaborator

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

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

The changes you've added here look good. Appreciate you updating the docs and adding the changelog fragment but are you also able to add a test for this specific scenario. We currently have some tests with the checksum option under https://github.com/ansible-collections/ansible.windows/blob/main/tests/integration/targets/win_get_url/tasks/tests_checksum.yml but it doesn't look like there are any ones for idempotency checking when force: false is set.

If you need help with any of this please let me know and I can guide you where I can.

plugins/modules/win_get_url.py Outdated Show resolved Hide resolved
Knut Arne Bjørndal and others added 2 commits January 8, 2025 14:33
@KBjorndal-VizRT
Copy link
Contributor Author

The changes you've added here look good. Appreciate you updating the docs and adding the changelog fragment but are you also able to add a test for this specific scenario. We currently have some tests with the checksum option under https://github.com/ansible-collections/ansible.windows/blob/main/tests/integration/targets/win_get_url/tasks/tests_checksum.yml but it doesn't look like there are any ones for idempotency checking when force: false is set.

I added a test for the behaviour where it shouldn't do any download if checksum already matches.

Tried a few different ways but can't think of how to make an automated test for the other part. As far as I can see httpbin only sends 304 replies for the /cache endpoint, which otherwise returns dynamic data so it's impossible to make it emulate the case where we have a file that differs by checksum but the If-Modified-Since logic would say there is nothing new at the URL.

@KBjorndal-VizRT
Copy link
Contributor Author

Not sure what the failing check here is about, is it related to the PR or some CI infrastructure?

@jborean93
Copy link
Collaborator

I added a test for the behaviour where it shouldn't do any download if checksum already matches.

Thanks, appreciate it.

Tried a few different ways but can't think of how to make an automated test for the other part. As far as I can see httpbin only sends 304 replies for the /cache endpoint, which otherwise returns dynamic data so it's impossible to make it emulate the case where we have a file that differs by checksum but the If-Modified-Since logic would say there is nothing new at the URL.

I think that's fine to ignore for now, if we get any future regressions we can look at potentially spinning up a custom HTTP endpoint just as a test but I think that's overkill for now.

Not sure what the failing check here is about, is it related to the PR or some CI infrastructure?

There seems to be some trouble with Zuul so the failure is unrelated here.

@jborean93 jborean93 merged commit 8862da5 into ansible-collections:main Jan 9, 2025
45 of 46 checks passed
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.

win_get_url checksum does not work as expected with force=false
2 participants