Skip to content

Commit

Permalink
build(mps-legacy-sync-plugin): fix flaky test in `ReferenceSynchronis…
Browse files Browse the repository at this point in the history
…ationTest`

The test did not account for that running `ISyncService.flushAllBindings` only flushed to the local modelix branch and did not guarantee to immediately sync to the model server.

Synchronization is scheduled by `org.modelix.model.client.ReplicatedRepository` on different thread.

Fixes: MODELIX-840
  • Loading branch information
Oleksandr Dzhychko committed Apr 11, 2024
1 parent c3e98f7 commit 97c3aa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ interface ISyncService {
fun findMpsNode(cloudNodeReference: INodeReference): List<SNode>

/**
* Synchronize all bindings between MPS and the model server.
* Synchronize all bindings between MPS and the local Modelix branch.
* The call blocks until all synchronizations are finished or timeout.
*
* It is not guaranteed that after invocation, the local Modelix branch has been synced to the model server.
* Synchronizing to the model server happens asynchronously in the background.
*
* The synchronization is always scheduled on a different thread which will try to acquire a write and read lock.
* To not deadlock your program, do not call this method while holding a write lock or read lock.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ class ReferenceSynchronisationTest : SyncPluginTestBase("projectWithReferences")
null,
)
}
syncService.flushAllBindings()
delayUntil(exceptionMessage = "Failed to sync module to model server") {
val dataOnServer = readDumpFromServer(defaultBranchRef)
dataOnServer.children.any { module ->
module.children.any { it.role == "models" }
}
}

// Assert
val rootNodeData = readDumpFromServer(defaultBranchRef)
Expand Down

0 comments on commit 97c3aa7

Please sign in to comment.