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

Resizer might be broken #36

Open
Mo0rBy opened this issue Sep 3, 2024 · 2 comments
Open

Resizer might be broken #36

Mo0rBy opened this issue Sep 3, 2024 · 2 comments

Comments

@Mo0rBy
Copy link

Mo0rBy commented Sep 3, 2024

Hello,

I came across this when trying to test out LocalStack and what it can do.

I clone this repo and deployed the application using the bin/deploy.sh and it all looked good, I could access the website URL and it looked to be all good.

I ran the tests and get the following output:

============================= test session starts ==============================
platform darwin -- Python 3.11.6, pytest-8.3.2, pluggy-1.5.0 -- /Users/wmoorby/.pyenv/versions/3.11.6/bin/python3.11
cachedir: .pytest_cache
rootdir: /Users/wmoorby/Library/CloudStorage/OneDrive(O365)/sample-serverless-image-resizer-s3-lambda
collecting ... collected 2 items

tests/test_integration.py::test_s3_resize_integration FAILED             [ 50%]
tests/test_integration.py::test_failure_sns_to_ses_integration PASSED    [100%]

=================================== FAILURES ===================================
__________________________ test_s3_resize_integration __________________________

    def test_s3_resize_integration():
        file = os.path.join(os.path.dirname(__file__), "nyan-cat.png")
        key = os.path.basename(file)
    
        parameter = ssm.get_parameter(Name="/localstack-thumbnail-app/buckets/images")
        source_bucket = parameter["Parameter"]["Value"]
    
        parameter = ssm.get_parameter(Name="/localstack-thumbnail-app/buckets/resized")
        target_bucket = parameter["Parameter"]["Value"]
    
        s3.upload_file(file, Bucket=source_bucket, Key=key)
    
        # wait for the resized image to appear
>       s3.get_waiter("object_exists").wait(Bucket=target_bucket, Key=key)

tests/test_integration.py:51: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/Users/wmoorby/.pyenv/versions/3.11.6/lib/python3.11/site-packages/botocore/waiter.py:55: in wait
    Waiter.wait(self, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <botocore.waiter.S3.Waiter.ObjectExists object at 0x103421b10>
kwargs = {'Bucket': 'localstack-thumbnails-app-resized', 'Key': 'nyan-cat.png'}
acceptors = [<botocore.waiter.AcceptorConfig object at 0x103421bd0>, <botocore.waiter.AcceptorConfig object at 0x103423110>]
current_state = 'retry', config = {}, sleep_amount = 5, max_attempts = 20
last_matched_acceptor = <botocore.waiter.AcceptorConfig object at 0x103423110>
num_attempts = 20

    def wait(self, **kwargs):
        acceptors = list(self.config.acceptors)
        current_state = 'waiting'
        # pop the invocation specific config
        config = kwargs.pop('WaiterConfig', {})
        sleep_amount = config.get('Delay', self.config.delay)
        max_attempts = config.get('MaxAttempts', self.config.max_attempts)
        last_matched_acceptor = None
        num_attempts = 0
    
        while True:
            response = self._operation_method(**kwargs)
            num_attempts += 1
            for acceptor in acceptors:
                if acceptor.matcher_func(response):
                    last_matched_acceptor = acceptor
                    current_state = acceptor.state
                    break
            else:
                # If none of the acceptors matched, we should
                # transition to the failure state if an error
                # response was received.
                if is_valid_waiter_error(response):
                    # Transition to a failure state, which we
                    # can just handle here by raising an exception.
                    raise WaiterError(
                        name=self.name,
                        reason='An error occurred ({}): {}'.format(
                            response['Error'].get('Code', 'Unknown'),
                            response['Error'].get('Message', 'Unknown'),
                        ),
                        last_response=response,
                    )
            if current_state == 'success':
                logger.debug(
                    "Waiting complete, waiter matched the " "success state."
                )
                return
            if current_state == 'failure':
                reason = f'Waiter encountered a terminal failure state: {acceptor.explanation}'
                raise WaiterError(
                    name=self.name,
                    reason=reason,
                    last_response=response,
                )
            if num_attempts >= max_attempts:
                if last_matched_acceptor is None:
                    reason = 'Max attempts exceeded'
                else:
                    reason = (
                        f'Max attempts exceeded. Previously accepted state: '
                        f'{acceptor.explanation}'
                    )
>               raise WaiterError(
                    name=self.name,
                    reason=reason,
                    last_response=response,
                )
E               botocore.exceptions.WaiterError: Waiter ObjectExists failed: Max attempts exceeded. Previously accepted state: Matched expected HTTP status code: 404

/Users/wmoorby/.pyenv/versions/3.11.6/lib/python3.11/site-packages/botocore/waiter.py:387: WaiterError
=========================== short test summary info ============================
FAILED tests/test_integration.py::test_s3_resize_integration - botocore.excep...
==================== 1 failed, 1 passed in 96.89s (0:01:36) ====================

I double checked the website I was running + the video in this repo, and it looks like the resizing part actually doesn't work.
I noticed this as there was no resize number of bytes when attempting to resize an image in the UI.

Here is a screenshot of my hosted application:
Screenshot 2024-09-03 at 16 16 46

And here it is from the video in this repo:
Screenshot 2024-09-03 at 16 18 18

I'm not really sure if this is an actual error within the python resizing script or if there is something wrong with my setup (I don't know what would be, I just cloned the repo and ran the included deploy script).

@abidkhan484
Copy link

@Mo0rBy, Have you found any error while running the deployment script?

@Mo0rBy
Copy link
Author

Mo0rBy commented Dec 5, 2024

@abidkhan484 I don't know where the error is exactly.
Been a while since I've looked at this now but from what I remember, there were no errors or issues when deploying this, I just saw that 1 of the pytest tests was failing.
Initially I thought that it must be the test that was broken as this is a nice and simple setup that probably was created and then never touched again due to the fact that it's a tutorial repo.

So I looked at the test code and then realised with the screenshots above, the actual webapp page doesn't work in the way that it should.

So like I said, don't know exactly where the issue is occurring, but I believe it's related to the actual deployment of the resources, not the test that needs updating.

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

No branches or pull requests

2 participants