From 75a0bebb65595b5640043528bd0a91aee5aaed99 Mon Sep 17 00:00:00 2001 From: "vincent.pericart" Date: Thu, 8 Sep 2022 17:03:08 +0900 Subject: [PATCH 1/2] Use centraldogma 0.57 --- benchmark/build.gradle | 4 +- build.gradle | 2 +- centraldogma/build.gradle | 5 +- .../CentralDogmaPropertySupplier.java | 90 ++++++++++++------ ...lDogmaPropertySupplierIntegrationTest.java | 78 ++++++++-------- .../CentralDogmaPropertySupplierTest.java | 91 ++++++++----------- docs/example/build.gradle | 2 +- processor/build.gradle | 2 +- testing/build.gradle | 4 +- 9 files changed, 150 insertions(+), 128 deletions(-) diff --git a/benchmark/build.gradle b/benchmark/build.gradle index db0ca563..86ed408d 100644 --- a/benchmark/build.gradle +++ b/benchmark/build.gradle @@ -3,7 +3,7 @@ ext { shadeAllDependencies = true picoVersion = "4.2.0" - jacksonVersion = "2.12.3" + jacksonVersion = "2.13.4" } dependencies { @@ -21,5 +21,5 @@ dependencies { // To serialize java.time.Duration implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion" - runtimeOnly "ch.qos.logback:logback-classic:1.2.3" + runtimeOnly "ch.qos.logback:logback-classic:1.3.0" } diff --git a/build.gradle b/build.gradle index 7a62a044..a79328a1 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ subprojects { } ext { - slf4jVersion = "1.7.32" + slf4jVersion = "2.0.0" protobufVersion = "3.3.0" kafkaVersion = "3.2.0" micrometerVersion = "1.7.5" diff --git a/centraldogma/build.gradle b/centraldogma/build.gradle index cfe47f5c..28d809f5 100644 --- a/centraldogma/build.gradle +++ b/centraldogma/build.gradle @@ -3,8 +3,8 @@ repositories { } ext { - centralDogmaVersion = "0.52.5" - jacksonVersion = "2.12.5" + centralDogmaVersion = "0.57.0" + jacksonVersion = "2.13.4" } dependencies { @@ -15,4 +15,5 @@ dependencies { implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion" testImplementation "com.linecorp.centraldogma:centraldogma-testing-junit4:$centralDogmaVersion" + testRuntimeOnly "ch.qos.logback:logback-classic:1.3.0" } diff --git a/centraldogma/src/main/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplier.java b/centraldogma/src/main/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplier.java index 4641d81c..ee3e19d7 100644 --- a/centraldogma/src/main/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplier.java +++ b/centraldogma/src/main/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplier.java @@ -16,7 +16,6 @@ package com.linecorp.decaton.centraldogma; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -33,10 +32,12 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.linecorp.centraldogma.client.CentralDogma; +import com.linecorp.centraldogma.client.CentralDogmaRepository; import com.linecorp.centraldogma.client.Watcher; import com.linecorp.centraldogma.common.Change; import com.linecorp.centraldogma.common.ChangeConflictException; import com.linecorp.centraldogma.common.EntryType; +import com.linecorp.centraldogma.common.PathPattern; import com.linecorp.centraldogma.common.Query; import com.linecorp.centraldogma.common.Revision; import com.linecorp.decaton.processor.runtime.DynamicProperty; @@ -82,7 +83,16 @@ public class CentralDogmaPropertySupplier implements PropertySupplier, AutoClose */ public CentralDogmaPropertySupplier(CentralDogma centralDogma, String projectName, String repositoryName, String fileName) { - rootWatcher = centralDogma.fileWatcher(projectName, repositoryName, Query.ofJsonPath(fileName)); + this(centralDogma.forRepo(projectName, repositoryName), fileName); + } + + /** + * Creates a new {@link CentralDogmaPropertySupplier}. + * @param centralDogmaRepository {@link CentralDogmaRepository} instance that points to a particular Central Dogma repository. + * @param fileName the name of the file containing properties as top-level fields. + */ + public CentralDogmaPropertySupplier(CentralDogmaRepository centralDogmaRepository, String fileName) { + rootWatcher = centralDogmaRepository.watcher(Query.ofJsonPath(fileName)).start(); try { rootWatcher.awaitInitialValue(INITIAL_VALUE_TIMEOUT_SECS, TimeUnit.SECONDS); } catch (InterruptedException e) { @@ -144,8 +154,20 @@ public void close() { */ public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, String project, String repository, String filename) { - createPropertyFile(centralDogma, project, repository, filename, ProcessorProperties.defaultProperties()); - return new CentralDogmaPropertySupplier(centralDogma, project, repository, filename); + final CentralDogmaRepository centralDogmaRepository = centralDogma.forRepo(project, repository); + createPropertyFile(centralDogmaRepository, filename, ProcessorProperties.defaultProperties()); + return new CentralDogmaPropertySupplier(centralDogmaRepository, filename); + } + + /** + * Create a default property file if it doesn't exist on Central Dogma and + * return a {@link CentralDogmaPropertySupplier}. + * @param centralDogmaRepository a {@link CentralDogmaRepository} instance that points to a particular Central Dogma repository. + * @param filename the name of the file containing properties as top-level fields. + */ + public static CentralDogmaPropertySupplier register(CentralDogmaRepository centralDogmaRepository, String filename) { + createPropertyFile(centralDogmaRepository, filename, ProcessorProperties.defaultProperties()); + return new CentralDogmaPropertySupplier(centralDogmaRepository, filename); } /** @@ -160,6 +182,19 @@ public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, S public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, String project, String repository, String filename, PropertySupplier supplier) { + return register(centralDogma.forRepo(project, repository), filename, supplier); + } + + /** + * Create a default property file if it doesn't exist on Central Dogma and + * return a {@link CentralDogmaPropertySupplier}. + * @param centralDogmaRepository a {@link CentralDogmaRepository} instance that points to a particular Central Dogma repository. + * @param filename the name of the file containing properties as top-level fields. + * @param supplier a {@link PropertySupplier} which provides a set of properties with customized initial values. + */ + public static CentralDogmaPropertySupplier register(CentralDogmaRepository centralDogmaRepository, + String filename, + PropertySupplier supplier) { List> properties = ProcessorProperties.defaultProperties().stream().map(defaultProperty -> { Optional> prop = supplier.getProperty(defaultProperty.definition()); if (prop.isPresent()) { @@ -169,15 +204,14 @@ public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, S } }).collect(Collectors.toList()); - createPropertyFile(centralDogma, project, repository, filename, properties); - return new CentralDogmaPropertySupplier(centralDogma, project, repository, filename); + createPropertyFile(centralDogmaRepository, filename, properties); + return new CentralDogmaPropertySupplier(centralDogmaRepository, filename); } - private static void createPropertyFile(CentralDogma centralDogma, String project, - String repository, String fileName, + private static void createPropertyFile(CentralDogmaRepository centralDogmaRepository, String fileName, List> properties) { - Revision baseRevision = normalizeRevision(centralDogma, project, repository, Revision.HEAD); - boolean fileExists = fileExists(centralDogma, project, repository, fileName, baseRevision); + Revision baseRevision = normalizeRevision(centralDogmaRepository, Revision.HEAD); + boolean fileExists = fileExists(centralDogmaRepository, fileName, baseRevision); long startedTime = System.currentTimeMillis(); long remainingTime = remainingTime(PROPERTY_CREATION_TIMEOUT_MILLIS, startedTime); @@ -185,21 +219,20 @@ private static void createPropertyFile(CentralDogma centralDogma, String project while (!fileExists && remainingTime > 0) { try { - centralDogma.push(project, repository, baseRevision, - String.format("[CentralDogmaPropertySupplier] Property file created: %s", - fileName), - Change.ofJsonUpsert(fileName, jsonNodeProperties)) - .get(remainingTime, TimeUnit.MILLISECONDS); - logger.info("New property file registered on Central Dogma: {}/{}/{}", - project, repository, fileName); + centralDogmaRepository + .commit(String.format("[CentralDogmaPropertySupplier] Property file created: %s", fileName), + Change.ofJsonUpsert(fileName, jsonNodeProperties)) + .push(baseRevision) + .get(remainingTime, TimeUnit.MILLISECONDS); + logger.info("New property file {} registered on Central Dogma", fileName); fileExists = true; } catch (ExecutionException e) { if (e.getCause() instanceof ChangeConflictException) { logger.warn( "Failed to push to {}. Someone pushed a commit against current revision. Try again", baseRevision); - baseRevision = normalizeRevision(centralDogma, project, repository, Revision.HEAD); - fileExists = fileExists(centralDogma, project, repository, fileName, baseRevision); + baseRevision = normalizeRevision(centralDogmaRepository, Revision.HEAD); + fileExists = fileExists(centralDogmaRepository, fileName, baseRevision); } else { logger.error("Failed to push to {}. Unexpected exception happened", baseRevision, e); break; @@ -222,11 +255,10 @@ private static void createPropertyFile(CentralDogma centralDogma, String project } } - private static Revision normalizeRevision(CentralDogma centralDogma, String project, - String repository, Revision revision) { + private static Revision normalizeRevision(CentralDogmaRepository centralDogmaRepository, Revision revision) { try { - return centralDogma.normalizeRevision(project, repository, revision) - .get(PROPERTY_CREATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); + return centralDogmaRepository.normalize(revision) + .get(PROPERTY_CREATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); @@ -236,13 +268,13 @@ private static Revision normalizeRevision(CentralDogma centralDogma, String proj } // visible for testing - static boolean fileExists(CentralDogma centralDogma, String project, - String repository, String filename, Revision revision) { + static boolean fileExists(CentralDogmaRepository centralDogmaRepository, String filename, Revision revision) { try { - Map files = centralDogma - .listFiles(project, repository, revision, filename) - .get(PROPERTY_CREATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); - return files.containsKey(filename); + return centralDogmaRepository + .file(PathPattern.of(filename)) + .list(revision) + .get(PROPERTY_CREATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS) + .containsKey(filename); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); diff --git a/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierIntegrationTest.java b/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierIntegrationTest.java index 5a6dd884..dde6278b 100644 --- a/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierIntegrationTest.java +++ b/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierIntegrationTest.java @@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.linecorp.centraldogma.client.CentralDogma; +import com.linecorp.centraldogma.client.CentralDogmaRepository; import com.linecorp.centraldogma.common.Change; import com.linecorp.centraldogma.common.Entry; import com.linecorp.centraldogma.common.Query; @@ -76,12 +77,13 @@ public void testCDIntegration() throws InterruptedException { + "}\n"; client.createProject(PROJECT_NAME).join(); - client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); - client.push(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, "summary", - Change.ofJsonUpsert(FILENAME, ORIGINAL)).join(); + CentralDogmaRepository centralDogmaRepository = client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); + centralDogmaRepository + .commit("summary", Change.ofJsonUpsert(FILENAME, ORIGINAL)) + .push() + .join(); - CentralDogmaPropertySupplier supplier = new CentralDogmaPropertySupplier( - client, PROJECT_NAME, REPOSITORY_NAME, FILENAME); + CentralDogmaPropertySupplier supplier = new CentralDogmaPropertySupplier(centralDogmaRepository, FILENAME); Property prop = supplier.getProperty(CONFIG_PARTITION_CONCURRENCY).get(); @@ -100,8 +102,10 @@ public void testCDIntegration() throws InterruptedException { CountDownLatch latch = new CountDownLatch(2); prop.listen((o, n) -> latch.countDown()); - client.push(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, "summary", - Change.ofJsonPatch(FILENAME, ORIGINAL, UPDATED)).join(); + centralDogmaRepository + .commit("summary", Change.ofJsonPatch(FILENAME, ORIGINAL, UPDATED)) + .push() + .join(); latch.await(); assertEquals(20, prop.value().intValue()); @@ -111,31 +115,34 @@ public void testCDIntegration() throws InterruptedException { public void testFileExist() { CentralDogma client = centralDogmaRule.client(); client.createProject(PROJECT_NAME).join(); - client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); - client.push(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, "test", - Change.ofJsonUpsert(FILENAME, "{}")).join(); + CentralDogmaRepository centralDogmaRepository = client.createRepository(PROJECT_NAME, REPOSITORY_NAME) + .join(); + + centralDogmaRepository + .commit("test", Change.ofJsonUpsert(FILENAME, "{}")) + .push() + .join(); assertTrue(CentralDogmaPropertySupplier - .fileExists(client, PROJECT_NAME, REPOSITORY_NAME, FILENAME, Revision.HEAD)); + .fileExists(centralDogmaRepository, FILENAME, Revision.HEAD)); } @Test public void testFileNonExistent() { CentralDogma client = centralDogmaRule.client(); client.createProject(PROJECT_NAME).join(); - client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); + CentralDogmaRepository centralDogmaRepository = client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); assertFalse(CentralDogmaPropertySupplier - .fileExists(client, PROJECT_NAME, REPOSITORY_NAME, FILENAME, Revision.HEAD)); + .fileExists(centralDogmaRepository, FILENAME, Revision.HEAD)); } @Test(timeout = 10000) public void testCDRegisterSuccess() { CentralDogma client = centralDogmaRule.client(); client.createProject(PROJECT_NAME).join(); - client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); + CentralDogmaRepository centralDogmaRepository = client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); - CentralDogmaPropertySupplier.register(client, PROJECT_NAME, REPOSITORY_NAME, FILENAME); - Entry prop = client.getFile(PROJECT_NAME, REPOSITORY_NAME, - Revision.HEAD, Query.ofJson(FILENAME)).join(); + CentralDogmaPropertySupplier.register(centralDogmaRepository, FILENAME); + Entry prop = centralDogmaRepository.file(Query.ofJson(FILENAME)).get().join(); assertEquals(defaultProperties().asText(), prop.content().asText()); @@ -149,17 +156,17 @@ public void testCDRegisterNonExistentProject() { @Test(timeout = 15000, expected = RuntimeException.class) public void testCDRegisterTimeout() { - CentralDogma client = spy(centralDogmaRule.client()); + CentralDogma client = centralDogmaRule.client(); client.createProject(PROJECT_NAME).join(); - client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); + CentralDogmaRepository centralDogmaRepository = spy(client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join()); doReturn(CompletableFuture.completedFuture(new Revision(1))) - .when(client) - .normalizeRevision(eq(PROJECT_NAME), eq(REPOSITORY_NAME), any()); + .when(centralDogmaRepository) + .normalize(any()); - CentralDogmaPropertySupplier.register(client, PROJECT_NAME, REPOSITORY_NAME, FILENAME); + CentralDogmaPropertySupplier.register(centralDogmaRepository, FILENAME); - CentralDogmaPropertySupplier.register(client, PROJECT_NAME, REPOSITORY_NAME, FILENAME); + CentralDogmaPropertySupplier.register(centralDogmaRepository, FILENAME); } @Test(timeout = 15000) @@ -167,29 +174,27 @@ public void testCDRegisterConflict() throws Exception { CountDownLatch userAIsRunning = new CountDownLatch(1); CountDownLatch userBIsRunning = new CountDownLatch(1); - CentralDogma userA = spy(centralDogmaRule.client()); - CentralDogma userB = centralDogmaRule.client(); + CentralDogma client = centralDogmaRule.client(); + client.createProject(PROJECT_NAME).join(); + CentralDogmaRepository userB = client.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); + CentralDogmaRepository userA = spy(client.forRepo(PROJECT_NAME, REPOSITORY_NAME)); JsonNode userBPush = Jackson.readTree("{\"foo\": \"bar\"}"); - userA.createProject(PROJECT_NAME).join(); - userA.createRepository(PROJECT_NAME, REPOSITORY_NAME).join(); - doAnswer(i -> { userAIsRunning.countDown(); userBIsRunning.await(); return i.callRealMethod(); }).when(userA) - .push(eq(PROJECT_NAME), eq(REPOSITORY_NAME), any(), any(), - eq(Change.ofJsonUpsert(FILENAME, defaultProperties()))); + .commit(any(), eq(Change.ofJsonUpsert(FILENAME, defaultProperties()))); ExecutorService service = Executors.newFixedThreadPool(2); - service.submit(() -> CentralDogmaPropertySupplier - .register(userA, PROJECT_NAME, REPOSITORY_NAME, FILENAME)); + service.submit(() -> CentralDogmaPropertySupplier.register(userA, FILENAME)); service.submit(() -> { try { userAIsRunning.await(); - userB.push(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, "test", - Change.ofJsonUpsert(FILENAME, userBPush)).join(); + userB.commit("test", Change.ofJsonUpsert(FILENAME, userBPush)) + .push() + .join(); userBIsRunning.countDown(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); @@ -199,8 +204,9 @@ public void testCDRegisterConflict() throws Exception { service.shutdown(); service.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); - Entry prop = userA.getFile(PROJECT_NAME, REPOSITORY_NAME, - Revision.HEAD, Query.ofJson(FILENAME)).join(); + Entry prop = userA.file(Query.ofJson(FILENAME)) + .get() + .join(); assertEquals(userBPush, prop.content()); } diff --git a/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierTest.java b/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierTest.java index 5f0f8b9f..c303325c 100644 --- a/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierTest.java +++ b/centraldogma/src/test/java/com/linecorp/decaton/centraldogma/CentralDogmaPropertySupplierTest.java @@ -21,10 +21,10 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -48,9 +48,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.linecorp.centraldogma.client.CentralDogma; +import com.linecorp.centraldogma.client.CentralDogmaRepository; +import com.linecorp.centraldogma.client.CommitRequest; +import com.linecorp.centraldogma.client.FilesRequest; import com.linecorp.centraldogma.client.Watcher; +import com.linecorp.centraldogma.client.WatcherRequest; import com.linecorp.centraldogma.common.Change; +import com.linecorp.centraldogma.common.PathPattern; import com.linecorp.centraldogma.common.PushResult; import com.linecorp.centraldogma.common.Query; import com.linecorp.centraldogma.common.Revision; @@ -67,8 +71,6 @@ public class CentralDogmaPropertySupplierTest { private final ObjectMapper objectMapper = new ObjectMapper(); - private static final String PROJECT_NAME = "unit-test"; - private static final String REPOSITORY_NAME = "repo"; private static final String FILENAME = "/subscription.json"; private static final PropertyDefinition LONG_PROPERTY = @@ -80,7 +82,10 @@ public class CentralDogmaPropertySupplierTest { PropertyDefinition.checkListElement(String.class)); @Mock - private CentralDogma centralDogma; + private CentralDogmaRepository centralDogmaRepository; + + @Mock + WatcherRequest watcherRequest; @Mock Watcher rootWatcher; @@ -89,10 +94,9 @@ public class CentralDogmaPropertySupplierTest { @Before public void setUp() { - when(centralDogma.fileWatcher(PROJECT_NAME, REPOSITORY_NAME, Query.ofJsonPath(FILENAME))) - .thenReturn(rootWatcher); - - supplier = new CentralDogmaPropertySupplier(centralDogma, PROJECT_NAME, REPOSITORY_NAME, FILENAME); + when(centralDogmaRepository.watcher(Query.ofJsonPath(FILENAME))).thenReturn(watcherRequest); + when(watcherRequest.start()).thenReturn(rootWatcher); + supplier = new CentralDogmaPropertySupplier(centralDogmaRepository, FILENAME); } @Test @@ -149,33 +153,23 @@ public void testGetPropertyAbsentName() { @Test public void testRegisterWithDefaultSettings() { - when(centralDogma.normalizeRevision(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD)).thenReturn( - CompletableFuture.completedFuture(Revision.HEAD) - ); - when(centralDogma.listFiles(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, FILENAME)).thenReturn( - CompletableFuture.completedFuture(Collections.emptyMap()) - ); - when(centralDogma.push( - eq(PROJECT_NAME), - eq(REPOSITORY_NAME), - eq(Revision.HEAD), - any(String.class), - eq(Change.ofJsonUpsert(FILENAME, defaultPropertiesAsJsonNode()))) - ).thenReturn( - CompletableFuture.completedFuture( - new PushResult(Revision.HEAD, 1) - ) - ); + when(centralDogmaRepository.normalize(Revision.HEAD)) + .thenReturn(CompletableFuture.completedFuture(Revision.HEAD)); + + final FilesRequest filesRequest = mock(FilesRequest.class); + when(centralDogmaRepository.file(any(PathPattern.class))).thenReturn(filesRequest); + when(filesRequest.list(Revision.HEAD)).thenReturn(CompletableFuture.completedFuture(Collections.emptyMap())); - CentralDogmaPropertySupplier.register(centralDogma, PROJECT_NAME, REPOSITORY_NAME, FILENAME); - verify(centralDogma, times(1)).push( - eq(PROJECT_NAME), - eq(REPOSITORY_NAME), - eq(Revision.HEAD), + final CommitRequest commitRequest = mock(CommitRequest.class); + when(centralDogmaRepository.commit(anyString(), eq(Change.ofJsonUpsert(FILENAME, defaultPropertiesAsJsonNode())))).thenReturn(commitRequest); + when(commitRequest.push(Revision.HEAD)).thenReturn(CompletableFuture.completedFuture(new PushResult(Revision.HEAD, 1))); + + + CentralDogmaPropertySupplier.register(centralDogmaRepository, FILENAME); + verify(centralDogmaRepository).commit( any(String.class), eq(Change.ofJsonUpsert(FILENAME, defaultPropertiesAsJsonNode())) ); - } @Test @@ -210,31 +204,20 @@ public void testRegisterWithCustomizedSettings() { final JsonNode jsonNodeProperties = CentralDogmaPropertySupplier .convertPropertyListToJsonNode(listPropertiesForVerifyingMock); - when(centralDogma.normalizeRevision(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD)).thenReturn( - CompletableFuture.completedFuture(Revision.HEAD) - ); - when(centralDogma.listFiles(PROJECT_NAME, REPOSITORY_NAME, Revision.HEAD, FILENAME)).thenReturn( - CompletableFuture.completedFuture(Collections.emptyMap()) - ); + when(centralDogmaRepository.normalize(Revision.HEAD)) + .thenReturn(CompletableFuture.completedFuture(Revision.HEAD)); - when(centralDogma.push( - eq(PROJECT_NAME), - eq(REPOSITORY_NAME), - eq(Revision.HEAD), - any(String.class), - eq(Change.ofJsonUpsert(FILENAME, jsonNodeProperties))) - ).thenReturn( - CompletableFuture.completedFuture( - new PushResult(Revision.HEAD, whenCentralDogmaPushed) - ) - ); + final FilesRequest filesRequest = mock(FilesRequest.class); + when(centralDogmaRepository.file(any(PathPattern.class))).thenReturn(filesRequest); + when(filesRequest.list(Revision.HEAD)).thenReturn(CompletableFuture.completedFuture(Collections.emptyMap())); + + final CommitRequest commitRequest = mock(CommitRequest.class); + when(centralDogmaRepository.commit(any(String.class), eq(Change.ofJsonUpsert(FILENAME, jsonNodeProperties)))).thenReturn(commitRequest); + when(commitRequest.push(Revision.HEAD)).thenReturn(CompletableFuture.completedFuture(new PushResult(Revision.HEAD, whenCentralDogmaPushed))); - CentralDogmaPropertySupplier.register(centralDogma, PROJECT_NAME, REPOSITORY_NAME, FILENAME, supplier); + CentralDogmaPropertySupplier.register(centralDogmaRepository, FILENAME, supplier); - verify(centralDogma, times(1)).push( - eq(PROJECT_NAME), - eq(REPOSITORY_NAME), - eq(Revision.HEAD), + verify(centralDogmaRepository).commit( any(String.class), eq(Change.ofJsonUpsert(FILENAME, jsonNodeProperties)) ); diff --git a/docs/example/build.gradle b/docs/example/build.gradle index eef2ffc7..cc7927f0 100644 --- a/docs/example/build.gradle +++ b/docs/example/build.gradle @@ -28,7 +28,7 @@ dependencies { implementation "org.apache.kafka:kafka-clients:$KAFKA_VERSION" // for "Consuming Arbitrary Topic" section - implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.5' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4' // for "Property Supplier" section implementation "com.linecorp.decaton:decaton-centraldogma:$DECATON_VERSION" diff --git a/processor/build.gradle b/processor/build.gradle index 334a9b20..88aef672 100644 --- a/processor/build.gradle +++ b/processor/build.gradle @@ -9,7 +9,7 @@ dependencies { implementation "org.slf4j:slf4j-api:$slf4jVersion" testImplementation project(":protobuf") - testRuntimeOnly "ch.qos.logback:logback-classic:1.2.6" + testRuntimeOnly "ch.qos.logback:logback-classic:1.3.0" testFixturesImplementation "junit:junit:$junitVersion" testFixturesImplementation "org.apache.kafka:kafka-clients:$kafkaVersion" diff --git a/testing/build.gradle b/testing/build.gradle index f5792252..df08c0a7 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -16,7 +16,7 @@ ext { noPublish = true - jacksonVersion = "2.12.3" + jacksonVersion = "2.13.4" } dependencies { implementation testFixtures(project(':processor')) @@ -38,5 +38,5 @@ dependencies { implementation "junit:junit:$junitVersion" implementation "org.hamcrest:hamcrest:$hamcrestVersion" - runtimeOnly "ch.qos.logback:logback-classic:1.2.6" + runtimeOnly "ch.qos.logback:logback-classic:1.3.0" } From 64949d15c36a73716ba6742eeee0d36cf4fb75df Mon Sep 17 00:00:00 2001 From: "vincent.pericart" Date: Thu, 15 Sep 2022 12:31:03 +0900 Subject: [PATCH 2/2] SLF4J 2.0.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a79328a1..63c9a49e 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ subprojects { } ext { - slf4jVersion = "2.0.0" + slf4jVersion = "2.0.1" protobufVersion = "3.3.0" kafkaVersion = "3.2.0" micrometerVersion = "1.7.5"