Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Conversation

@jonasfj
Copy link
Contributor

@jonasfj jonasfj commented Apr 16, 2018

We only do this for new the blob artifacts, as they are not in wide-spread use yet.
Hence, as we adopt them people will have time to switch over.

@jonasfj jonasfj requested a review from jhford April 16, 2018 11:23
@jonasfj
Copy link
Contributor Author

jonasfj commented Apr 16, 2018

I think my editor also removed some trailing whitespaces... But getting rid of those is just a bonus I guess.

Copy link
Contributor

@jhford jhford left a comment

Choose a reason for hiding this comment

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

Please use existing code where it makes sense instead of reimplementing functionality. The existing code does much more exhaustive checks.

src/artifacts.js Outdated
'available in one of these encodings.',
'',
'To download this artifact the request must support `Content-Encoding: {{contentEncoding}}`,',
'the request can indicating by setting `Accept-Encoding` accordingly.',
Copy link
Contributor

Choose a reason for hiding this comment

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

'the request can indicating by setting Accept-Encoding accordingly.',

Let's go all the way and suggest "Try using Accept-Encoding: {{contentEncoding}}" :)

src/data.js Outdated
* contentEncoding: Content encoding, such as 'gzip',
* NOTE: This property is not present if contentEncoding is 'identity'.
* contentSha256: Hex encoded sha256 hash of the un-encoded artifact
* contentLength: Size of the un-encoded artifact
Copy link
Contributor

@jhford jhford Apr 16, 2018

Choose a reason for hiding this comment

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

Number of bytes is more specific, and so more accurate than "size", let's leave it as number of bytes as that's exactly what it is.

* to determine if the operation would result in an idempotency
* error
* contentEncoding: Content encoding, such as 'gzip',
* NOTE: This property is not present if contentEncoding is 'identity'.
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought if not present, we would store 'identity' there, am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I look at the code yes... maybe we have default in the schema and I missed that.. but then we have unnecessary special cases in the code.

src/data.js Outdated
* NOTE: This property is not present if contentEncoding is 'identity'.
* transferSha256: Hax encooded sha256 hash of the content-encoding encoded artifact,
* NOTE: This property is not present if contentEncoding is 'identity'.
* provider: Always 's3'
Copy link
Contributor

Choose a reason for hiding this comment

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

Knowing this is very likely to change at some point in this year, let's say "Currently always 's3' but might change later"

src/data.js Outdated
* transferSha256: Hax encooded sha256 hash of the content-encoding encoded artifact,
* NOTE: This property is not present if contentEncoding is 'identity'.
* provider: Always 's3'
* region: Always 'us-west-2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Knowing this is very likely to change at some point in this year, let's say "Currently always 'us-west-2' but might change later"

}],
});

debug('### Put first part of artifact');
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean the only part :)

});

debug('### Put first part of artifact');
const {method, url, headers} = requests[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Please match the way that all the other blob-type unit tests run uploads instead of reimplementing it.

      let uploadOutcome = await client.runUpload(response.requests, uploadInfo);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually want to test the REST APIs work as documented in api.declare?

I'm not interested in testing that some client library works. Our public interface is the REST API, if the REST API breaks I want to know about it.

To be honest, I considered going all the way down to require('http') and use that instead of superagent, because I can about the HTTP level correctness.

note: I don't mind having the other tests, it's great to have more test coverage.

contentSha256: crypto.createHash('sha256').update(data).digest('hex'),
transferLength: gzipped.length,
transferSha256: crypto.createHash('sha256').update(gzipped).digest('hex'),
parts: [{
Copy link
Contributor

Choose a reason for hiding this comment

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

This is testing single part uploads according to the test name and all the artifact names used, but you're doing a multipart upload with a single part. Please delete the parts list from the request to do a true single part upload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, interesting... :)

I didn't notice this. let's talk about it tomorrow.

taskId, 0, 'public/singlepart.dat',
);
debug('### Fetching artifact from: %s', artifactUrl);
const res2 = await request.get(artifactUrl).responseType('blob');
Copy link
Contributor

Choose a reason for hiding this comment

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

There's already code for doing this:

      await verifyDownload(artifact.headers.location, bigfilehash, bigfilesize);

Please use this code as it's what we do for all the other tests and handles many more tests than are duplicated here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tried adding it that won't work because of content-encoding.


debug('### Downloading artifact with incorrect "Accept-Encoding"');
let e;
await request.get(artifactUrl).set('Accept-Encoding', 'identity').catch(err => e = err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also test for no Accept-Encoding value set, since that's by far the more likely scenario in reality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

identity is the same thing as setting no accept-encoding.

Copy link
Contributor

Choose a reason for hiding this comment

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

but it should also be one extra line to account for us doing something incorrectly and handling the two different options differently.

@jonasfj jonasfj force-pushed the limit-blob-accept-gzip branch from 54561b7 to d8905a8 Compare April 20, 2018 13:54
@jonasfj
Copy link
Contributor Author

jonasfj commented Apr 20, 2018

@jhford, I'm not sure how well, we want to test this... We basically have to do everything manually with http if you want perfect tests.

IMO this exercises all aspect of the code added. If we want better tests we'll need to write a lot of low-level, and that won't be nice to maintain.

@jonasfj jonasfj requested a review from jhford April 20, 2018 13:56
@jhford
Copy link
Contributor

jhford commented Apr 23, 2018

The code that does the verify stuff is written using the standard library's HTTP library already, so I think we should just use that. Adding support for content-encoding to those functions should be pretty trivial.

@jhford
Copy link
Contributor

jhford commented Apr 23, 2018

in the case of verifyDownload, it's already actually directly using the system's http and https libraries :)

@djmitche
Copy link
Contributor

djmitche commented Jan 4, 2019

highly bitrotted..

@djmitche djmitche closed this Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants