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

Sync android-sdk with js-sdk: Implement updates to v0.4.27 #212

Merged
merged 35 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1a279a5
Publish DocumentStatusChanged event if status was changed
daeyounglnc Aug 14, 2024
8b92b71
Remove node from indexes during GC
daeyounglnc Aug 14, 2024
726e57a
Handle retry for syncLoop and watchLoop
daeyounglnc Aug 15, 2024
44ce553
Updated lambda parameter's name
daeyounglnc Aug 15, 2024
9af7217
Added tc for the condition of watchLoop.
daeyounglnc Aug 15, 2024
c6ae388
Defined YorkieException to handle error by type
daeyounglnc Aug 16, 2024
56c97d9
Replace other exceptions and Kotlin's check()/require() with YorkieEx…
daeyounglnc Aug 16, 2024
657782f
Added a tc to verify correct usage of YorkieException and Code
daeyounglnc Aug 16, 2024
97322ad
Removed comment
daeyounglnc Aug 16, 2024
7713dd4
Updated docker-compose.yml and docker-compose-ci.yml
daeyounglnc Aug 16, 2024
c74ac17
Fixes issues caused by not using little endian
daeyounglnc Aug 28, 2024
d26d565
Handle local changes correctly when receiving snapshot
daeyounglnc Aug 28, 2024
0555d69
Updated version to 0.4.27-rc
daeyounglnc Aug 28, 2024
b1970e3
Use little endian in MockYorkieService
daeyounglnc Aug 28, 2024
80df75c
Use little endian on CrdtPrimitive.kt
daeyounglnc Aug 28, 2024
4a58b48
Bump up libraries
daeyounglnc Aug 28, 2024
74fe3be
Update tc to represent the changed spec.
daeyounglnc Aug 29, 2024
6f98ad6
Removed unused function
daeyounglnc Aug 29, 2024
6966671
Added access modifier
daeyounglnc Aug 31, 2024
a7166d3
Added access modifier
daeyounglnc Aug 31, 2024
698e0ec
Added access modifier
daeyounglnc Aug 31, 2024
6c6e41b
fixed a typo
daeyounglnc Aug 31, 2024
3524c6b
Updated comment
daeyounglnc Aug 31, 2024
0aaa758
Modified property's name
daeyounglnc Aug 31, 2024
10dea5e
Modified property's name
daeyounglnc Aug 31, 2024
64c55bc
Added access modifier
daeyounglnc Aug 31, 2024
a0abc7a
Added access modifier
daeyounglnc Aug 31, 2024
cbd8272
Updated tc to fix compile error
daeyounglnc Aug 31, 2024
e1f6de8
Calling handleWatchStreamFailure() function was moved to outside of …
daeyounglnc Aug 31, 2024
f0bd230
Removed unnecessary Map to make the code a bit clearer.
daeyounglnc Sep 12, 2024
d30bbfc
Improve code readability
daeyounglnc Sep 12, 2024
ba2229f
Removed unused logs
daeyounglnc Sep 12, 2024
12aa5ef
Updated comment
daeyounglnc Sep 12, 2024
45f1c71
Improved comment
daeyounglnc Sep 12, 2024
358c8ac
Removed `actorID` parameter from applyDocumentStatus() function.
daeyounglnc Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.3'

services:
yorkie:
image: 'yorkieteam/yorkie:0.4.24'
image: 'yorkieteam/yorkie:0.4.27'
container_name: 'yorkie'
command: ['server', '--mongo-connection-uri', 'mongodb://mongo:27017']
restart: always
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.3'

services:
yorkie:
image: 'yorkieteam/yorkie:0.4.24'
image: 'yorkieteam/yorkie:0.4.27'
container_name: 'yorkie'
command: ['server', '--enable-pprof']
restart: always
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android.suppressUnsupportedOptionWarnings=android.suppressUnsupportedOptionWarni
kotlin.code.style=official
kotlin.mpp.stability.nowarn=true
GROUP=dev.yorkie
VERSION_NAME=0.4.25-rc
VERSION_NAME=0.4.27-rc
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set the RC version because even after the merge this PR, there are still specs to discuss.
yorkie-team/yorkie-js-sdk#865

POM_DESCRIPTION=Document store for building collaborative editing applications.
POM_INCEPTION_YEAR=2022
POM_URL=https://github.com/yorkie-team/yorkie-android-sdk
Expand Down
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ minSdk = "24"
compileSdk = "34"
targetSdk = "34"
agp = "8.5.0"
connectKotlin = "0.6.1"
connectKotlin = "0.7.0"
okhttp = "4.12.0"
coroutines = "1.8.1"
androidxActivity = "1.9.0"
androidxLifecycle = "2.8.2"
androidxBenchmark = "1.2.4"
androidxActivity = "1.9.1"
androidxLifecycle = "2.8.4"
androidxBenchmark = "1.3.0"
androidxComposeCompiler = "1.5.14"

[libraries]
androidx-annotation = { module = "androidx.annotation:annotation", version = "1.8.0" }
androidx-annotation = { module = "androidx.annotation:annotation", version = "1.8.2" }
connect-kotlin-google-javalite-ext = { module = "com.connectrpc:connect-kotlin-google-javalite-ext", version.ref = "connectKotlin" }
connect-kotlin-okhttp = { module = "com.connectrpc:connect-kotlin-okhttp", version.ref = "connectKotlin" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
Expand Down Expand Up @@ -46,10 +46,10 @@ gson = { group = "com.google.code.gson", name = "gson", version = "2.11.0" }

kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
junit = { group = "junit", name = "junit", version = "4.13.2" }
androidx-test-runner = { group = "androidx.test", name = "runner", version = "1.5.2" }
androidx-test-junit = { group = "androidx.test.ext", name = "junit-ktx", version = "1.1.5" }
androidx-test-monitor = { group = "androidx.test", name = "monitor", version = "1.6.1" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version = "3.5.1" }
androidx-test-runner = { group = "androidx.test", name = "runner", version = "1.6.2" }
androidx-test-junit = { group = "androidx.test.ext", name = "junit-ktx", version = "1.2.1" }
androidx-test-monitor = { group = "androidx.test", name = "monitor", version = "1.7.2" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version = "3.6.1" }
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version = "4.1.0" }

[bundles]
Expand Down
71 changes: 71 additions & 0 deletions yorkie/src/androidTest/kotlin/dev/yorkie/core/ClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import dev.yorkie.document.json.JsonTreeTest.Companion.rootTree
import dev.yorkie.document.json.TreeBuilder.element
import dev.yorkie.document.json.TreeBuilder.text
import dev.yorkie.document.operation.OperationInfo
import dev.yorkie.util.YorkieException
import dev.yorkie.util.YorkieException.Code.*
import java.util.UUID
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertIs
import kotlin.test.assertNotEquals
Expand Down Expand Up @@ -890,4 +893,72 @@ class ClientTest {
collectJobs.forEach(Job::cancel)
}
}

@Test
fun test_should_throw_exceptions_attach_and_detach_document() {
runBlocking {
val c1 = createClient()
val key = UUID.randomUUID().toString().toDocKey()
val d1 = Document(key)

// Test that attaching an already attached document throws an error
val activatedException = assertFailsWith<YorkieException> {
c1.attachAsync(d1).await()
}
assertEquals(ErrClientNotActivated, activatedException.code)

c1.activateAsync().await()

c1.attachAsync(d1).await()

// Test that attaching an already attached document throws an error
val attachException = assertFailsWith<YorkieException> {
c1.attachAsync(d1).await()
}
assertEquals(ErrDocumentNotDetached, attachException.code)

c1.detachAsync(d1).await()

// Test that detaching an already detached document throws an error
val detachException = assertFailsWith<YorkieException> {
c1.detachAsync(d1).await()
}
assertEquals(ErrDocumentNotAttached, detachException.code)

c1.deactivateAsync().await()
d1.close()
c1.close()
}
}

@Test
fun test_should_handle_local_changes_correctly_when_receiving_snapshot() {
withTwoClientsAndDocuments(syncMode = Manual) { c1, c2, d1, d2, _ ->
d1.updateAsync { root, _ ->
root.setNewCounter("counter", 0)
}.await()

c1.syncAsync().await()
c2.syncAsync().await()

// 01. c1 increases the counter for creating snapshot.
repeat(500) {
d1.updateAsync { root, _ ->
root.getAs<JsonCounter>("counter").increase(1)
}.await()
}
c1.syncAsync().await()

// 02. c2 receives the snapshot and increases the counter simultaneously.
// The tc in js-sdk, it performed the sync before update, but it is not necessary.
Copy link
Contributor Author

@daeyounglnc daeyounglnc Aug 29, 2024

Choose a reason for hiding this comment

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

@raararaara ,

As we talked in the offline conversation, calling the sync function in the js-sdk isn't mandatory.
So I didn't write the code to call the sync (syncAsync in android) function, I thought it might cause unnecessary to understand exactly what TC is trying to do.
If you has any thoughts on this, please comment.

// so, it is not implemented in android sdk.
d2.updateAsync { root, _ ->
root.getAs<JsonCounter>("counter").increase(1)
}.await()

c2.syncAsync().await()
c1.syncAsync().await()
assertEquals(d1.toJson(), d2.toJson())
}
}
}
Loading