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

[provisioning api] fix failing testcase #19930

Merged
merged 1 commit into from
Oct 21, 2015
Merged

Conversation

rullzer
Copy link
Contributor

@rullzer rullzer commented Oct 21, 2015

In order to make sure that slicing is done proplery the list of users should always be sorted.

This should fix the sometimes failing tests on Jenkins. exmaple

Patch is rather trivial.

CC: @MorrisJobke @PVince81 @nickvergessen @tomneedham

@rullzer rullzer added this to the 9.0-current milestone Oct 21, 2015
@@ -93,6 +93,8 @@ public function getUsers() {
$users = array_merge($users, $this->groupManager->displayNamesInGroup($group, $search));
}

asort($users);
Copy link
Contributor

Choose a reason for hiding this comment

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

uhh, thats a bit of a problem. The groupManager already sorts (or let's the user backend sort). This sorting might not be asort().
But well fine by me

Copy link
Member

Choose a reason for hiding this comment

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

sorting a list of half a million users? no 👎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorting a list of half a million users? no 👎

Then tell me how to do proper pagination 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.

uhh, thats a bit of a problem. The groupManager already sorts (or let's the user backend sort). This sorting might not be asort().
But well fine by me

Well this is the same situation as with the sharee API... we get a list of users from several groups... So if we want to do pagination we need to properly sort first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unified accounts table 🙈

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 sure. But I would like not to have failing test cases until then.

Copy link
Contributor

Choose a reason for hiding this comment

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

sort in the testcase 🙊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok let me do a nasty hack on the tests then. (Note that once we have #19827 merged I can convert the provisioning app to pure unit tests and this should all go away...) Then we can leave the intergration tests to that nice job we have running already.

@rullzer rullzer changed the title [provisioning api] sort users before returning them [provisioning api] fix failing testcase Oct 21, 2015
@rullzer
Copy link
Contributor Author

rullzer commented Oct 21, 2015

Ok I modified the test. It is almost impossible to get the sort order right in the testcase to compare because databases sort is to dependant on the enviroment (the locale set has influence etc). So I just losend the test case here.

Does mean we do not have strict tests for pagination of accessible users.

$this->assertEquals(['users' => array_slice($uids, 1, 2)], $result->getData());

// Disable this test for now since sorting is not done the same on all backends
//$this->assertEquals(['users' => array_slice($uids, 1, 2)], $result->getData());
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 compare arrays with phpunit

$this->assertEquals($expectedArray, $array, '', 0.0, true);

Copy link
Member

Choose a reason for hiding this comment

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

relevant part is the true for the parameter $canonicalize which allows array comare ignoring the order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still will not work since I need to slice the $expectedArray before passing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

why don't you just use sort on $result->getData() then?
You tried to sort it on the call. should be fine to sort it in the test the same way, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because I will have sliced after the sort.. assume 4 users:

['User1', 'User2', 'user4', 'User3']

Now assume the backend sorts like this:

['user4', 'User1', 'User2', 'User3']

Now the array is sliced and we return the middle 2 elements so:

['User1', 'User2']

However I don't know how the backend has sorted so I just sort in php which results in:

['User1', 'User2', 'User3', 'user4']

If I then slice I get:

['User2', 'User3']

So sorting what the call returns does not help me here. Because I don't know how the backend sorts my slice doesn't have to match the returned slice.

Copy link
Member

Choose a reason for hiding this comment

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

I meanwhile question the value of this test .... we know pagination has issues ... no need to operate around it.

Anyway - let's get this merged to have a stable CI system

@rullzer please open an issue on pagination on the provisioning api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LukasReschke
Copy link
Member

👍

Since we have no control of how backends sort their list of users and we
also don't want to sort yet another time the test now just checks if the
correct number of elements is returned and if they are from the list of
group members.
@DeepDiver1975
Copy link
Member

👍

DeepDiver1975 added a commit that referenced this pull request Oct 21, 2015
[provisioning api] fix failing testcase
@DeepDiver1975 DeepDiver1975 merged commit e1e1f4f into master Oct 21, 2015
@DeepDiver1975 DeepDiver1975 deleted the sort_usernames branch October 21, 2015 20:44
@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants