Skip to content

Commit

Permalink
Merge pull request #2891 from kuzudb/fix-extension-load
Browse files Browse the repository at this point in the history
Add API tests to load extension & fix Python API extension loading
  • Loading branch information
acquamarin authored Feb 15, 2024
2 parents 11b6964 + e6e05b2 commit 7d41ce0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/java_api/src/test/java/com/kuzudb/test/ExtensionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kuzudb.java_test;

import com.kuzudb.*;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class ExtensionTest extends TestBase {
@Test
void HttpfsInstallAndLoad() throws KuzuObjectRefDestroyedException {
KuzuQueryResult result = conn.query("INSTALL httpfs");
assertTrue(result.isSuccess());
result.destroy();
// Skip loading the extension for now until the fix is in place
// result = conn.query("LOAD EXTENSION httpfs");
// assertTrue(result.isSuccess());
// result.destroy();
}
}
1 change: 1 addition & 0 deletions tools/nodejs_api/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("kuzu", () => {
importTest("Connection", "./test_connection.js");
importTest("Query result", "./test_query_result.js");
importTest("Data types", "./test_data_type.js");
importTest("Extension loading", "./test_extension.js");
importTest("Query parameters", "./test_parameter.js");
importTest("Concurrent query execution", "./test_concurrency.js");
});
9 changes: 9 additions & 0 deletions tools/nodejs_api/test/test_extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { assert } = require("chai");

describe("Extension loading", () => {
it("should install and load httpfs extension", async function () {
await conn.query("INSTALL httpfs");
// Skip this test until the fix is in place
// await conn.query("LOAD EXTENSION httpfs");
});
});
13 changes: 13 additions & 0 deletions tools/python_api/src_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@
"""

import sys
import os

# Set RTLD_GLOBAL and RTLD_NOW flags on Linux to fix the issue with loading
# extensions
if sys.platform == "linux":
original_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

from .database import *
from .connection import *
from .query_result import *
from .types import *

# Restore the original dlopen flags
if sys.platform == "linux":
sys.setdlopenflags(original_dlopen_flags)
4 changes: 4 additions & 0 deletions tools/python_api/test/test_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_install_and_load_httpfs(establish_connection):
conn, db = establish_connection
conn.execute("INSTALL httpfs")
conn.execute("LOAD EXTENSION httpfs")

0 comments on commit 7d41ce0

Please sign in to comment.