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

Dereference symlink when displaying needle info #2738

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

Amrysliu
Copy link
Contributor

@Amrysliu Amrysliu commented Feb 7, 2020

@Amrysliu
Copy link
Contributor Author

Amrysliu commented Feb 7, 2020

I set this PR as WIP because I need to add test code.
After the modification, the UI will shown as the picture in this ticket's description (after.png).

@codecov
Copy link

codecov bot commented Feb 7, 2020

Codecov Report

Merging #2738 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/OpenQA/WebAPI/Controller/Admin/Needle.pm 79.31% <100%> (+2.38%) ⬆️
lib/OpenQA/Worker/Engines/isotovideo.pm 92.98% <0%> (-0.44%) ⬇️

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 fa28b31...87486fb. Read the comment docs.

@Amrysliu Amrysliu changed the title [WIP] Dereference symlink when displaying needle info Dereference symlink when displaying needle info Feb 17, 2020
@Amrysliu
Copy link
Contributor Author

I set this PR as WIP because I need to add test code.
After the modification, the UI will shown as the picture in this ticket's description (after.png).

Already added the test code. Ready for review.

@Martchus Martchus self-requested a review February 17, 2020 10:44
Copy link
Contributor

@Martchus Martchus left a 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.

t/ui/21-admin-needles.t Outdated Show resolved Hide resolved
t/ui/21-admin-needles.t Outdated Show resolved Hide resolved
@Amrysliu
Copy link
Contributor Author

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 path function before.

Comment on lines 82 to 88
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;
Copy link
Member

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.

Copy link
Contributor

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';

Copy link
Contributor Author

@Amrysliu Amrysliu Feb 21, 2020

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

Comment on lines +120 to +129
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;
Copy link
Member

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.

Copy link
Contributor

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.

Comment on lines +154 to +160
$driver->find_element('.dataTables_filter input')->send_keys("bootloader");
wait_for_ajax;
my @needle_trs = $driver->find_elements('#needles tbody tr');
Copy link
Member

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

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 tried to use wait_for_element, but failed to get the array of tr using this function.

Comment on lines 159 to 162
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');
Copy link
Member

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?

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 changed is right to is displayed correct, does it make sense? :)

Comment on lines 82 to 88
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;
Copy link
Contributor

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';

lib/OpenQA/WebAPI/Controller/Admin/Needle.pm Outdated Show resolved Hide resolved
Copy link
Member

@okurz okurz left a 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

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

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

@okurz
Copy link
Member

okurz commented Feb 25, 2020

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

@okurz okurz merged commit 1a487f6 into os-autoinst:master Feb 25, 2020
Amrysliu added a commit to Amrysliu/openQA that referenced this pull request Feb 28, 2020
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
Amrysliu added a commit to Amrysliu/openQA that referenced this pull request Feb 28, 2020
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
Amrysliu added a commit to Amrysliu/openQA that referenced this pull request Feb 28, 2020
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
Amrysliu added a commit to Amrysliu/openQA that referenced this pull request Feb 29, 2020
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
Amrysliu added a commit to Amrysliu/openQA that referenced this pull request Mar 11, 2020
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
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.

3 participants