2727import org .junit .jupiter .params .provider .Arguments ;
2828import org .junit .jupiter .params .provider .EnumSource ;
2929import org .junit .jupiter .params .provider .MethodSource ;
30- import org .neo4j .gds .similarity .nodesim .NodeSimilarityStatsProc ;
3130import org .neo4j .gds .BaseProcTest ;
3231import org .neo4j .gds .config .RandomGraphGeneratorConfig ;
3332import org .neo4j .gds .core .loading .GraphStoreCatalog ;
33+ import org .neo4j .gds .core .utils .mem .MemoryRange ;
34+ import org .neo4j .gds .similarity .nodesim .NodeSimilarityStatsProc ;
3435import org .neo4j .graphdb .QueryExecutionException ;
3536
3637import java .util .ArrayList ;
4748import static org .junit .jupiter .api .Assertions .assertNull ;
4849import static org .junit .jupiter .api .Assertions .assertThrows ;
4950import static org .junit .jupiter .api .Assertions .assertTrue ;
50- import static org .neo4j .gds .compat .MapUtil .map ;
51- import static org .neo4j .gds .core .CypherMapWrapper .create ;
52- import static org .neo4j .gds .utils .StringFormatting .formatWithLocale ;
51+ import static org .neo4j .gds .TestSupport .assertCypherMemoryEstimation ;
5352import static org .neo4j .gds .TestSupport .assertGraphEquals ;
53+ import static org .neo4j .gds .compat .MapUtil .map ;
5454import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_DISTRIBUTION_KEY ;
5555import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_PROPERTY_KEY ;
5656import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_PROPERTY_MAX_KEY ;
5959import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_PROPERTY_TYPE_KEY ;
6060import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_PROPERTY_VALUE_KEY ;
6161import static org .neo4j .gds .config .RandomGraphGeneratorConfig .RELATIONSHIP_SEED_KEY ;
62+ import static org .neo4j .gds .core .CypherMapWrapper .create ;
6263import static org .neo4j .gds .utils .ExceptionUtil .rootCause ;
64+ import static org .neo4j .gds .utils .StringFormatting .formatWithLocale ;
6365
6466class GraphGenerateProcTest extends BaseProcTest {
6567
@@ -120,7 +122,7 @@ void shouldThrowIfGraphAlreadyExists() {
120122
121123 @ ParameterizedTest
122124 @ MethodSource ("estimations" )
123- void shouldWorkWithEstimate (int nodeCount , int avgDegree , String memReq ) {
125+ void shouldWorkWithEstimate (int nodeCount , int avgDegree , MemoryRange expected ) {
124126 String generateQ =
125127 "CALL gds.beta.graph.generate( " +
126128 " 'g', " +
@@ -134,11 +136,9 @@ void shouldWorkWithEstimate(int nodeCount, int avgDegree, String memReq) {
134136 "CALL gds.nodeSimilarity.stats.estimate( " +
135137 " 'g', " +
136138 " {} " +
137- ") YIELD requiredMemory " ;
139+ ") YIELD bytesMin, bytesMax, nodeCount, relationshipCount " ;
138140
139- runQueryWithRowConsumer (estimateQ , row ->
140- assertEquals (memReq , row .getString ("requiredMemory" ))
141- );
141+ assertCypherMemoryEstimation (db , estimateQ , expected , nodeCount , nodeCount * avgDegree );
142142 }
143143
144144 @ Test
@@ -389,9 +389,9 @@ static Stream<Arguments> invalidRelationshipPropertyProducers() {
389389
390390 private static Stream <Arguments > estimations () {
391391 return Stream .of (
392- Arguments .of (100 , 2 , "[27 KiB ... 30 KiB]" ),
393- Arguments .of (100 , 4 , "[29 KiB ... 33 KiB]" ),
394- Arguments .of (200 , 4 , "[57 KiB ... 67 KiB]" )
392+ Arguments .of (100 , 2 , MemoryRange . of ( 28_088 , 31_288 ) ),
393+ Arguments .of (100 , 4 , MemoryRange . of ( 29_688 , 34_488 ) ),
394+ Arguments .of (200 , 4 , MemoryRange . of ( 59_304 , 68_904 ) )
395395 );
396396 }
397397}
0 commit comments