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

Adds cache option to uplinks #132

Merged
merged 1 commit into from
Jun 8, 2017

Conversation

silkentrance
Copy link
Contributor

Open to discussion. Please review.

WIP: needs tests

[GH-131] add cache option to uplinks

lib/storage.js Outdated
@@ -246,7 +246,11 @@ Storage.prototype.get_tarball = function(name, filename) {
}, self.config)
}

var savestream = self.local.add_tarball(name, filename)
var savestream
var docache = !!uplink.cache
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: Any reason to have a double negation 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.

Yes, you are correct, this is rather unneccessary. Out of habit, I think...

@juanpicado
Copy link
Member

juanpicado commented May 23, 2017

I'm considering to merge this one, but I'd need a rebase from master and unit testing. Could you take a look #142 @silkentrance ?

@silkentrance
Copy link
Contributor Author

silkentrance commented Jun 1, 2017

@juanpicado Will do as soon as I find the time. Is tomorrow ok with you?

@juanpicado
Copy link
Member

@silkentrance sure, no problem, take your time 👍

@silkentrance silkentrance force-pushed the gh-131 branch 2 times, most recently from 2ec20fa to 62bd467 Compare June 1, 2017 19:48
@silkentrance
Copy link
Contributor Author

I also fixed the existing integration tests, namely I adjusted the sinopia-test-1.2.3.tgz package to match the requirements, renaming everything to verdaccio.

I also added test/integration/config_nocache.yaml and test/integration/test_nocache.pl.

I think that these integration tests need to be re-implemented 😁

The configuration uplink caching behavior is tested in test/unit/config.js.

@codecov
Copy link

codecov bot commented Jun 1, 2017

Codecov Report

Merging #132 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #132      +/-   ##
==========================================
+ Coverage   79.12%   79.18%   +0.05%     
==========================================
  Files          24       24              
  Lines        2247     2253       +6     
==========================================
+ Hits         1778     1784       +6     
  Misses        469      469
Impacted Files Coverage Δ
lib/storage.js 83.94% <100%> (+0.3%) ⬆️
lib/config.js 98.07% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c274168...7018fc9. Read the comment docs.

@juanpicado
Copy link
Member

juanpicado commented Jun 1, 2017

Awesome, I'll review it soon 👍

@silkentrance
Copy link
Contributor Author

ATM I am working on implementing the functional tests, but this may take a while. I need to get my head around the test cases first.

@silkentrance
Copy link
Contributor Author

@juanpicado I am having a hard time with the proper configuration of server3 (config-3.yaml) in test/functional. It will always fail with a 404 on get_package.

While the integration test works as expected, I cannot get it to work in the functional tests.

Maybe you can give me some hints on how to use the functional server test API?

Copy link
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

I'll need your feedback about the perl file, I have no clue :) the "why".

lib/storage.js Outdated
_autogenerated: true,
}, self.config);
}
let savestream = self.local.add_tarball(name, filename);
let savestream = null;
if (uplink.config.cache == true) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need == for true?

const PKG_NOCACHE = 'pkg_nocache';
const PKG_NOCACHE2 = 'pkg_nocache2';

function iscached(pkgname, tarballname) {
Copy link
Member

Choose a reason for hiding this comment

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

camelCase here please, isCache. The same in other functions. I'll enable camelCase eslint rule soon.

});

before(function() {
let pkg = require('./lib/package')(PKG_NOCACHE2);
Copy link
Member

Choose a reason for hiding this comment

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

const if the variable does not change

@@ -41,4 +42,5 @@ module.exports.start = function(dir, conf) {
process.on('exit', function() {
if (forks[0]) forks[0].kill();
Copy link
Member

Choose a reason for hiding this comment

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

Let's use curly braces, I'll enable that rule soon as well.

@@ -0,0 +1,17 @@
'use strict';

let assert = require('assert');
Copy link
Member

Choose a reason for hiding this comment

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

const for imports

@@ -2,6 +2,11 @@

let config = {
Copy link
Member

Choose a reason for hiding this comment

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

const here as well

@juanpicado
Copy link
Member

@silkentrance I'm testing your branch locally, to figure out the 404.

@silkentrance
Copy link
Contributor Author

@juanpicado will fix. thanks for looking into this. 👍

@juanpicado
Copy link
Member

@silkentrance the 404 seems to be because in your packages configuration for server3 you define pkg-nocache while in your test you define

const PKG_NOCACHE = 'pkg_nocache';
const PKG_NOCACHE2 = 'pkg_nocache2';

Thus, the uplinks are false, that drives you to 404. Then if you fix that the asserts are false, I do not know if the PKG_NOCACHE name is intended or not.

@silkentrance
Copy link
Contributor Author

@juanpicado Thanks so much for Findling

@silkentrance
Copy link
Contributor Author

silkentrance commented Jun 3, 2017

@juanpicado Thank you so much for finding this annoying typo. I will fix that right away incl. the issues you found in your review.

@silkentrance
Copy link
Contributor Author

Dunno why this was closed. Must have hit the wrong button...

@silkentrance
Copy link
Contributor Author

@juanpicado fixed issues and tests. rebased to master.

@juanpicado
Copy link
Member

Cool !! @silkentrance I'll review it asap

@juanpicado
Copy link
Member

Awesome work, unit testing widely complete 👍 thanks so much ! This goes to the next version.

@juanpicado juanpicado merged commit 0cabd62 into verdaccio:master Jun 8, 2017
@juanpicado juanpicado added this to the 2.1.8 milestone Jun 8, 2017
@silkentrance silkentrance deleted the gh-131 branch June 8, 2017 19:19
@lock
Copy link

lock bot commented May 31, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants