-
Notifications
You must be signed in to change notification settings - Fork 53
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
Issue #315 - Added mtime attribute #411
Conversation
Job #411 is now in scope, role is |
@yegor256 One test was failing also on master so never mind, but the test_all_scripts is failing quite strangely, I tried to understand how that test works but I suppose you can help me with it. |
This pull request #411 is assigned to @ledestin/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @yegor256/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be a monetary reward for this job |
lib/zold/remotes.rb
Outdated
@@ -120,6 +121,7 @@ def initialize(file, network: 'test') | |||
raise 'Network can\'t be nil' if network.nil? | |||
@network = network | |||
@mutex = Mutex.new | |||
read_mtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa have you seen this? https://www.yegor256.com/2015/05/07/ctors-must-be-code-free.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 Ok fixed
lib/zold/remotes.rb
Outdated
@@ -242,9 +244,16 @@ def if_present(host, port) | |||
save(list) | |||
end | |||
|
|||
def read_mtime | |||
CSV.read(file, skip_lines: /.+,\d+,\d+,\d+/).map do |r| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa r
is probably better off as row
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledestin You are right, it is much more clear
lib/zold/remotes.rb
Outdated
@mutex.synchronize do | ||
raw = CSV.read(file).map do |r| | ||
raw = CSV.read(file, skip_lines: /mtime,\d+/).map do |r| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa why not use the filesystem mtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledestin It is a very good idea, implemented. Thanks a lot!
@emilianodellacasa please see my comments |
Codecov Report
@@ Coverage Diff @@
## master #411 +/- ##
==========================================
+ Coverage 32.56% 32.88% +0.31%
==========================================
Files 59 58 -1
Lines 2822 2746 -76
==========================================
- Hits 919 903 -16
+ Misses 1903 1843 -60
Continue to review full report at Codecov.
|
lib/zold/node/front.rb
Outdated
mtime: settings.remotes.mtime.utc.iso8601, | ||
all: settings.remotes.all | ||
all: settings.remotes.all, | ||
mtime: settings.remotes.mtime.utc.iso8601 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 This is the offending line that breaks the test_all_scripts test. If you remove it the test is green, red otherwise.
However, the code works perfectly as I also tried to call the remote endpoint from the same test, and the generated JSON is what is expected. Any comment on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 It is the redeploy_on_upgrade that is failing, I cannot understand why. Could you explain how it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 This has been solved in last commit, thanks anyway
test/test_remotes.rb
Outdated
file = File.join(dir, 'remotes') | ||
FileUtils.touch(file) | ||
File.write(file, "127,0,0,0\n") | ||
mtime_on_file = Time.now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa it this works, the test is probably is broken or there's a race here. I'd load mtime from the file here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledestin Correct
test/test_remotes.rb
Outdated
def test_read_mtime_from_file | ||
Dir.mktmpdir 'test' do |dir| | ||
file = File.join(dir, 'remotes') | ||
FileUtils.touch(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa I think mtime
is updated on write anyway, so no need for touch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledestin Definitely, I removed the touch thanks a lot
@emilianodellacasa please see my comments |
@ledestin I worked on your comments and fixed the problem with the test, please check |
@ledestin ping |
@@ -62,6 +63,10 @@ def all | |||
def iterate(_) | |||
# Nothing to do here | |||
end | |||
|
|||
def mtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa since you add this, why do you need attr_reader
? Unless it's defined in a different class.
@emilianodellacasa please see my comment |
@ledestin You are right, I needed to have a fixed value, but it is better to set this value on the initilizer; I have also refactored a little bit and merged some code, it should be everything ok now; |
@@ -187,7 +190,7 @@ def iterate(log, farm: Farm::Empty.new) | |||
network: @network | |||
) | |||
idx += 1 | |||
raise 'Took too long to execute' if (Time.now - start).round > @timeout | |||
raise 'Took too long to execute' if (Time.now - start).round > timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa have you heard of Timeout.timeout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ledestin Actually this is something I merged from another issue, I didn't do that: in any case, I will take a look at it :-)
@yegor256 looks fine to me |
@yegor256 I have never seen that error before, please try merging again |
@yegor256 ping |
test/node/test_entrance.rb
Outdated
@@ -60,6 +60,7 @@ def test_pushes_wallet | |||
end | |||
|
|||
def test_renders_json | |||
skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa you can't just skip a test. You have to explain why and add a puzzle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilianodellacasa see above |
@yegor256 answered |
@yegor256 ping |
@emilianodellacasa we should not leave |
@yegor256 I have added the puzzle as requested |
@yegor256 In this case Travis failed because tests took too long |
@rultor merge |
@ypshenychka/z please review this job completed by @ledestin/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed |
The job #411 is now out of scope |
@ypshenychka Done |
@emilianodellacasa thanks |
@0crat quality acceptable |
Quality review completed: +8 point(s) just awarded to @ypshenychka/z |
Fixed issue #315. I have added an mtime attribute returning the last time the list has been updated. The same value is saved the the remote file, with a slightly different format.