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

test(binding/java): add behavior test framework #3129

Merged
merged 26 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
43cbec8
test(binding/java): add behavior test
G-XD Sep 18, 2023
c51bbab
test(binding/java): override append test for s3
G-XD Sep 18, 2023
a878d0d
ci(services/redis): add behavior test for binding java
G-XD Sep 18, 2023
e72e742
ci(services/s3): add behavior test for binding java
G-XD Sep 18, 2023
2a165e4
test(binding/java): del redis test
G-XD Sep 18, 2023
396c019
test(binding/java): add behavior test for memory & fs
G-XD Sep 18, 2023
418d5e6
style(binding/java): fix code style
G-XD Sep 18, 2023
d5d8dd8
test(binding/java): del cucumber test
G-XD Sep 18, 2023
60e2b4d
test(binding/java): refactor append test
G-XD Sep 18, 2023
bd95181
test(binding/java): refactor blocking test
G-XD Sep 19, 2023
f14775a
test(binding/java): skip tests if the env is not set
G-XD Sep 19, 2023
9afb744
ci(services/redis): setup redis server
G-XD Sep 19, 2023
8e621a6
chore(binding/java): reuse the .env.example
G-XD Sep 19, 2023
708d325
feat(binding/java): support info ops
G-XD Sep 21, 2023
5b022c0
test(binding/java): add operator info test
G-XD Sep 21, 2023
1fe237c
test(binding/java): refactor behavior test
G-XD Sep 21, 2023
c7d354f
Merge branch 'main' into behavior_test_java
G-XD Sep 21, 2023
accfdc8
test(binding/java): fix code style
G-XD Sep 21, 2023
30d4df8
test(binding/java): reuse the .env file
G-XD Sep 21, 2023
cefcc73
ci(binding/java): fix test command
G-XD Sep 21, 2023
55a495a
Merge branch 'main' into behavior_test_java
G-XD Sep 21, 2023
5d9bfd9
test(binding/java): init all services test that OPENDAL_<SERVICE>_ON …
G-XD Sep 21, 2023
f3019b9
ci(binding/java): del test
G-XD Sep 21, 2023
f6d8395
test(binding/java): skip test when no services turn on
G-XD Sep 21, 2023
658a675
doc(binding/java): update doc
G-XD Sep 21, 2023
aee4b5c
test(binding/java): del schema enum
G-XD Sep 22, 2023
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
23 changes: 23 additions & 0 deletions .github/workflows/service_test_redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,26 @@ jobs:
OPENDAL_REDIS_ENDPOINT: tcp://127.0.0.1:6379
OPENDAL_REDIS_ROOT: /
OPENDAL_REDIS_DB: 0

binding_java_redis:
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: ./.github/actions/setup

- name: Setup Redis Server
shell: bash
working-directory: fixtures/redis
run: docker-compose -f docker-compose-redis.yml up -d

- name: Test
shell: bash
working-directory: bindings/java
run: ./mvnw test -Dcargo-build.features=services-redis -Dtest=org.apache.opendal.services.RedisTest
env:
OPENDAL_REDIS_TEST: on
OPENDAL_REDIS_ENDPOINT: tcp://127.0.0.1:6379
OPENDAL_REDIS_ROOT: /
OPENDAL_REDIS_DB: 0
21 changes: 21 additions & 0 deletions .github/workflows/service_test_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,24 @@ jobs:
# This is the R2's limitation
# Refer to https://opendal.apache.org/docs/services/s3#compatible-services for more information
OPENDAL_S3_ENABLE_EXACT_BUF_WRITE: true

binding_java_s3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: ./.github/actions/setup

- name: Test
shell: bash
working-directory: bindings/java
run: ./mvnw test -Dtest=org.apache.opendal.services.S3Test
env:
OPENDAL_S3_TEST: ${{ secrets.OPENDAL_S3_TEST }}
OPENDAL_S3_ROOT: ${{ secrets.OPENDAL_S3_ROOT }}
OPENDAL_S3_BUCKET: ${{ secrets.OPENDAL_S3_BUCKET }}
OPENDAL_S3_ENDPOINT: ${{ secrets.OPENDAL_S3_ENDPOINT }}
OPENDAL_S3_ACCESS_KEY_ID: ${{ secrets.OPENDAL_S3_ACCESS_KEY_ID }}
OPENDAL_S3_SECRET_ACCESS_KEY: ${{ secrets.OPENDAL_S3_SECRET_ACCESS_KEY }}
OPENDAL_S3_REGION: ap-northeast-1
166 changes: 166 additions & 0 deletions bindings/java/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# memory
G-XD marked this conversation as resolved.
Show resolved Hide resolved
OPENDAL_MEMORY_TEST=on
# fs
OPENDAL_FS_TEST=false
OPENDAL_FS_ROOT=/path/to/dir
OPENDAL_FS_ATOMIC_WRITE_DIR=/path/to/tempdir
# cos
OPENDAL_COS_TEST=false
OPENDAL_COS_BUCKET=opendal-testing-1318209832
OPENDAL_COS_ENDPOINT=https://cos.ap-singapore.myqcloud.com
OPENDAL_COS_SECRET_ID=<secret_id>
OPENDAL_COS_SECRET_KEY=<secret_key>
# s3
OPENDAL_S3_TEST=false
OPENDAL_S3_BUCKET=<bucket>
OPENDAL_S3_ENDPOINT=<endpoint>
OPENDAL_S3_REGION=<region>
OPENDAL_S3_ACCESS_KEY_ID=<access_key_id>
OPENDAL_S3_SECRET_ACCESS_KEY=<secret_access_key>
# azblob
OPENDAL_AZBLOB_TEST=false
OPENDAL_AZBLOB_ROOT=/path/to/dir
OPENDAL_AZBLOB_CONTAINER=<container>
OPENDAL_AZBLOB_ENDPOINT=<endpoint>
OPENDAL_AZBLOB_ACCOUNT_NAME=<account_name>
OPENDAL_AZBLOB_ACCOUNT_KEY=<account_key>
# hdfs
OPENDAL_HDFS_TEST=false
OPENDAL_HDFS_ROOT=/path/to/dir
OPENDAL_HDFS_NAME_NODE=<name_node>
# gcs
OPENDAL_GCS_TEST=false
OPENDAL_GCS_ROOT=/path/to/dir
OPENDAL_GCS_BUCKET=<bucket>
OPENDAL_GCS_CREDENTIAL=<base64_content>
# obs
OPENDAL_OBS_TEST=false
OPENDAL_OBS_BUCKET=<bucket>
OPENDAL_OBS_ENDPOINT=<endpoint>
OPENDAL_OBS_ACCESS_KEY_ID=<access_key_id>
OPENDAL_OBS_SECRET_ACCESS_KEY=<secret_access_key>
# oss
OPENDAL_OSS_TEST=false
OPENDAL_OSS_BUCKET=<bucket>
OPENDAL_OSS_ENDPOINT=<endpoint>
OPENDAL_OSS_ACCESS_KEY_ID=<access_key_id>
OPENDAL_OSS_ACCESS_KEY_SECRET=<access_key_secret>
# ipmfs
OPENDAL_IPMFS_TEST=false
OPENDAL_IPMFS_ROOT=/path/to/dir
OPENDAL_IPMFS_ENDPOINT=http://localhost:5001
# ftp
OPENDAL_FTP_TEST=false
OPENDAL_FTP_ENDPOINT=ftp://<endpoint>
OPENDAL_FTP_ROOT=/path/to/dir
OPENDAL_FTP_USER=<user>
OPENDAL_FTP_PASSWORD=<password>
# ipfs
OPENDAL_IPFS_TEST=false
OPENDAL_IPFS_ROOT=/ipfs/Qmxxxxxxxx
OPENDAL_IPFS_ENDPOINT=http://localhost:8080
# redis
OPENDAL_REDIS_TEST=false
OPENDAL_REDIS_ENDPOINT=tcp://127.0.0.1:6379
# OPENDAL_REDIS_CLUSTER_ENDPOINTS=rediss://127.0.0.1:6380,rediss://127.0.0.1:6381,rediss://127.0.0.1:6382,rediss://127.0.0.1:6383,rediss://127.0.0.1:6384,rediss://127.0.0.1:6385
OPENDAL_REDIS_ROOT=/
OPENDAL_REDIS_DB=0
# rocksdb
OPENDAL_ROCKSDB_TEST=false
OPENDAL_ROCKSDB_DATADIR=/path/to/database
OPENDAL_ROCKSDB_ROOT=/path/to/root
# sftp
OPENDAL_SFTP_TEST=false
OPENDAL_SFTP_ENDPOINT=ssh://<endpoint>
OPENDAL_SFTP_ROOT=/path/to/dir
OPENDAL_SFTP_USER=<user>
OPENDAL_SFTP_KEY=<key_path>
OPENDAL_SFTP_KNOWN_HOSTS_STRATEGY=<accept|add|strict>
# sled
OPENDAL_SLED_TEST=false
OPENDAL_SLED_DATADIR=/path/to/database
OPENDAL_SLED_TREE=sled-tree
# mini-moka
OPENDAL_MINI_MOKA_TEST=false
# moka
OPENDAL_MOKA_TEST=false
# ghac
OPENDAL_GHAC_TEST=false
# memcached
OPENDAL_MEMCACHED_TEST=false
OPENDAL_MEMCACHED_ENDPOINT=tcp://127.0.0.1:11211
OPENDAL_MEMCACHED_ROOT=/
# webdav
OPENDAL_WEBDAV_TEST=false
OPENDAL_WEBDAV_ROOT=/tmp/opendal/
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8080
# webhfds
OPENDAL_WEBHDFS_TEST=false
OPENDAL_WEBHDFS_ROOT=/tmp/opendal/
OPENDAL_WEBHDFS_ENDPOINT=http://127.0.0.1:9870
OPENDAL_WEBHDFS_DELEGATION=<delegation>
OPENDAL_WEBHDFS_DISABLE_LIST_BATCH=false
# supbase
OPENDAL_SUPABASE_TEST=false
OPENDAL_SUPABASE_BUCKET=<bucket>
OPENDAL_SUPABASE_ENDPOINT=<endpoint>
OPENDAL_SUPABASE_KEY=<service_key>
# vercel artifacts
OPENDAL_VERCEL_ARTIFACTS_TEST=false
OPENDAL_VERCEL_ARTIFACTS_ACCESS_TOKEN=<token>
# onedrive
OPENDAL_ONEDRIVE_TEST=false
OPENDAL_ONEDRIVE_ACCESS_TOKEN=<access_token>
# wasabi
OPENDAL_WASABI_TEST=false
OPENDAL_WASABI_REGION=<region>
OPENDAL_WASABI_BUCKET=<bucket>
OPENDAL_WASABI_ENDPOINT=<endpoint>
OPENDAL_WASABI_ACCESS_KEY_ID=<ak>
OPENDAL_WASABI_SECRET_ACCESS_KEY=<sk>
# atomicserver
OPENDAL_ATOMICSERVER_TEST=false
OPENDAL_ATOMICSERVER_ROOT=/path/to/dir
OPENDAL_ATOMICSERVER_ENDPOINT=http://localhost:9883
OPENDAL_ATOMICSERVER_PRIVATE_KEY=<private_key>
OPENDAL_ATOMICSERVER_PUBLIC_KEY=<public_key>
OPENDAL_ATOMICSERVER_PARENT_RESOURCE_ID=http://localhost:9883
# foundationdb
OPENDAL_FOUNDATIONDB_TEST=false
OPENDAL_FOUNDATIONDB_ROOT=/path/to/dir
OPENDAL_FOUNDATIONDB_CONFIG_PATH=/tmp/opendal/foundationdb.conf
# redb
OPENDAL_REDB_TEST=false
OPENDAL_REDB_DATADIR=/tmp/redb
OPENDAL_REDB_TABLE=redb-table
# cacache
OPENDAL_CACACHE_TEST=false
OPENDAL_CACACHE_DATADIR=/tmp/opendal/cacache/
# persy
OPENDAL_PERSY_TEST=false
OPENDAL_PERSY_DATAFILE=/tmp/opendal/test.persy
OPENDAL_PERSY_SEGMENT=data
OPENDAL_PERSY_INDEX=index
#dropbox
OPENDAL_DROPBOX_TEST=false
OPENDAL_DROPBOX_ROOT=/tmp/opendal/
OPENDAL_DROPBOX_ACCESS_TOKEN=<access_token>
OPENDAL_DROPBOX_REFRESH_TOKEN=<refresh_token>
OPENDAL_DROPBOX_CLIENT_ID=<client_id>
OPENDAL_DROPBOX_CLIENT_SECRET=<client_secret>
# etcd
OPENDAL_ETCD_TEST=false
OPENDAL_ETCD_ENDPOINTS=127.0.0.1:2379
OPENDAL_ETCD_ROOT=/tmp/opendal/
OPENDAL_ETCD_USERNAME=<username>
OPENDAL_ETCD_PASSWORD=<password>
OPENDAL_ETCD_CA_PATH=<ca_path>
OPENDAL_ETCD_CERT_PATH=<cert_path>
OPENDAL_ETCD_KEY_PATH=<key_path>
# google drive
OPENDAL_GDRIVE_TEST=false
OPENDAL_GDRIVE_ROOT=/tmp/opendal/
OPENDAL_GDRIVE_ACCESS_TOKEN=<access_token>
OPENDAL_GDRIVE_REFRESH_TOKEN=<refresh_token>
OPENDAL_GDRIVE_CLIENT_ID=<client_id>
OPENDAL_GDRIVE_CLIENT_SECRET=<client_secret>
36 changes: 34 additions & 2 deletions bindings/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,48 @@ You can use Maven to build both Rust dynamic lib and JAR files with one command
./mvnw clean package -DskipTests=true
```

## Setup Tests
G-XD marked this conversation as resolved.
Show resolved Hide resolved

Please copy `.env.example` to `src/test/resources/.env` and change the values on need.
G-XD marked this conversation as resolved.
Show resolved Hide resolved

Take `fs` for example, we need to enable bench on `fs` on `/tmp`.

```dotenv
OPENDAL_FS_TEST=false
OPENDAL_FS_ROOT=/path/to/dir
```

into

```dotenv
OPENDAL_FS_TEST=on
OPENDAL_FS_ROOT=/tmp
```

Notice: The default will skip all benches if the env is not set.

## Run tests

Currently, all tests are written in Java. It contains the Cucumber feature tests and other unit tests.
Currently, all tests are written in Java.

You can run tests with the following command:
You can run all available backends tests with the following command:

```shell
./mvnw clean verify -Dcargo-build.features=services-redis
```

Test specific backend(such as `fs`).

```shell
./mvnw test -Dtest=org.apache.opendal.services.FsTest
```

Test specific backend(such as `redis`).

```shell
./mvnw test -Dtest=org.apache.opendal.services.RedisTest -Dcargo-build.features=services-redis
```

> **Note:**
>
> The `-Dcargo-build.features=services-redis` argument is a temporary workaround. See also:
Expand Down
Loading