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

unable to upload screenshots/videos to S3 #51

Closed
dineshk-qa opened this issue Apr 15, 2020 · 7 comments
Closed

unable to upload screenshots/videos to S3 #51

dineshk-qa opened this issue Apr 15, 2020 · 7 comments
Assignees

Comments

@dineshk-qa
Copy link

dineshk-qa commented Apr 15, 2020

I used the CloudFormation template you provided to create and run the stack.
Director and dashboard services are working fine and results are displayed.
but S3 uploads are not working.
I have checked the aws role has the policy attached for respective S3 bucket put operations.
Here's the CloudWatch log extract:

 05:10:59
screenshotUploadUrls:
[{ readUrl:
'https://{bucketName}.s3.amazonaws.com/dbce2bcf6203650deb8575f73952ffe9.png',
uploadUrl:
'https://{bucketName}.s3.amazonaws.com/dbce2bcf6203650deb8575f73952ffe9.png?Content-Type=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=*****t&X-Amz-Date=20200415T051059Z&X-Amz-Expires=60&X-Amz-Security-Token=*****
screenshotId: 'qxjke' },
videoUploadInstructions:
{ readUrl:
'https://sorry-cypress-dev-test-results.s3.amazonaws.com/cb632523-cdb5-42d2-b33a-5dc9d3cd43da.mp4',
uploadUrl:
'https://{bucketName}.s3.amazonaws.com/cb632523-cdb5-42d2-b33a-5dc9d3cd43da.mp4?Content-Type=video%2Fmp4&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=****]

No error is displayed in log.
So it looks like it is uploading but there are no files in the bucket.
Although uploading error is shown in gitlab log

(Uploading Results)
   - Failed Uploading (1/3) /builds/qa/cypress-poc/cypress/screenshots/2_gift_cards_spec.js/Gift Cards Page Tests -- iframe demo - Verify user is able to buy gift cards (failed).png
   - Failed Uploading (2/3) /builds/qa/cypress-poc/cypress/screenshots/2_gift_cards_spec.js/Gift Cards Page Tests -- iframe demo - Verify user is able to buy gift cards (failed) (1).png
   - Failed Uploading (3/3) /builds/qa/cypress-poc/cypress/videos/2_gift_cards_spec.js.mp4

Is there any S3 related setting we need to in our cypress project.

@danielvianna
Copy link

I have the exact issue before then disappeared after 2 days - no clue what is causing on a specific machine, and on another one, it never happened (both are windows)
If you upload a file via postman (or similar tool) does the Amazon S3 API works fine?

@agoldis
Copy link
Collaborator

agoldis commented Apr 15, 2020

@dineshk-qa thanks for reporting the issue! Would be useful to run the failed tests locally with similar settings with DEBUG=cypress:* env variable to see if there are more details from cypress agent.

@dineshk-qa
Copy link
Author

dineshk-qa commented Apr 16, 2020

Here is Cypress in DEBUG mode
cypress:server:record failed to upload artifact { file: 'source/cypress-poc/cypress/screenshots/2_gift_cards_spec.js/Gift Cards Page Tests -- iframe demo - buy gift cards (failed).png', stack: 'StatusCodeError: 400 - "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n<Error><Code>InvalidArgument</Code><Message></Message><ArgumentName>x-amz-acl</ArgumentName><ArgumentValue>ap-southeast-2</ArgumentValue><RequestId>xxxxx</RequestId> <HostId>xxxxxxxxx</HostId> </Error>

Getting 400 due to Invalid argument > x-amz-acl: ap-southeast-2

@danielvianna - Yes uploading through postman is working fine, but I have checked using my user not that role

@EddyQiu
Copy link

EddyQiu commented Apr 16, 2020

I've found something interesting in the docker.io/agoldis/sorry-cypress-director image in the path /app/src/screenshots/s3

# cat config.ts export const S3_BUCKET = process.env.S3_BUCKET || 'sorry-cypress'; export const S3_REGION = process.env.S3_REGION || 'us-east-1'; export const S3_ACL = process.env.S3_REGION || 'public-read'; export const S3_READ_URL_PREFIX = process.env.S3_READ_URL_PREFIX || null;

Does the S3_ACL need to be set to a region?
Because when I set the S3_REGION to ap-southeast-2 it will also change the S3_ACL to ap-southeast-2 when we want it to be 'public-read'

Thanks,
Eddy

@EddyQiu
Copy link

EddyQiu commented Apr 16, 2020

I believe the fix for this would be just to change the line
export const S3_ACL = process.env.S3_REGION || 'public-read';
to be:
export const S3_ACL = process.env.S3_ACL || 'public-read';

@agoldis
Copy link
Collaborator

agoldis commented Apr 16, 2020

There was a bug introduced in the latests release. Should be fixed in https://github.com/agoldis/sorry-cypress/releases/tag/v0.2.5.

@dineshk-qa Please tell me if that somehow resolves the issue, because the issue was opened before the bug was introduced 😃

@dineshk-qa
Copy link
Author

@agoldis actually our S3 bucket was hosted in ap-southeast-2 and we were not setting the region and it was taking the default value, so we had that issue.
It just coincided with your changes :)
All working fine now after the above fix, I can see images/videos in the dashboard.
Thanks for so quick response & fix.

@agoldis agoldis self-assigned this Apr 16, 2020
@agoldis agoldis closed this as completed Apr 16, 2020
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

4 participants