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

fix virtual systems listing filters #8265

Merged

Conversation

rjpmestre
Copy link
Contributor

@rjpmestre rjpmestre commented Feb 5, 2024

What does this PR change?

This PR fixes virtual system listing and enhances its filtering system. It adds a new dropdown input field. This will allow users to select either "Virtual Host" or "Virtual System" as the target for their query.

GUI diff

Before:

image

After:

image

  • DONE

Documentation

  • No documentation needed: There is a GUI difference but the granularity its not high enough to cover these filters.

  • DONE

Test coverage

  • Unit tests were added

  • DONE

Links

Issue(s): https://github.com/SUSE/spacewalk/issues/21192

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

Before you merge

Check How to branch and merge properly!

@rjpmestre rjpmestre requested review from a team as code owners February 5, 2024 13:42
@rjpmestre rjpmestre self-assigned this Feb 5, 2024
Copy link
Contributor

github-actions bot commented Feb 5, 2024

👋 Hello! Thanks for contributing to our project.
Acceptance tests will take some time (aprox. 1h), please be patient ☕
You can see the progress at the end of this page and at https://github.com/uyuni-project/uyuni/pull/8265/checks
Once tests finish, if they fail, you can check 👀 the cucumber report. See the link at the output of the action.
You can also check the artifacts section, which contains the logs at https://github.com/uyuni-project/uyuni/pull/8265/checks.

If you are unsure the failing tests are related to your code, you can check the "reference jobs". These are jobs that run on a scheduled time with code from master. If they fail for the same reason as your build, it means the tests or the infrastructure are broken. If they do not fail, but yours do, it means it is related to your code.

Reference tests:

KNOWN ISSUES

Sometimes the build can fail when pulling new jar files from download.opensuse.org . This is a known limitation. Given this happens rarely, when it does, all you need to do is rerun the test. Sorry for the inconvenience.

For more tips on troubleshooting, see the troubleshooting guide.

Happy hacking!
⚠️ You should not merge if acceptance tests fail to pass. ⚠️

Copy link
Contributor

github-actions bot commented Feb 5, 2024

Suggested tests to cover this Pull Request
  • min_deblike_openscap_audit
  • sle_minion
  • proxy_branch_network
  • srv_push_package
  • srv_menu
  • srv_datepicker
  • buildhost_osimage_build_image
  • srv_restart
  • min_ssh_tunnel
  • min_rhlike_salt_install_package_and_patch
  • min_retracted_patches
  • min_bootstrap_api
  • srv_first_settings
  • srv_advanced_search
  • srv_patches_page
  • min_salt_formulas
  • min_salt_lock_packages
  • srv_users
  • srv_handle_software_channels_with_ISS_v2
  • srv_cobbler_sync
  • srv_reportdb
  • min_salt_minions_page
  • min_rhlike_openscap_audit
  • srv_salt
  • allcli_action_chain
  • srv_docker_cve_audit
  • srv_power_management
  • minssh_move_from_and_to_proxy
  • srv_organization_credentials
  • min_salt_mgrcompat_state
  • min_deblike_monitoring
  • proxy_cobbler_pxeboot
  • min_cve_id_new_syntax
  • srv_scc_user_credentials
  • min_bootstrap_script
  • srv_logfile
  • proxy_as_pod_basic_tests
  • allcli_system_group
  • buildhost_bootstrap
  • srv_monitoring
  • min_rhlike_salt
  • min_config_state_channel_subscriptions
  • srv_wait_for_reposync
  • min_custom_pkg_download_endpoint
  • srv_mainpage
  • srv_create_activationkey
  • min_ansible_control_node
  • min_virthost
  • srv_rename_hostname
  • srv_check_reposync
  • min_salt_formulas_advanced
  • srv_handle_config_channels_with_ISS_v2
  • min_project_lotus
  • srv_change_password
  • min_salt_pkgset_beacon
  • srv_check_channels_page
  • min_check_patches_install
  • srv_user_configuration_salt_states
  • min_salt_install_with_staging
  • allcli_reboot
  • buildhost_docker_auth_registry
  • allcli_sanity
  • min_deblike_salt_install_with_staging
  • min_rhlike_ssh
  • srv_clone_channel_npn
  • allcli_update_activationkeys
  • min_cve_audit
  • min_deblike_salt
  • srv_distro_cobbler
  • srv_docker_advanced_content_management
  • srv_add_rocky8_repositories
  • srv_custom_system_info
  • srv_sync_channels
  • min_move_from_and_to_proxy
  • srv_salt_download_endpoint
  • minssh_action_chain
  • minkvm_guests
  • min_activationkey
  • srv_maintenance_windows
  • min_bootstrap_negative
  • min_bootstrap_reactivation
  • min_timezone
  • min_salt_software_states
  • min_empty_system_profiles
  • srv_enable_sync_products
  • srv_create_repository
  • srv_virtual_host_manager
  • min_config_state_channel
  • min_deblike_salt_install_package
  • srv_manage_channels_page
  • minssh_ansible_control_node
  • proxy_register_as_minion_with_script
  • srv_power_management_api
  • proxy_retail_pxeboot_and_mass_import
  • min_salt_install_package
  • minssh_bootstrap_api
  • min_monitoring
  • min_rhlike_monitoring
  • min_docker_api
  • min_action_chain
  • min_salt_openscap_audit
  • min_salt_minion_details
  • srv_channel_api
  • srv_check_sync_source_packages
  • srv_payg_ssh_connection
  • srv_cobbler_distro
  • srv_activationkey_api
  • allcli_config_channel
  • minssh_salt_install_package
  • srv_cobbler_profile
  • min_recurring_action
  • srv_delete_channel_from_ui
  • srv_dist_channel_mapping
  • srv_user_preferences
  • srv_group_union_intersection
  • min_salt_user_states
  • srv_power_management_redfish
  • srv_task_status_engine
  • srv_delete_channel_with_tool
  • sle_ssh_minion
  • min_rhlike_remote_command
  • min_config_state_channel_api
  • allcli_overview_systems_details
  • srv_content_lifecycle
  • min_deblike_ssh
  • min_deblike_remote_command
  • srv_osimage
  • buildhost_docker_build_image
  • srv_channels_add
  • min_change_software_channel
  • srv_change_task_schedule
  • srv_cobbler_buildiso
  • allcli_software_channels_dependencies
  • srv_notifications
  • min_salt_migration
  • srv_disable_local_repos_off
  • min_bootstrap_ssh_key
  • allcli_software_channels

@rjpmestre rjpmestre marked this pull request as draft February 5, 2024 14:06
@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch 3 times, most recently from 169a0f4 to aff153f Compare February 7, 2024 17:46
@rjpmestre rjpmestre marked this pull request as ready for review February 7, 2024 19:20
@rjpmestre rjpmestre requested a review from cbosdo February 7, 2024 19:20
Comment on lines 1165 to 1166
"COALESCE(RS.name, '(none)') AS virtual_host_name, " +
"COALESCE(VII.name, '(none)') AS virtual_vm_name, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to change the names here as this will imply additional fields and getters/setters in the DTO.

@@ -67,7 +68,8 @@ public VirtualSystemOverview(Tuple tuple) {
stateLabel = getTupleValue(tuple, "state_label", String.class).orElse(null);
vcpus = getTupleValue(tuple, "vcpus", Number.class).map(Number::longValue).orElse(0L);
memory = getTupleValue(tuple, "memory", Number.class).map(Number::longValue).orElse(0L);
hostServerName = getTupleValue(tuple, "host_server_name", String.class).orElse(null);
virtualHostName = getTupleValue(tuple, "virtual_host_name", String.class).orElse(null);
virtualVmName = getTupleValue(tuple, "virtual_vm_name", String.class).orElse(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

server_name is setup the parent class IIRC. There is no need to add another field for it

Comment on lines 70 to 71
hostServerName = getTupleValue(tuple, "host_server_name", String.class).orElse(null);
virtualHostName = getTupleValue(tuple, "virtual_host_name", String.class).orElse(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why changing the field name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, you're right, it goes in line with the original names. already rolled it back

Comment on lines 155 to 165
"hostServerName", "host_server_name",
"name", "VII.name",
defaultFilterColumn, "RS.name",
"virtual_vm_name", "VII.name",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this rename is really needed

import java.util.Optional;
import java.util.function.Supplier;

public final class Predicates {
Copy link
Contributor

Choose a reason for hiding this comment

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

You are probably missing a Javadoc comment for this class

@@ -52,6 +52,15 @@ const allListOptions = [
{ value: "group_count", label: t("Groups") },
];

const virtualSystemsListOptions = [
{ value: "virtual_host_name", label: t("Virtual Host Name") },
{ value: "virtual_vm_name", label: t("Virtual VM Name") },
Copy link
Contributor

Choose a reason for hiding this comment

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

virtual VM is a pleonasm, either use virtual guest, virtual machine or just vm

@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch from aff153f to 6498937 Compare February 8, 2024 13:09
@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch from 6498937 to e1fbd32 Compare February 8, 2024 13:12
@rjpmestre rjpmestre requested a review from cbosdo February 8, 2024 21:23
Comment on lines 73 to 71
header={t("Virtual System")}
header={t("Virtual Machine")}
Copy link
Contributor

Choose a reason for hiding this comment

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

Better not change this name: the word System is used all over the place in the user interface and docs to refer to a machine. But this is nitpicking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got you! Updated the label on the dropdown as well.

@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch from e1fbd32 to d59fbe9 Compare February 9, 2024 10:48
@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch from d59fbe9 to 236d6d7 Compare February 9, 2024 10:57
Copy link
Contributor

@cbbayburt cbbayburt left a comment

Choose a reason for hiding this comment

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

Thanks, @rjpmestre!

I left 2 minor comments below.

Also, thanks for extensive testing, and introducing parametrized tests ❤️

Comment on lines 154 to 177
/**
* Determines whether a CharSequence is null or blank, ie, containing only whitespace characters.
*
* @param value the CharSequence to be evaluated
* @return true if the CharSequence is null or blank
*/
public static boolean isBlank(final CharSequence value) {
if (isNull(value)) {
return true;
}

int length = value.length();
if (length == 0) {
return true;
}

for (int i = 0; i < length; i++) {
if (!Character.isWhitespace(value.charAt(i))) {
return false;
}
}

return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is already available in StringUtils

Copy link
Contributor Author

@rjpmestre rjpmestre Feb 14, 2024

Choose a reason for hiding this comment

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

Yeah, you're right. I had this sitting for a while now and i cannot recall exactly the small detail this was supposed to address/cover. Well, i should've commented back then. Lets stick to apache's StringUtils.

Comment on lines 298 to 299
String filterColumn = requestIn.queryParams("qc");
String filterQuery = requestIn.queryParams("q");
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use the PageControlHelper to get these parameters. It encapsulates the logic and does some minimal validation.

Suggested change
String filterColumn = requestIn.queryParams("qc");
String filterQuery = requestIn.queryParams("q");
PageControlHelper pageHelper = new PageControlHelper(requestIn);
// pageHelper.getQuery()
// pageHelper.getQueryColumn()

@rjpmestre rjpmestre force-pushed the um_fix-virtual-systems-filters branch from 236d6d7 to 82696d5 Compare February 14, 2024 15:04
@rjpmestre rjpmestre requested a review from cbbayburt February 14, 2024 15:15
@rjpmestre rjpmestre merged commit 9dabeef into uyuni-project:master Feb 20, 2024
26 checks passed
@rjpmestre rjpmestre deleted the um_fix-virtual-systems-filters branch February 21, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants