-
Notifications
You must be signed in to change notification settings - Fork 205
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
Dereference symlink when displaying needle info #2738
Conversation
I set this PR as WIP because I need to add test code. |
Codecov Report
@@ Coverage Diff @@
## master #2738 +/- ##
==========================================
- Coverage 92.14% 92.14% -0.01%
==========================================
Files 187 187
Lines 11728 11734 +6
==========================================
+ Hits 10807 10812 +5
- Misses 921 922 +1
Continue to review full report at Codecov.
|
Already added the test code. Ready for review. |
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.
Please use e.g. $needle->path
in all the places you're currently duplicating that function like $needle->directory->path . '/' . $needle->filename
.
This slightly decreases the AJAX loading time (~ 0.0399 secs => ~ 0.0583 secs with OSD data) but I guess it is still ok. Good that this table is using server-side rendering.
Thanks for the reminder. I did not know the |
my %needles_record_real_path = map { | ||
$_->path => { | ||
needle_file_real_path => realpath($_->path), | ||
last_seen => $_->last_seen_time || 'never', | ||
last_match => $_->last_matched_time || 'never', | ||
} | ||
} $needles->all; |
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.
The duplication is worrysome. I don't understand why you also need to update here what is done later in the next while-loop. We can at least extract a function for the initialisation for last_seen+last_match. Maybe you have an even better idea.
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.
Yes. You could for instance create a simple mapping from path to DBIx object: my %needles_record_real_path = map { $_->path => $_ } $needles->all
and access the DBIx object directly in the loop below where you do the "never"-fallback only one time in the end like this:
$hash->{last_seen} ||= 'never';
$hash->{last_match} ||= 'never';
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.
I modified the code, please help to review if it is the way that you suggested. Thanks
my $symlink_needle_dir_id = $needle_dir->create( | ||
{ | ||
path => $symlink_needle_dir . '/needles', | ||
name => 'symlink_needle_dir' | ||
})->id; | ||
my $real_needle_dir_id = $needle_dir->create( | ||
{ | ||
path => $real_needle_dir . '/needles', | ||
name => 'real_needle_dir' | ||
})->id; |
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.
you can do a for loop to apply the same for both dirs.
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.
I think it is ok. The assignment is to different variables and the 2 hash entries are different.
$driver->find_element('.dataTables_filter input')->send_keys("bootloader"); | ||
wait_for_ajax; | ||
my @needle_trs = $driver->find_elements('#needles tbody tr'); |
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.
maybe you can take a look into #2626 and use wait_for_element
instead of the combination of wait_for_ajax
and find_elements
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.
I tried to use wait_for_element
, but failed to get the array of tr
using this function.
t/ui/21-admin-needles.t
Outdated
is((shift @symlink_needle_tds)->get_text(), 'symlink_needle_dir', 'symlink needle dir is right'); | ||
is((shift @symlink_needle_tds)->get_text(), 'bootloader.json', 'symlink needle file name is right'); | ||
is((shift @symlink_needle_tds)->get_text(), 'a day ago', 'symlink needle last use is right'); | ||
is((shift @symlink_needle_tds)->get_text(), 'about 14 hours ago', 'symlink needle last match is right'); |
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.
I guess we can find better explanations than "… is right". Can you be more specific?
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.
I changed is right
to is displayed correct
, does it make sense? :)
my %needles_record_real_path = map { | ||
$_->path => { | ||
needle_file_real_path => realpath($_->path), | ||
last_seen => $_->last_seen_time || 'never', | ||
last_match => $_->last_matched_time || 'never', | ||
} | ||
} $needles->all; |
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.
Yes. You could for instance create a simple mapping from path to DBIx object: my %needles_record_real_path = map { $_->path => $_ } $needles->all
and access the DBIx object directly in the loop below where you do the "never"-fallback only one time in the end like this:
$hash->{last_seen} ||= 'never';
$hash->{last_match} ||= 'never';
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.
I think it's ok like it is now
t/ui/21-admin-needles.t
Outdated
like( | ||
$driver->find_child_element($last_matched_td, 'a')->get_attribute('href'), | ||
qr/admin\/needles\/$last_matched_module_id\/$real_needle_id/, | ||
'symlink needle last used module link is correctly' |
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.
Just a grammar nitpick: I believe in this case it should be 'correct' instead of 'correctly' (after is usually comes an adjective and not an adverb).
"fullstack" failed with something about "Live View". The fullstack test should retry but failed after first try. Maybe I have caused this with a recent change. I retriggered the failed test. |
There is a bug in PR os-autoinst#2738. If the symlink needle is not loaded with the real needle file together, the last seen and last match of the symlink needle are still 'Never'. Related ticket: https://progress.opensuse.org/issues/53762#note-9
There is a bug in PR os-autoinst#2738. If the symlink needle is not loaded with the real needle file together, the last seen and last match of the symlink needle are still 'Never'. Related ticket: https://progress.opensuse.org/issues/53762#note-9
There is a bug in PR os-autoinst#2738. If the symlink needle is not loaded with the real needle file together, the last seen and last match of the symlink needle are still 'Never'. Related ticket: https://progress.opensuse.org/issues/53762#note-9
There is a bug in PR os-autoinst#2738. If the symlink needle is not loaded with the real needle file together, the last seen and last match of the symlink needle are still 'Never'. Related ticket: https://progress.opensuse.org/issues/53762#note-9
There is a bug in PR os-autoinst#2738. If the symlink needle is not loaded with the real needle file together, the last seen and last match of the symlink needle are still 'Never'. Related ticket: https://progress.opensuse.org/issues/53762#note-9
See: https://progress.opensuse.org/issues/53762