Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API tests to load extension & fix Python API extension loading #2891

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Loading