Skip to content

Commit

Permalink
Fixes #4197: apoc.monitor.store fails for block stores (#4223) (#4289)
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 authored Dec 10, 2024
1 parent 15b8da4 commit c7671ca
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package apoc.monitor;

import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import org.neo4j.driver.Session;

import java.util.List;

import static apoc.util.TestContainerUtil.createEnterpriseDB;
import static apoc.util.TestContainerUtil.testCall;
import static org.junit.Assert.assertNotNull;

public class StoreInfoProcedureEnterpriseTest {
private static Neo4jContainerExtension neo4jContainer;
private static Session session;

@BeforeClass
public static void setUp() throws Exception {
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.EXTENDED), true);
neo4jContainer.start();

session = neo4jContainer.getSession();
}

@AfterClass
public static void tearDown() {
session.close();
neo4jContainer.close();
}

@Test
public void testGetStoreInfo() {
testCall(session, "CALL apoc.monitor.store()", (row) -> {
assertNotNull(row.get("logSize"));
assertNotNull(row.get("stringStoreSize"));
assertNotNull(row.get("arrayStoreSize"));
assertNotNull(row.get("nodeStoreSize"));
assertNotNull(row.get("relStoreSize"));
assertNotNull(row.get("propStoreSize"));
assertNotNull(row.get("totalStoreSize"));
});
}
}
2 changes: 1 addition & 1 deletion extended/src/main/java/apoc/monitor/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Stream<StoreInfoResult> store() {

Database database = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(Database.class);
//This will work only on Record format databases. Has to be updated when any additional format is available
RecordDatabaseLayout databaseLayout = RecordDatabaseLayout.cast( database.getDatabaseLayout() );
RecordDatabaseLayout databaseLayout = RecordDatabaseLayout.convert( database.getDatabaseLayout() );
return Stream.of(new StoreInfoResult(
getDirectorySize(databaseLayout.getTransactionLogsDirectory().toFile()),
databaseLayout.propertyStringStore().toFile().length(),
Expand Down

0 comments on commit c7671ca

Please sign in to comment.