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

Ressurect instrumented tests #8

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Ressurect instrumented tests #8

merged 3 commits into from
Apr 11, 2024

Conversation

norohind
Copy link

Closes #7.
Basically, it wanted to have kotlin standard library.
Also, there is a helper method createMusicSongs which is used to provide songs for tests.
This method used to return hand-crafted song entry which actually exists on subsonic test server.
But now navidrome test server is utilized in the project by default, so some tests was getting this song,
failed to lookup it up on navidrome demo server and thus, some tests fails.
I redone this method to pull a really present on server song, it would allow us to run tests against different subsonic servers in future.

All tests pass except testGetRecentDownloadsWithoutPlaylist. I still don't know why, have looked up changes in related to this test code, tried to rollback them and still couldn't figure out what's wrong.
The problem actually not the test's assertion, but exception is being throw inside application code:

java.lang.IllegalArgumentException: fromIndex(0) > toIndex(-1)
at java.util.ArrayList.subListRangeCheck(ArrayList.java:1018)
at java.util.ArrayList.subList(ArrayList.java:1008)
at github.daneren2005.dsub.service.DownloadService.getRecentDownloads(DownloadService.java:1089)

P.S. All my pull requests are based one on another, I'm doing it because it simplifies for me building app with all my changes for personal use. I guess there would be no problems if you merge my PRs in submit order. If this is gonna cause problems, let me now and we'll figure something out.

norohind added 3 commits April 6, 2024 17:33
Current implementation of offline scrobbling is to save all
required data to submit scrobble in local shared preferences file
and when back online, DSub sends them to server.

When in Offline mode, dsub uses pathes to local files as their identifies
as opposite to Online mode where server side identifies are utilized.
In order to send scrobble it is required to specify server side ID
in a query.

Thus, Dsub has to match identifies of what it has scrobbled while offline
(paths to files in file system) to server side identifies. To do so, it relies
on
1. Querying local database, which contains mapping local path to file <-> server side id.
It sounds good but we don't live in perfect world and there are couple flaws in this implementation:
a) Dsub's local database only contains information for songs that have been played in online
mode at least once.
b) It just doesn't work since in scrobble OfflineMusicService.scrobble method id of a song comes with ".complete"
postfix and in database it's saved without this ".complete" postfix so it fails to lookup server side id.

2. Querying the server with lucene syntax search clause. Subsonic api doesn't say anything about lucene
search syntax support and not all servers have support for it (i.e. see this issue for navidrome
navidrome/navidrome#1466). Besides, it isn't precise in case you have multiple
songs with same artist and title (i.e. multiple editions of an album).

This commit and according PR focus on fixing problems with looking up local path to file <-> server side id.
It is achieved with removing ".complete" substring from all identifies which
comes to OfflineMusicSerivce.scrobble. And by adding all cached songs to local db on download stage
so when DSub switches to offline mode it always has server side identifies for all media files it has
locally.
All tests pass except testGetRecentDownloadsWithoutPlaylist
@paroj paroj merged commit f5f29a9 into paroj:edge Apr 11, 2024
@paroj
Copy link
Owner

paroj commented Apr 11, 2024

sorry for the delayed merging - I somehow ended up not "watching" my own repo and got no notifications..

@norohind norohind deleted the fix-tests branch April 11, 2024 21:23
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.

Make instrumented tests work again
2 participants