Skip to content

Commit

Permalink
Add Tree concurrency tests (#169)
Browse files Browse the repository at this point in the history
* Add Tree concurrency tests

* Update swift-integration.yml

* Update swift-integration.yml

* Update swift-integration.yml
  • Loading branch information
humdrum authored May 21, 2024
1 parent 97ed0c8 commit e309688
Show file tree
Hide file tree
Showing 7 changed files with 949 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/swift-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:

jobs:
build:
runs-on: macos-13
runs-on: macos-latest
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: actions/checkout@v3
- name: Setup Docker on macOS using Colima, Lima-VM, and Homebrew.
uses: douglascamata/setup-docker-macos-action@main
id: docker
- run: docker-compose -f docker/docker-compose-ci.yml up --build -d
- uses: actions/checkout@v4
- name: Setup yorkie server
run: brew install yorkie
- name: Run yorkie server
run: yorkie server &
- name: Run tests
run: swift test --enable-code-coverage -v --filter YorkieIntegrationTests
3 changes: 1 addition & 2 deletions Sources/Core/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public actor Client {

let builder: ClientConnection.Builder
if rpcAddress.isSecured {
builder = ClientConnection.usingTLSBackedByNetworkFramework(on: self.group)
builder = ClientConnection.usingPlatformAppropriateTLS(for: self.group)
} else {
builder = ClientConnection.insecure(group: self.group)
}
Expand Down Expand Up @@ -226,7 +226,6 @@ public actor Client {
}

deinit {
try? self.group.syncShutdownGracefully()
try? self.rpcClient.channel.close().wait()
}

Expand Down
9 changes: 9 additions & 0 deletions Sources/Document/Change/ChangeContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class ChangeContext {
self.delimiter = TimeTicket.Values.initialDelimiter
}

func deepcopy() -> ChangeContext {
let clone = ChangeContext(id: self.id, root: self.root.deepcopy(), message: self.message)

clone.operations = self.operations
clone.delimiter = self.delimiter

return clone
}

/**
* `push` pushes the given operation to this context.
*/
Expand Down
9 changes: 9 additions & 0 deletions Sources/Document/Json/JSONTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ public class JSONTree {
self.tree = tree
}

func deepcopy() -> JSONTree {
let clone = JSONTree(initialRoot: self.initialRoot)

clone.context = self.context?.deepcopy()
clone.tree = self.tree?.deepcopy() as? CRDTTree

return clone
}

/**
* `id` returns the ID of this tree.
*/
Expand Down
Loading

0 comments on commit e309688

Please sign in to comment.