Skip to content

Feature/fga/fix sdk integration tests #4568

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

Merged
merged 9 commits into from
Dec 3, 2021

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Nov 26, 2021

This will fix #4546
All of the tests are not passing yet, but we are progressing.
Most notable stuff is introduction of TestMatrix class and MatrixWorkerFactory.

@github-actions
Copy link

github-actions bot commented Nov 26, 2021

Unit Test Results

  66 files  ±0    66 suites  ±0   59s ⏱️ -7s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 667bf1a. ± Comparison against base commit bdbbdb7.

♻️ This comment has been updated with latest results.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Some remarks. Also:

  • Please check the CI
  • Add a file for the changelog
  • Thanks!

*/
class Matrix private constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
class TestMatrix constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be internal?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's in androidTest package so not needed I guess

@@ -57,11 +55,9 @@ class SpaceCreationTest : InstrumentedTest {
val topic = "A public space for test"
var spaceId: String = ""
commonTestHelper.waitWithLatch {
GlobalScope.launch {
Copy link
Member

Choose a reason for hiding this comment

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

Since you are not using GlobalScope anymore, @Suppress("EXPERIMENTAL_API_USAGE") can be removed. There are maybe other places in the PR.

return Realm.getInstance(monarchy.realmConfiguration).use {
val token = Realm.getInstance(monarchy.realmConfiguration).use {
// Makes sure realm is up-to-date as it's used for querying internally on non looper thread.
it.refresh()
Copy link
Member

Choose a reason for hiding this comment

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

Will it fix the notification about init sync not displayed after a clear cache? (not sure there is an existing issue about that)

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe? :D

}

fun saveToken(realm: Realm, token: String?) {
val sync = SyncEntity(token)
realm.insertOrUpdate(sync)
if (realm.isInTransaction) {
Copy link
Member

Choose a reason for hiding this comment

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

it should always be the case, no? Else shouldn't we do something like crashing the app for instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yes sorry, miss from testing

/**
* Force foreground for testing
*/
internal class TestBackgroundDetectionObserver : BackgroundDetectionObserver {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe extract to its own file

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

UploadContentWorker(appContext, workerParameters, sessionManager)
else ->
// Return null to delegate to the default WorkerFactory.
null
Copy link
Member

Choose a reason for hiding this comment

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

Maybe log a warning for the developers, if they forget to add their new worker instanciation above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes good point

@bmarty
Copy link
Member

bmarty commented Nov 29, 2021

Also for big 1d9da6c next time please do separate commits to split renaming of members, and more impactful changes, it will ease the review. Thanks!

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM, 2 small remarks but no blockers

if (workInfo.state == WorkInfo.State.FAILED) {
throw RuntimeException("MatrixWorkerFactory is not being set on your worker configuration.\n" +
"Makes sure to add it to a DelegatingWorkerFactory if you have your own factory or use it directly.\n" +
"You can grab the instance through the Matrix class.")
Copy link
Member

Choose a reason for hiding this comment

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

The message is maybe a bit hard to understand (to me at least) :/. I cannot propose better though, but maybe add a link to the Element code where it's done?


/**
* This worker is launched by the factory with the isCreatedByMatrixWorkerFactory flag to true.
* If the MatrixWorkerFactory is not set up, it will default to the other constructor and it will throw
Copy link
Member

Choose a reason for hiding this comment

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

it will not throw but it will fail :)

@bmarty bmarty enabled auto-merge November 30, 2021 13:28
@@ -44,7 +44,7 @@ import javax.inject.Inject
/**
* This mimics the Matrix class but using TestMatrixComponent internally instead of regular MatrixComponent.
*/
class TestMatrix constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
internal class TestMatrix constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
Copy link
Member

Choose a reason for hiding this comment

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

I told you!

Copy link
Member

Choose a reason for hiding this comment

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

CI does not like this change though. I think some other test classes have to be declared internal

@bmarty bmarty disabled auto-merge November 30, 2021 19:46
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update

@bmarty bmarty merged commit e60d053 into develop Dec 3, 2021
@bmarty bmarty deleted the feature/fga/fix_sdk_integration_tests branch December 3, 2021 16:11
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.

Fix integration tests
2 participants