Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Server tests et al #3363

Merged
merged 7 commits into from
Aug 17, 2017
Merged

Server tests et al #3363

merged 7 commits into from
Aug 17, 2017

Conversation

ianb
Copy link
Contributor

@ianb ianb commented Aug 16, 2017

No description provided.

ianb added 6 commits August 16, 2017 15:04
Make the tests no longer be executable, since the test runner runs
Note: test succeeds (despite what I expected from #3290)
Timing is logged when it goes over a configurable limit. Locations are logged based on caller filename/position
@ianb ianb changed the title Server tests Server tests et al Aug 16, 2017
@ianb
Copy link
Contributor Author

ianb commented Aug 16, 2017

This turned into a bucket of things, but I'll cut it off here for review

@jaredhirsch
Copy link
Member

just curious, what is the purpose of tracking image sizes in the database?

@ianb
Copy link
Contributor Author

ianb commented Aug 16, 2017

For future reporting: during some performance discussions we realized we didn't know how big (in bytes) images were, and certainly couldn't see if some users had a particularly large set of images.

Copy link
Member

@jaredhirsch jaredhirsch left a comment

Choose a reason for hiding this comment

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

Some questions for you 🍻

// This happens when getCallerPosition detects we shouldn't time this function call
return doNothing;
}
let start = Date.now();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe process.hrtime instead, to get a high resolution timestamp?

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 looked at process.hrtime, but it splits the time into two numbers, and seemed complicated to work with. We don't really care about anything that's less than (or even close to) 1ms anyway.

@@ -115,9 +124,11 @@ exports.transaction = function(func) {
exports.del = exports.update;

exports.exec = function(sql, args) {
let timer = initTiming();
return getConnection().then(function([client, done]) {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be useful to track slow connection times as well? Maybe shove a second timer in 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.

As I think about it, I somehow remember that we removed connection pooling. But I'm not sure. It might be good for a followup, but I'd be surprised if we saw anything interesting.

return doNothing;
}
let caller = getCallerPosition(2);
if (caller == "skip") {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little bit confused by this getCallerPosition-related stuff, it seems a little dangerously clever.

Could we instead issue the timing calls from the files that call into db.js, like servershot.js? That might be an opportunity to pass a label into initTiming to identify the query, which would make it directly greppable. Would also get us moving in the direction of adding timing for arbitrary other events.

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 guess I was trying to make this minimal, without adding a bunch of stuff throughout the codebase. Given that, it required some cleverness to identify queries (there might have been an option to identify queries based on the SQL, but then there's a question of how to uniquely identify SQL without putting every query into the log).

But I don't think this should be forever code... like, this code isn't Mr. Right, just Mr. Right Now.

Copy link
Member

Choose a reason for hiding this comment

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

lol ok

@@ -856,6 +856,10 @@ Shot.upgradeSearch = function() {
return resolve();
}
Shot.get("upgrade_search_only", rows[index].id).then((shot) => {
// This shouldn't really happen, but apparently can...
Copy link
Member

Choose a reason for hiding this comment

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

Is this related to another bug, or just something unfiled that you ran into?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something weird in my local database, I don't know if it was due to testing or some latent bug I didn't notice before.

@ianb
Copy link
Contributor Author

ianb commented Aug 17, 2017

It also has occurred to me that I added npm run test:server, but it doesn't run in CI

Copy link
Member

@jaredhirsch jaredhirsch left a comment

Choose a reason for hiding this comment

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

let's do it

@jaredhirsch jaredhirsch merged commit c34dae2 into master Aug 17, 2017
@jaredhirsch jaredhirsch deleted the server-tests branch August 17, 2017 17:08
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.

2 participants