Skip to content

Commit

Permalink
[NOID] fix time assertion GeocodeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed May 10, 2023
1 parent 6f3dac5 commit 559572f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subprojects {
archiveClassifier = 'javadoc'
}
test {
//exclude '**/CypherProceduresClusterTest.class'//, '**/AtomicTest.class'
include '**/GeocodeTest.class'//, '**/AtomicTest.class'

// neo4jDockerImage system property is used in TestContainerUtil
systemProperties 'user.language' : 'en' ,
Expand Down
19 changes: 15 additions & 4 deletions core/src/test/java/apoc/spatial/GeocodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ public void initDb() throws Exception {
// -- with config map
@Test
public void testWrongUrlButViaOtherProvider() throws Exception {
for (int i = 0; i < 20; i++) {
System.out.println("i = " + i);
// wrong url but doesn't fail because provider is osm, not opencage
testGeocodeWithThrottling("osm", false,
testGeocodeWithThrottling("osm", false,
map("url", "https://api.opencagedata.com/geocode/v1/json?q=PLACE&key=KEY111"));

}
}

@Test(expected = QueryExecutionException.class)
public void testWrongUrlWithOpenCage() throws Exception {
// overwrite ApocConfig provider
Expand Down Expand Up @@ -108,7 +112,7 @@ public void testGeocodeWithBlockedAddressWithApocConf() {
assertGeocodeAllowedUrl(true);
});
}

@Test
public void testGeocodeWithBlockedAddressWithConfigMap() {
Stream.of("https", "http", "ftp").forEach(protocol -> {
Expand Down Expand Up @@ -176,7 +180,10 @@ private void assertGeocodeFails(boolean reverseGeocode, String expectedMsgError,

@Test
public void testGeocodeOSM() throws Exception {
for (int i = 0; i < 20; i++) {
testGeocodeWithThrottling("osm", false);

}
}

@Test
Expand All @@ -189,7 +196,9 @@ private void testGeocodeWithThrottling(String supplier, Boolean reverseGeocode)
}

private void testGeocodeWithThrottling(String supplier, Boolean reverseGeocode, Map<String, Object> config) throws Exception {
System.out.println("GeocodeTest.testGeocodeWithThrottling");
long fast = testGeocode(supplier, 100, reverseGeocode, config);
System.out.println("fast done...");
long slow = testGeocode(supplier, 2000, reverseGeocode, config);
assertTrue("Fast " + supplier + " took " + fast + "ms and slow took " + slow + "ms, but expected slow to be at least twice as long", (1.0 * slow / fast) > 1.2);
}
Expand Down Expand Up @@ -339,7 +348,9 @@ private void waitForServerResponseOK(String query, Map<String, Object> params, A
return null;
});

time.addAndGet( System.currentTimeMillis() - start );
long delta = System.currentTimeMillis() - start;
System.out.println("delta = " + delta);
time.addAndGet(delta);
return true;
} catch (Exception e) {
String msg = e.getMessage();
Expand Down

0 comments on commit 559572f

Please sign in to comment.