Skip to content

Improve threading and test suite#242

Merged
wzieba merged 23 commits intoexperimentation_refactorfrom
improve_threading_and_test_suite
Aug 30, 2024
Merged

Improve threading and test suite#242
wzieba merged 23 commits intoexperimentation_refactorfrom
improve_threading_and_test_suite

Conversation

@wzieba
Copy link
Member

@wzieba wzieba commented Aug 28, 2024

Description

This PR aims to:

To test

This PR introduces a robust test suite. Still, you can perform some smoke tests if you'd like following instructions from #241

wzieba added 18 commits August 28, 2024 20:38
In order to remove `runBlocking` from `ExPlat`, we have to have a way to get value from cache in a way, that doesn't require sync file-operation. That's why I introduce `latest` field, which keeps the latest cache value in memory.

Providing dispatchers is considered a good practice and might come handy during tests
Now, that we have few new/changed tests, I extract some similarities to make tests more readable
This is a confusing API, because, even if user requests a refresh, we don't return fresh data immediately, but only queue this to fetch. This is not something I'd expect as the SDK consumer.

Also, we already have specialized refresh methods. I don't think we need more.

I plan to remove `shouldRefreshIfStale` in another commit.
I've added some comments explaining a story of this test, as I found it a little confusing when I started working on this.
…don't think their necessary (nothing bad will happen if the list will be empty, and the check itself is trivial), and they bring maintenance overhead at the same time.
…periment

I'm not sure if it's good idea to test the debug code, but at the same time this test is tiny, so maybe let's keep it
Personal preference, I'm not a fan of "dummy"
@wzieba wzieba marked this pull request as ready for review August 29, 2024 06:54
@wzieba wzieba requested a review from ParaskP7 August 29, 2024 06:54
Copy link
Contributor

@ParaskP7 ParaskP7 left a comment

Choose a reason for hiding this comment

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

Same as with #239, #240 and #241 @wzieba , awesome work on the testing side of things, very helpful, and I'll continue reviewing the final PR, I am very close to the finish line, then we can start merging everything! 🤞

setupAssignments(cachedAssignments = treatmentAssignments, fetchedAssignments = treatmentAssignments)

val secondVariation = exPlat.getVariation(dummyExperiment, shouldRefreshIfStale = false)
assertThat(secondVariation).isEqualTo(controlVariation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion (💡): I usually split such code with an extra /* HELPER */ grouping comment, which means, see helper functions below.

Base automatically changed from no_fluxc_test_app to experimentation_refactor August 30, 2024 10:47
wzieba added 2 commits August 30, 2024 13:18
… not found in cache

It's more reasonable to return `null` if there are no assignments, rather than a fake assignment with made up values.
@wzieba
Copy link
Member Author

wzieba commented Aug 30, 2024

@ParaskP7 I think this PR is ready to re-review. Re tests we discussed in #240 (comment) - I think I'll add it rather in #243 as there are some changes to tests there, so I don't want to work unnecessarily addressing conflicts

@ParaskP7
Copy link
Contributor

Reviewed and everything looks good to me, feel free to merge! ✅

PS: Just one note from me, maybe we should consider testing the publicly available getVariation(...) call, via the example app, as I was surprised that the change to making it nullable didn't have any effect their too... 🤔

@wzieba
Copy link
Member Author

wzieba commented Aug 30, 2024

Sorry, my bad. Actually getVariation is not changing signature - in case of empty assignment, we return Control

@ParaskP7
Copy link
Contributor

Sorry, my bad. Actually getVariation is not changing signature - in case of empty assignment, we return Control

Ah, right, true! 💯

@wzieba wzieba merged commit de01485 into experimentation_refactor Aug 30, 2024
@wzieba wzieba deleted the improve_threading_and_test_suite branch August 30, 2024 12:14
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.

2 participants