Skip to content

Conversation

@davidjumani
Copy link
Contributor

@davidjumani davidjumani commented Oct 5, 2020

Description

Fixes #4372

Ensures that the count returned by searchAndCount searchAndDistinctCount do not include removed items
Before, it would return the count of removed items as well when the search criteria is null (since sc is created and modified in search which doesn't reflect when it tires to get the count)
Also refactored a bit to make life easieer for the next person who comes along

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

How Has This Been Tested?

Before :

(localcloud) SBCM5> > list roles filter=
{
  "count": 11,
  "role": [
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {}
  ]
}

After :

(localcloud) SBCM5> > list roles filter=
{
  "count": 9,
  "role": [
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {},
    {}
  ]
}

@davidjumani
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2118

@davidjumani
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@davidjumani davidjumani added this to the 4.15.0.0 milestone Oct 5, 2020
Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

code looks good. I think the search and count method should however have a single set of criteria for both the results and the count and not need any adjustments down the line. starting with an sc only containing "true", could be a solution (as well or on top of this, no pref)

@DB()
public <M> List<M> customSearch(SearchCriteria<M> sc, final Filter filter) {
if (_removed != null) {
sc.addAnd(_removed.second().field.getName(), SearchCriteria.Op.NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

can use checkAndSetRemovedIsNull() 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.

Makes it a bit difficult since it is of a different type M not T

Copy link
Contributor

Choose a reason for hiding this comment

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

}

public Integer getDistinctCount(SearchCriteria<T> sc, boolean removed) {
if (!removed) {
Copy link
Contributor

Choose a reason for hiding this comment

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

removed & _removed seems to be redundant here & wherever used in similar way, can you directly set / unset _removed as per its usage ? If the purpose is to include / exclude removed records, you can use methods with naming *IncludingRemovedBy() [for ex: getDistinctCountIncludingRemovedBy()] to be in sync with the other methods.

Copy link
Contributor Author

@davidjumani davidjumani Oct 6, 2020

Choose a reason for hiding this comment

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

As of now getDistinctCount returns including removed so changing it would require changing where it's been referenced, would it be better to create getDistinctCountExcludingRemoved ?
Edit : Nevermind. Isn't used much elsewhere. Will make the changes

Copy link
Contributor

Choose a reason for hiding this comment

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

getDistinctCountExcludingRemoved is not in line with other methods, so I do not recommend.

Copy link
Contributor

@sureshanaparti sureshanaparti Oct 6, 2020

Choose a reason for hiding this comment

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

Default method should not include removed records, explicitly mentioned methods "*IncludingRemovedBy()" should. so, may be you can change current method to "*IncludingRemovedBy()" and add other method with current 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.

Added! Thanks @sureshanaparti

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, changes LGTM.

@davidjumani
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✖centos7 ✖centos8 ✔debian. JID-2125

@davidjumani
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@apache apache deleted a comment from blueorangutan Oct 6, 2020
@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2134

@davidjumani
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2901)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 37746 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4374-t2901-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 83 look OK, 2 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers Failure 290.08 test_vpc_redundant.py
test_hostha_kvm_host_fencing Error 99.19 test_hostha_kvm.py

@davidjumani davidjumani marked this pull request as ready for review October 7, 2020 04:57
@davidjumani
Copy link
Contributor Author

@blueorangutan test matrix

@blueorangutan
Copy link

@davidjumani a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware67, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2905)
Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server 7
Total time taken: 35549 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4374-t2905-vmware-67u3.zip
Intermittent failure detected: /marvin/tests/smoke/test_host_maintenance.py
Smoke tests completed. 83 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@DaanHoogland
Copy link
Contributor

@blueorangutan test centos7 xs71
@blueorangutan test centos7 kvmcentos7

@blueorangutan
Copy link

@DaanHoogland unsupported parameters provided. Supported mgmt server os are: centos6, centos7, centos8, ubuntu. Supported hypervisors are: kvm-centos6, kvm-centos7, kvm-centos8, kvm-ubuntu, xenserver-71, xenserver-65sp1, vmware-67u3, vmware-65u2, vmware-60u2, vmware-55u3, xcpng76, xcpng80, xcpng81, xenserver-74, xcpng74

@sureshanaparti
Copy link
Contributor

@blueorangutan test centos7 xenserver-71
@blueorangutan test centos7 kvm-centos7

@blueorangutan
Copy link

@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + xenserver-71) has been kicked to run smoke tests

@DaanHoogland
Copy link
Contributor

@blueorangutan test centos7 xenserver-71

@blueorangutan
Copy link

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + xenserver-71) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2920)
Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36403 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4374-t2920-xenserver-71.zip
Intermittent failure detected: /marvin/tests/smoke/test_scale_vm.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Smoke tests completed. 84 look OK, 1 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_01_scale_vm Failure 9.40 test_scale_vm.py

@DaanHoogland
Copy link
Contributor

@blueorangutan test centos7 kvm-centos7

@blueorangutan
Copy link

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-2926)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 31223 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4374-t2926-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 84 look OK, 1 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_hostha_kvm_host_fencing Error 101.42 test_hostha_kvm.py

@DaanHoogland DaanHoogland merged commit aab8df0 into apache:master Oct 13, 2020
@DaanHoogland DaanHoogland deleted the fix-searchandcount branch October 13, 2020 09:30
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.

list roles API returns a wrong count

4 participants