From 3a6e4225423324a94a0a21f3b829c98ef50dd7f7 Mon Sep 17 00:00:00 2001 From: Jung gyun Ahn Date: Mon, 18 Dec 2023 11:39:47 +0900 Subject: [PATCH 1/2] Add more GC tests to reflect current server modifications --- Tests/Integration/GCTests.swift | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/Tests/Integration/GCTests.swift b/Tests/Integration/GCTests.swift index b0009560..4c9029c1 100644 --- a/Tests/Integration/GCTests.swift +++ b/Tests/Integration/GCTests.swift @@ -769,4 +769,75 @@ class GCTests: XCTestCase { len = await doc.getGarbageLengthFromClone() XCTAssertEqual(len, 6) } + + func test_can_purges_removed_elements_after_peers_can_not_access_them() async throws { + let options = ClientOptions() + let docKey = "\(self.description)-\(Date().description)".toDocKey + + let doc1 = Document(key: docKey) + let doc2 = Document(key: docKey) + + let client1 = Client(rpcAddress: rpcAddress, options: options) + let client2 = Client(rpcAddress: rpcAddress, options: options) + + try await client1.activate() + try await client2.activate() + + try await client1.attach(doc1, [:], false) + + try await doc1.update { root, _ in + root.point = ["x": Int64(0), "y": Int64(0)] + } + + try await doc1.update { root, _ in + (root.point as? JSONObject)?.x = Int64(1) + } + + var len = await doc1.getGarbageLength() + XCTAssertEqual(len, 1) + + try await client1.sync() + + try await client2.attach(doc2, [:], false) + + len = await doc2.getGarbageLength() + XCTAssertEqual(len, 1) + + try await doc2.update { root, _ in + (root.point as? JSONObject)?.x = Int64(2) + } + + len = await doc2.getGarbageLength() + XCTAssertEqual(len, 2) + + try await doc1.update { root, _ in + root.point = ["x": Int64(3), "y": Int64(3)] + } + + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 4) + try await client1.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 4) + + try await client1.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 4) + + try await client2.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 4) + try await client1.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 5) + try await client2.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 5) + try await client1.sync() + len = await doc1.getGarbageLength() + XCTAssertEqual(len, 0) + + try await client1.deactivate() + try await client2.deactivate() + } } From cd795ba15c7b1391b9d03bfabf1fc3ca690a981d Mon Sep 17 00:00:00 2001 From: Jung gyun Ahn Date: Mon, 18 Dec 2023 13:28:57 +0900 Subject: [PATCH 2/2] Update docker settings --- docker/docker-compose-ci.yml | 23 +++-------------------- docker/docker-compose.yml | 29 +++-------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/docker/docker-compose-ci.yml b/docker/docker-compose-ci.yml index 0e733303..5a852e49 100644 --- a/docker/docker-compose-ci.yml +++ b/docker/docker-compose-ci.yml @@ -1,31 +1,14 @@ version: '3.3' services: - envoy: - build: - context: ./ - dockerfile: ./envoy.Dockerfile - image: 'grpcweb:envoy' - container_name: 'envoy' - restart: always - ports: - - '8080:8080' - - '9901:9901' - command: ['/etc/envoy/envoy-ci.yaml'] - depends_on: - - yorkie yorkie: image: 'yorkieteam/yorkie:latest' container_name: 'yorkie' - command: [ - 'server', - '--mongo-connection-uri', - 'mongodb://mongo:27017', - ] + command: ['server', '--mongo-connection-uri', 'mongodb://mongo:27017'] restart: always ports: - - '11101:11101' - - '11102:11102' + - '8080:8080' + - '8081:8081' depends_on: - mongo mongo: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0b8c865a..c03eda52 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,34 +1,11 @@ version: '3.3' services: - envoy: - build: - context: ./ - dockerfile: ./envoy.Dockerfile - image: 'grpcweb:envoy' - container_name: 'envoy' - restart: always - ports: - - '8080:8080' - - '9901:9901' - command: ['/etc/envoy/envoy.yaml'] - depends_on: - - yorkie - # If you're using Mac or Windows, this special domain name("host.docker.internal" which makes containers able to connect to the host) - # is supported by default. - # But if you're using Linux and want an envoy container to communicate with the host, - # it may help to define "host.docker.internal" in extra_hosts. - # (Actually, other hostnames are available, but in that case you should update clusters[].host configurations of envoy.yaml) - extra_hosts: - - "host.docker.internal:host-gateway" yorkie: image: 'yorkieteam/yorkie:latest' container_name: 'yorkie' - command: [ - 'server', - '--enable-pprof', - ] + command: ['server', '--enable-pprof'] restart: always ports: - - '11101:11101' - - '11102:11102' + - '8080:8080' + - '8081:8081'