Skip to content

Commit 710c5a3

Browse files
committed
SRE-3751 ci: avoid JNI loading in DaosObjectTest
Introduce DaosObjectClient as the dependency surface used by DaosObject, implement it in DaosObjClient, and mock the interface in DaosObjectTest instead of mocking DaosObjClient directly. This removes the test's accidental dependency on native DAOS libraries, fixing failures on Fedora 43 and Leap 15.6 where libdaos.so.2 is not available at test runtime. Doc-only: true Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@hpe.com>
1 parent 9cdc10b commit 710c5a3

3 files changed

Lines changed: 37 additions & 30 deletions

File tree

src/client/java/daos-java/src/main/java/io/daos/obj/DaosObjClient.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* (C) Copyright 2018-2022 Intel Corporation.
3+
* (C) Copyright 2026 Hewlett Packard Enterprise Development LP
34
*
45
* SPDX-License-Identifier: BSD-2-Clause-Patent
56
*/
@@ -19,7 +20,7 @@
1920
* {@link DaosObject} should be create from this client for calling DAOS object APIs indirectly.
2021
* It registers itself to shutdown manager in {@link DaosClient} to release resources in case of abnormal shutdown.
2122
*/
22-
public class DaosObjClient extends ShareableClient implements ForceCloseable {
23+
public class DaosObjClient extends ShareableClient implements DaosObjectClient {
2324

2425
private long contPtr;
2526

@@ -96,7 +97,7 @@ native static void encodeObjectId(long oidBufferAddress, long contPtr, int objec
9697
* @throws DaosIOException
9798
* {@link DaosIOException}
9899
*/
99-
native long openObject(long contPtr, long oidBufferAddress, int mode) throws DaosIOException;
100+
public native long openObject(long contPtr, long oidBufferAddress, int mode) throws DaosIOException;
100101

101102
/**
102103
* close object.
@@ -106,7 +107,7 @@ native static void encodeObjectId(long oidBufferAddress, long contPtr, int objec
106107
* @throws DaosIOException
107108
* {@link DaosIOException}
108109
*/
109-
native void closeObject(long objectPtr) throws DaosIOException;
110+
public native void closeObject(long objectPtr) throws DaosIOException;
110111

111112
/**
112113
* punch an entire object with all associated with it.
@@ -118,7 +119,7 @@ native static void encodeObjectId(long oidBufferAddress, long contPtr, int objec
118119
* @throws DaosIOException
119120
* {@link DaosIOException}
120121
*/
121-
native void punchObject(long objectPtr, long flags) throws DaosIOException;
122+
public native void punchObject(long objectPtr, long flags) throws DaosIOException;
122123

123124
/**
124125
* punch dkeys (with all its akeys) from an object.
@@ -136,7 +137,8 @@ native static void encodeObjectId(long oidBufferAddress, long contPtr, int objec
136137
* @throws DaosIOException
137138
* {@link DaosIOException}
138139
*/
139-
native void punchObjectDkeys(long objectPtr, long flags, int nbrOfDkeys, long dkeysBufferAddress, int dataLen)
140+
public native void punchObjectDkeys(long objectPtr, long flags, int nbrOfDkeys, long dkeysBufferAddress,
141+
int dataLen)
140142
throws DaosIOException;
141143

142144
/**
@@ -156,7 +158,8 @@ native void punchObjectDkeys(long objectPtr, long flags, int nbrOfDkeys, long dk
156158
* @throws DaosIOException
157159
* {@link DaosIOException}
158160
*/
159-
native void punchObjectAkeys(long objectPtr, long flags, int nbrOfAkeys, long keysBufferAddress, int dataLen)
161+
public native void punchObjectAkeys(long objectPtr, long flags, int nbrOfAkeys, long keysBufferAddress,
162+
int dataLen)
160163
throws DaosIOException;
161164

162165
/**
@@ -168,7 +171,7 @@ native void punchObjectAkeys(long objectPtr, long flags, int nbrOfAkeys, long ke
168171
* @throws DaosIOException
169172
* {@link DaosIOException}
170173
*/
171-
native byte[] queryObjectAttribute(long objectPtr) throws DaosIOException;
174+
public native byte[] queryObjectAttribute(long objectPtr) throws DaosIOException;
172175

173176
/**
174177
* allocate native simple desc struct.
@@ -230,7 +233,8 @@ native void punchObjectAkeys(long objectPtr, long flags, int nbrOfAkeys, long ke
230233
* @throws DaosIOException
231234
* {@link DaosIOException}
232235
*/
233-
native void fetchObject(long objectPtr, long flags, int nbrOfEntries, long descBufferAddress, int descBufferCap)
236+
public native void fetchObject(long objectPtr, long flags, int nbrOfEntries, long descBufferAddress,
237+
int descBufferCap)
234238
throws DaosIOException;
235239

236240
/**
@@ -247,7 +251,7 @@ native void fetchObject(long objectPtr, long flags, int nbrOfEntries, long descB
247251
* is asynchronous?
248252
* @throws DaosIOException
249253
*/
250-
native void fetchObjectSimple(long objectPtr, long flags, long descBufferAddress, boolean async)
254+
public native void fetchObjectSimple(long objectPtr, long flags, long descBufferAddress, boolean async)
251255
throws DaosIOException;
252256

253257
/**
@@ -262,7 +266,7 @@ native void fetchObjectSimple(long objectPtr, long flags, long descBufferAddress
262266
* {@link IOSimpleDDAsync} and how many records to fetch
263267
* @throws DaosIOException
264268
*/
265-
native void fetchObjectAsync(long objectPtr, long flags, long descBufferAddress)
269+
public native void fetchObjectAsync(long objectPtr, long flags, long descBufferAddress)
266270
throws DaosIOException;
267271

268272
/**
@@ -282,8 +286,8 @@ native void fetchObjectAsync(long objectPtr, long flags, long descBufferAddress)
282286
* @throws DaosIOException
283287
* {@link DaosIOException}
284288
*/
285-
native void updateObject(long objectPtr, long flags, int nbrOfEntries, long descBufferAddress,
286-
int descBufferCap) throws DaosIOException;
289+
public native void updateObject(long objectPtr, long flags, int nbrOfEntries, long descBufferAddress,
290+
int descBufferCap) throws DaosIOException;
287291

288292
/**
289293
* update object with simple desc.
@@ -299,7 +303,7 @@ native void updateObject(long objectPtr, long flags, int nbrOfEntries, long desc
299303
* is asynchronous?
300304
* @throws DaosIOException
301305
*/
302-
native void updateObjectSimple(long objectPtr, long flags, long descBufferAddress, boolean async)
306+
public native void updateObjectSimple(long objectPtr, long flags, long descBufferAddress, boolean async)
303307
throws DaosIOException;
304308

305309
/**
@@ -314,7 +318,7 @@ native void updateObjectSimple(long objectPtr, long flags, long descBufferAddres
314318
* offset and index in value buffer from {@link IOSimpleDDAsync} and how many records to update
315319
* @throws DaosIOException
316320
*/
317-
native void updateObjectAsync(long objectPtr, long flags, long descBufferAddress)
321+
public native void updateObjectAsync(long objectPtr, long flags, long descBufferAddress)
318322
throws DaosIOException;
319323

320324
/**
@@ -329,8 +333,9 @@ native void updateObjectAsync(long objectPtr, long flags, long descBufferAddress
329333
* @param dataMemAddress
330334
* @throws DaosIOException
331335
*/
332-
native void updateObjAsyncNoDecode(long objectPtr, long descMemAddress, long eqWrapHdl, short eventId,
333-
long offset, int dataLen, long dataMemAddress) throws DaosIOException;
336+
public native void updateObjAsyncNoDecode(long objectPtr, long descMemAddress, long eqWrapHdl,
337+
short eventId, long offset, int dataLen,
338+
long dataMemAddress) throws DaosIOException;
334339

335340
/**
336341
* update object synchronously with one entry. Dkey and Akey are described in {@link IODescUpdSync}.
@@ -342,8 +347,8 @@ native void updateObjAsyncNoDecode(long objectPtr, long descMemAddress, long eqW
342347
* @param dataMemAddress
343348
* @throws DaosIOException
344349
*/
345-
native void updateObjSyncNoDecode(long objectPtr, long descMemAddress, long offset, int dataLen,
346-
long dataMemAddress) throws DaosIOException;
350+
public native void updateObjSyncNoDecode(long objectPtr, long descMemAddress, long offset, int dataLen,
351+
long dataMemAddress) throws DaosIOException;
347352

348353
/**
349354
* list dkeys of given object.
@@ -364,8 +369,9 @@ native void updateObjSyncNoDecode(long objectPtr, long descMemAddress, long offs
364369
* @throws DaosIOException
365370
* {@link DaosIOException}
366371
*/
367-
native void listObjectDkeys(long objectPtr, long descBufferAddress, long keyBufferAddress, int keyBufferLen,
368-
long anchorBufferAddress, int nbrOfDesc) throws DaosIOException;
372+
public native void listObjectDkeys(long objectPtr, long descBufferAddress, long keyBufferAddress,
373+
int keyBufferLen, long anchorBufferAddress, int nbrOfDesc)
374+
throws DaosIOException;
369375

370376
/**
371377
* list akeys of given object and dkey.
@@ -386,8 +392,9 @@ native void listObjectDkeys(long objectPtr, long descBufferAddress, long keyBuff
386392
* @throws DaosIOException
387393
* {@link DaosIOException}
388394
*/
389-
native void listObjectAkeys(long objectPtr, long descBufferAddress, long keyBufferAddress, int keyBufferLen,
390-
long anchorBufferAddress, int nbrOfDesc) throws DaosIOException;
395+
public native void listObjectAkeys(long objectPtr, long descBufferAddress, long keyBufferAddress,
396+
int keyBufferLen, long anchorBufferAddress, int nbrOfDesc)
397+
throws DaosIOException;
391398

392399
/**
393400
* get record size of given dkey and akey encoded in direct buffer with given <code>address</code>.
@@ -399,7 +406,7 @@ native void listObjectAkeys(long objectPtr, long descBufferAddress, long keyBuff
399406
* @return record size
400407
* @throws DaosIOException
401408
*/
402-
native int getRecordSize(long objectPtr, long address) throws DaosIOException;
409+
public native int getRecordSize(long objectPtr, long address) throws DaosIOException;
403410

404411
/**
405412
* release the native IO desc identified by <code>descPtr</code>.

src/client/java/daos-java/src/main/java/io/daos/obj/DaosObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class DaosObject {
3434

35-
private DaosObjClient client;
35+
private DaosObjectClient client;
3636

3737
private long contPtr;
3838

@@ -55,7 +55,7 @@ public class DaosObject {
5555
* @param oid
5656
* encoded DAOS object id
5757
*/
58-
protected DaosObject(DaosObjClient client, DaosObjectId oid) {
58+
protected DaosObject(DaosObjectClient client, DaosObjectId oid) {
5959
this.oid = oid;
6060
this.client = client;
6161
this.contPtr = client.getContPtr();

src/client/java/daos-java/src/test/java/io/daos/obj/DaosObjectTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class DaosObjectTest {
2525
buf.writeLong(0L).writeLong(0L);
2626
Whitebox.setInternalState(oid, "encoded", true);
2727
Whitebox.setInternalState(oid, "buffer", buf);
28-
DaosObjClient client = Mockito.mock(DaosObjClient.class);
28+
DaosObjectClient client = Mockito.mock(DaosObjectClient.class);
2929
long contPtr = 12345;
3030
long address = oid.getBuffer().memoryAddress();
3131
long objPtr = 6789;
@@ -48,7 +48,7 @@ public void testObjectIdEncode() throws Exception {
4848

4949
Exception ee = null;
5050
try {
51-
new DaosObject(Mockito.mock(DaosObjClient.class), oid);
51+
new DaosObject(Mockito.mock(DaosObjectClient.class), oid);
5252
} catch (Exception e) {
5353
ee = e;
5454
}
@@ -62,7 +62,7 @@ public void testPunchEmptyDkeys() throws Exception {
6262
Exception ee = null;
6363
try {
6464
object.open();
65-
object.punchDkeys(Collections.EMPTY_LIST);
65+
object.punchDkeys(Collections.emptyList());
6666
} catch (Exception e) {
6767
ee = e;
6868
}
@@ -76,7 +76,7 @@ public void testPunchEmptyAkeys() throws Exception {
7676
Exception ee = null;
7777
try {
7878
object.open();
79-
object.punchAkeys("dkey1", Collections.EMPTY_LIST);
79+
object.punchAkeys("dkey1", Collections.emptyList());
8080
} catch (Exception e) {
8181
ee = e;
8282
}
@@ -90,7 +90,7 @@ public void testListAkeysWithNullDkey() throws Exception {
9090
Exception ee = null;
9191
try {
9292
object.open();
93-
IOKeyDesc desc = object.createKD(null);
93+
IOKeyDesc desc = DaosObject.createKD(null);
9494
try {
9595
object.listAkeys(desc);
9696
} finally {

0 commit comments

Comments
 (0)