|
20 | 20 | package org.neo4j.gds.similarity.filterednodesim; |
21 | 21 |
|
22 | 22 | import org.junit.jupiter.api.Test; |
| 23 | +import org.junit.jupiter.params.ParameterizedTest; |
| 24 | +import org.junit.jupiter.params.provider.ValueSource; |
| 25 | +import org.neo4j.gds.TestProgressTracker; |
| 26 | +import org.neo4j.gds.compat.Neo4jProxy; |
| 27 | +import org.neo4j.gds.compat.TestLog; |
| 28 | +import org.neo4j.gds.core.utils.progress.EmptyTaskRegistryFactory; |
23 | 29 | import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; |
24 | 30 | import org.neo4j.gds.extension.GdlExtension; |
25 | 31 | import org.neo4j.gds.extension.GdlGraph; |
|
30 | 36 | import java.util.List; |
31 | 37 |
|
32 | 38 | import static org.assertj.core.api.Assertions.assertThat; |
| 39 | +import static org.neo4j.gds.assertj.Extractors.removingThreadId; |
| 40 | +import static org.neo4j.gds.compat.TestLog.INFO; |
33 | 41 |
|
34 | 42 | @GdlExtension |
35 | 43 | class FilteredNodeSimilarityTest { |
@@ -154,4 +162,55 @@ void shouldSurviveIoannisFurtherObjections() { |
154 | 162 |
|
155 | 163 | nodeSimilarity.release(); |
156 | 164 | } |
| 165 | + |
| 166 | + @ParameterizedTest |
| 167 | + @ValueSource(ints = {1, 2}) |
| 168 | + void shouldLogProgressAccurately(int concurrency) { |
| 169 | + var sourceNodeFilter = List.of(2L, 3L); |
| 170 | + |
| 171 | + var config = ImmutableFilteredNodeSimilarityStreamConfig.builder() |
| 172 | + .sourceNodeFilter(NodeFilterSpecFactory.create(sourceNodeFilter)) |
| 173 | + .concurrency(concurrency) |
| 174 | + .topK(0) |
| 175 | + .topN(10) |
| 176 | + .build(); |
| 177 | + var progressTask = new FilteredNodeSimilarityFactory<>().progressTask(graph, config); |
| 178 | + TestLog log = Neo4jProxy.testLog(); |
| 179 | + var progressTracker = new TestProgressTracker( |
| 180 | + progressTask, |
| 181 | + log, |
| 182 | + concurrency, |
| 183 | + EmptyTaskRegistryFactory.INSTANCE |
| 184 | + ); |
| 185 | + |
| 186 | + |
| 187 | + new FilteredNodeSimilarityFactory<>().build( |
| 188 | + graph, |
| 189 | + config, |
| 190 | + progressTracker |
| 191 | + ).compute(); |
| 192 | + |
| 193 | + |
| 194 | + assertThat(log.getMessages(INFO)) |
| 195 | + .extracting(removingThreadId()) |
| 196 | + .containsExactly( |
| 197 | + "FilteredNodeSimilarity :: Start", |
| 198 | + "FilteredNodeSimilarity :: prepare :: Start", |
| 199 | + "FilteredNodeSimilarity :: prepare 33%", |
| 200 | + "FilteredNodeSimilarity :: prepare 55%", |
| 201 | + "FilteredNodeSimilarity :: prepare 66%", |
| 202 | + "FilteredNodeSimilarity :: prepare 100%", |
| 203 | + "FilteredNodeSimilarity :: prepare :: Finished", |
| 204 | + "FilteredNodeSimilarity :: compare node pairs :: Start", |
| 205 | + "FilteredNodeSimilarity :: compare node pairs 12%", |
| 206 | + "FilteredNodeSimilarity :: compare node pairs 25%", |
| 207 | + "FilteredNodeSimilarity :: compare node pairs 37%", |
| 208 | + "FilteredNodeSimilarity :: compare node pairs 50%", |
| 209 | + "FilteredNodeSimilarity :: compare node pairs 62%", |
| 210 | + "FilteredNodeSimilarity :: compare node pairs 75%", |
| 211 | + "FilteredNodeSimilarity :: compare node pairs 100%", |
| 212 | + "FilteredNodeSimilarity :: compare node pairs :: Finished", |
| 213 | + "FilteredNodeSimilarity :: Finished" |
| 214 | + ); |
| 215 | + } |
157 | 216 | } |
0 commit comments