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

Issue #315 - Added mtime attribute #411

Merged
merged 25 commits into from
Sep 18, 2018
Merged

Conversation

emilianodellacasa
Copy link
Contributor

@emilianodellacasa emilianodellacasa commented Jul 18, 2018

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.

@0crat 0crat added the scope label Jul 18, 2018
@0crat
Copy link
Collaborator

0crat commented Jul 18, 2018

Job #411 is now in scope, role is REV

@emilianodellacasa
Copy link
Contributor Author

@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.

@0crat
Copy link
Collaborator

0crat commented Jul 18, 2018

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

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@emilianodellacasa emilianodellacasa Jul 23, 2018

Choose a reason for hiding this comment

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

@yegor256 Ok fixed

@@ -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|
Copy link
Contributor

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

Copy link
Contributor Author

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

@mutex.synchronize do
raw = CSV.read(file).map do |r|
raw = CSV.read(file, skip_lines: /mtime,\d+/).map do |r|
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@ledestin
Copy link
Contributor

@emilianodellacasa please see my comments

@codecov-io
Copy link

codecov-io commented Jul 23, 2018

Codecov Report

Merging #411 into master will increase coverage by 0.31%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/zold/node/front.rb 35.74% <ø> (-0.2%) ⬇️
lib/zold/remotes.rb 34.69% <33.33%> (+1.36%) ⬆️
lib/zold/http.rb 50.9% <0%> (-1.93%) ⬇️
lib/zold/node/async_entrance.rb 23.43% <0%> (-1.18%) ⬇️
lib/zold/copies.rb 22.47% <0%> (-0.87%) ⬇️
lib/zold/commands/pay.rb 22.22% <0%> (ø) ⬆️
lib/zold/tree_wallets.rb
lib/zold/commands/node.rb 20.48% <0%> (+1.2%) ⬆️
... and 4 more

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 de083a8...4d45cf8. Read the comment docs.

mtime: settings.remotes.mtime.utc.iso8601,
all: settings.remotes.all
all: settings.remotes.all,
mtime: settings.remotes.mtime.utc.iso8601
Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

@emilianodellacasa emilianodellacasa Jul 24, 2018

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

file = File.join(dir, 'remotes')
FileUtils.touch(file)
File.write(file, "127,0,0,0\n")
mtime_on_file = Time.now
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ledestin Correct

def test_read_mtime_from_file
Dir.mktmpdir 'test' do |dir|
file = File.join(dir, 'remotes')
FileUtils.touch(file)
Copy link
Contributor

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.

Copy link
Contributor Author

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

@ledestin
Copy link
Contributor

@emilianodellacasa please see my comments

@0crat
Copy link
Collaborator

0crat commented Jul 23, 2018

@ledestin/z this job was assigned to you 5days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

@emilianodellacasa
Copy link
Contributor Author

@ledestin I worked on your comments and fixed the problem with the test, please check

@emilianodellacasa
Copy link
Contributor Author

@ledestin ping

@@ -62,6 +63,10 @@ def all
def iterate(_)
# Nothing to do here
end

def mtime
Copy link
Contributor

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.

@ledestin
Copy link
Contributor

@emilianodellacasa please see my comment

@emilianodellacasa
Copy link
Contributor Author

@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
Copy link
Contributor

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?

Copy link
Contributor Author

@emilianodellacasa emilianodellacasa Jul 27, 2018

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 :-)

@ledestin
Copy link
Contributor

@yegor256 looks fine to me

@emilianodellacasa
Copy link
Contributor Author

@yegor256 I have never seen that error before, please try merging again

@emilianodellacasa
Copy link
Contributor Author

@yegor256 ping

@@ -60,6 +60,7 @@ def test_pushes_wallet
end

def test_renders_json
skip
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yegor256 it is the same test for which I have opened an issue #425, and that I already skipped in PR #428, opening a puzzle now wouldn't make any sense

@yegor256
Copy link
Collaborator

yegor256 commented Aug 9, 2018

@emilianodellacasa see above

@emilianodellacasa
Copy link
Contributor Author

@yegor256 answered

@emilianodellacasa
Copy link
Contributor Author

@yegor256 ping

@yegor256
Copy link
Collaborator

@emilianodellacasa we should not leave skip in the code without any notice. In the future, in a few months, another programmer may ask -- what is that? Where will he/she find an answer?

@emilianodellacasa
Copy link
Contributor Author

@yegor256 I have added the puzzle as requested

@emilianodellacasa
Copy link
Contributor Author

@yegor256 In this case Travis failed because tests took too long

@yegor256
Copy link
Collaborator

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Sep 18, 2018

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 4d45cf8 into zold-io:master Sep 18, 2018
@rultor
Copy link
Collaborator

rultor commented Sep 18, 2018

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 9min)

@emilianodellacasa emilianodellacasa deleted the issue_315 branch September 18, 2018 07:33
@0crat
Copy link
Collaborator

0crat commented Sep 18, 2018

@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

@0crat 0crat removed the scope label Sep 18, 2018
@0crat
Copy link
Collaborator

0crat commented Sep 18, 2018

The job #411 is now out of scope

@0crat
Copy link
Collaborator

0crat commented Sep 18, 2018

Payment to ARC for a closed pull request, as in §28: +10 point(s) just awarded to @yegor256/z

@ypshenychka
Copy link

@emilianodellacasa According to our QA rules:

Messages in a job always start with a name of a user they are addressed to

Please correct your code review comments (here, here and here) by indicating an addressee in the beginning.

@emilianodellacasa
Copy link
Contributor Author

@ypshenychka Done

@ypshenychka
Copy link

@emilianodellacasa thanks

@ypshenychka
Copy link

@0crat quality acceptable

@0crat
Copy link
Collaborator

0crat commented Sep 18, 2018

Order was finished, quality is "acceptable": +15 point(s) just awarded to @ledestin/z

@0crat
Copy link
Collaborator

0crat commented Sep 18, 2018

Quality review completed: +8 point(s) just awarded to @ypshenychka/z

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

Successfully merging this pull request may close these issues.

7 participants