Skip to content

Commit 5fef5f2

Browse files
authored
Merge pull request #25 from picoded/mongodb-support
Mongodb support
2 parents fb8ed47 + e34ca60 commit 5fef5f2

16 files changed

Lines changed: 1301 additions & 49 deletions

.github/workflows/gradle-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Core Test & Binary Build
22
on:
33
push:
4-
branches: [ master, eugene/* ]
4+
branches: [ master, "*" ]
55
pull_request:
66
branches: [ master ]
77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-18.04
1010
steps:
1111
- uses: actions/checkout@v1
1212
- name: Init submodules

.github/workflows/hazelcast.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Local Hazelcast Test
2+
on:
3+
push:
4+
branches: [ master, "hazelcast*", "*hazelcast*" ]
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
unit_test:
9+
runs-on: ubuntu-latest
10+
11+
# Because github services, does not allow overwriting "CMD" / "ENTRYPOINT" commands
12+
# so we are gonna to run the docker containers via the bash commandline
13+
# services:
14+
# postgres:
15+
# image: cockroachdb/cockroach:v21.1.12
16+
# env:
17+
# POSTGRES_DATABASE: javacommons
18+
# POSTGRES_USER: javacommons
19+
# POSTGRES_PASSWORD: javacommons
20+
# ports:
21+
# - 26257:26257
22+
# options: --health-cmd="curl http://localhost:8080/health?ready=1" --health-interval=10s --health-timeout=5s --health-retries=3
23+
24+
steps:
25+
- uses: actions/checkout@v1
26+
- name: Init submodules
27+
run: ./git-init-submodules.sh
28+
- name: Set up JDK 1.8
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: 1.8
32+
- name: Cache Gradle packages
33+
uses: actions/cache@v2
34+
with:
35+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/build.gradle') }}
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
- name: Setup gradle binaries
40+
run: ./gradlew
41+
- name: Pull dependencies libs, and perform initial compile
42+
run: ./gradlew src
43+
- name: Run unit tests
44+
run: ./gradlew test -Ptest_hazelcast
45+
- name: Run jacocoTestReport
46+
run: ./gradlew jacocoTestReport
47+
- name: Archive code coverage results
48+
uses: actions/upload-artifact@v2
49+
if: always()
50+
with:
51+
name: test-result-report
52+
path: |
53+
build/reports/**/*
54+
build/test-results/**/*
55+
build/jacoco/**/*
56+
- name: Upload code coverage to codecov
57+
uses: codecov/codecov-action@v2
58+
if: always()
59+
with:
60+
# flags: gradle-build # optional
61+
# directory: build/jacoco/
62+
verbose: true # optional (default = false)
63+
fail_ci_if_error: false

.github/workflows/local-sqlite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Local Sqlite Support Test
22
on:
33
push:
4-
branches: [ master, eugene/* ]
4+
branches: [ master, "*" ]
55
pull_request:
66
branches: [ master ]
77
jobs:

.github/workflows/mongodb.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: MongoDB support test
2+
on:
3+
push:
4+
branches: [ master, "mongodb*", "*mongodb*" ]
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
unit_test:
9+
runs-on: ubuntu-latest
10+
11+
# Configuration, for us to perform test against multiple version in the future
12+
strategy:
13+
matrix:
14+
mongodb-version: ['5.0']
15+
16+
# The test step
17+
steps:
18+
# Start the mongoDB
19+
- name: Start MongoDB
20+
uses: supercharge/mongodb-github-action@1.7.0
21+
with:
22+
mongodb-version: ${{ matrix.mongodb-version }}
23+
24+
# The usual checkout, and test
25+
- uses: actions/checkout@v1
26+
- name: Init submodules
27+
run: ./git-init-submodules.sh
28+
- name: Set up JDK 1.8
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: 1.8
32+
- name: Cache Gradle packages
33+
uses: actions/cache@v2
34+
with:
35+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/build.gradle') }}
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
- name: Setup gradle binaries
40+
run: ./gradlew
41+
- name: Pull dependencies libs, and perform initial compile
42+
run: ./gradlew src
43+
- name: Run unit tests
44+
run: ./gradlew test -Ptest_mongodb
45+
- name: Run jacocoTestReport
46+
run: ./gradlew jacocoTestReport
47+
- name: Archive code coverage results
48+
uses: actions/upload-artifact@v2
49+
if: always()
50+
with:
51+
name: test-result-report
52+
path: |
53+
build/reports/**/*
54+
build/test-results/**/*
55+
build/jacoco/**/*
56+
- name: Upload code coverage to codecov
57+
uses: codecov/codecov-action@v2
58+
if: always()
59+
with:
60+
# flags: gradle-build # optional
61+
# directory: build/jacoco/
62+
verbose: true # optional (default = false)
63+
fail_ci_if_error: false

.github/workflows/perf_mongodb.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: (perf) MongoDB support test
2+
on:
3+
push:
4+
branches: [ perf, "mongodb*", "*mongodb*" ]
5+
pull_request:
6+
branches: [ perf ]
7+
jobs:
8+
unit_test:
9+
runs-on: ubuntu-latest
10+
11+
# Configuration, for us to perform test against multiple version in the future
12+
strategy:
13+
matrix:
14+
mongodb-version: ['5.0']
15+
16+
# The test step
17+
steps:
18+
# Start the mongoDB
19+
- name: Start MongoDB
20+
uses: supercharge/mongodb-github-action@1.7.0
21+
with:
22+
mongodb-version: ${{ matrix.mongodb-version }}
23+
24+
# The usual checkout, and test
25+
- uses: actions/checkout@v1
26+
- name: Init submodules
27+
run: ./git-init-submodules.sh
28+
- name: Set up JDK 1.8
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: 1.8
32+
- name: Cache Gradle packages
33+
uses: actions/cache@v2
34+
with:
35+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/build.gradle') }}
36+
path: |
37+
~/.gradle/caches
38+
~/.gradle/wrapper
39+
- name: Setup gradle binaries
40+
run: ./gradlew
41+
- name: Pull dependencies libs, and perform initial compile
42+
run: ./gradlew src
43+
# - name: Run unit tests
44+
# run: ./gradlew test -Ptest_mongodb
45+
- name: Run perf unit tests
46+
run: |
47+
./gradle-test-classpath.sh picoded.dstack.mongodb.MongoDB_DataObjectMap_perf
48+
- name: Run jacocoTestReport
49+
run: ./gradlew jacocoTestReport
50+
- name: Archive code coverage results
51+
uses: actions/upload-artifact@v2
52+
if: always()
53+
with:
54+
name: test-result-report
55+
path: |
56+
build/reports/**/*
57+
build/test-results/**/*
58+
build/jacoco/**/*
59+
- name: Upload code coverage to codecov
60+
uses: codecov/codecov-action@v2
61+
if: always()
62+
with:
63+
# flags: gradle-build # optional
64+
# directory: build/jacoco/
65+
verbose: true # optional (default = false)
66+
fail_ci_if_error: false

build.gradle

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ plugins {
2121

2222
// Dependency providers to fetch from
2323
repositories {
24-
// Use jcenter for resolving your dependencies.
25-
jcenter()
26-
27-
// Alterantively maven central could be used instead
24+
// Use maven central to resolve dependencies
2825
mavenCentral()
2926

27+
// Use jcenter as an alternative
28+
jcenter()
29+
3030
// You can declare any other Maven/Ivy/file repository here.
3131
}
3232

@@ -109,6 +109,9 @@ dependencies {
109109
// api "com.hazelcast:hazelcast:3.11.4"
110110
// api "com.hazelcast:hazelcast-client:3.11.4"
111111

112+
// Mongo DB
113+
api 'org.mongodb:mongodb-driver-sync:4.5.1'
114+
112115
// PostgresSQL library
113116
api "org.postgresql:postgresql:42.2.5"
114117

@@ -245,24 +248,36 @@ test {
245248
exclude "**/*_perf*"
246249
}
247250

248-
// Include mssql, mysql, and oracle test only if they are configured respectively
251+
// Include specific DB test only if they are configured respectively
249252
//
250253
// You can enable any of them by running the `gradle test` command with their `-P`
251254
// option, for example `gradle test -Ptest_mssql`
252-
if(!project.hasProperty("test_mssql")) {
253-
exclude "**/*Mssql*"
254-
}
255-
if(!project.hasProperty("test_oracle")) {
256-
exclude "**/*Oracle*"
257-
}
258-
if(!project.hasProperty("test_mysql")) {
259-
exclude "**/*Mysql*"
260-
}
261-
if(!project.hasProperty("test_postgres")) {
262-
exclude "**/*Postgres*"
263-
}
264-
if(!project.hasProperty("test_sqlite")) {
265-
exclude "**/*Sqlite*"
255+
if(project.hasProperty("test_all")) {
256+
// does nothing, no exclusions needed
257+
} else {
258+
if(!project.hasProperty("test_mssql")) {
259+
exclude "**/*Mssql*"
260+
}
261+
if(!project.hasProperty("test_oracle")) {
262+
exclude "**/*Oracle*"
263+
}
264+
if(!project.hasProperty("test_mysql")) {
265+
exclude "**/*Mysql*"
266+
}
267+
if(!project.hasProperty("test_postgres")) {
268+
exclude "**/*Postgres*"
269+
}
270+
if(!project.hasProperty("test_sqlite")) {
271+
exclude "**/*Sqlite*"
272+
}
273+
if(!project.hasProperty("test_hazelcast")) {
274+
exclude "**/*Hazelcast*"
275+
exclude "**/*hazelcast*"
276+
exclude "**/*HJ_*"
277+
}
278+
if(!project.hasProperty("test_mongodb")) {
279+
exclude "**/*MongoDB*"
280+
}
266281
}
267282

268283
// Setup test to run on parllel threads = to number of processors by default
@@ -336,24 +351,36 @@ task incrementalTest(type: TestWatcher) {
336351
exclude "**/perf/*.java"
337352
exclude "**/*_perf*"
338353

339-
// Include mssql, mysql, and oracle test only if they are configured respectively
354+
// Include specific DB test only if they are configured respectively
340355
//
341356
// You can enable any of them by running the `gradle test` command with their `-P`
342357
// option, for example `gradle test -Ptest_mssql`
343-
if(!project.hasProperty("test_mssql")) {
344-
exclude "**/*Mssql*"
345-
}
346-
if(!project.hasProperty("test_oracle")) {
347-
exclude "**/*Oracle*"
348-
}
349-
if(!project.hasProperty("test_mysql")) {
350-
exclude "**/*Mysql*"
351-
}
352-
if(!project.hasProperty("test_postgres")) {
353-
exclude "**/*Postgres*"
354-
}
355-
if(!project.hasProperty("test_sqlite")) {
356-
exclude "**/*Sqlite*"
358+
if(project.hasProperty("test_all")) {
359+
// does nothing, no exclusions needed
360+
} else {
361+
if(!project.hasProperty("test_mssql")) {
362+
exclude "**/*Mssql*"
363+
}
364+
if(!project.hasProperty("test_oracle")) {
365+
exclude "**/*Oracle*"
366+
}
367+
if(!project.hasProperty("test_mysql")) {
368+
exclude "**/*Mysql*"
369+
}
370+
if(!project.hasProperty("test_postgres")) {
371+
exclude "**/*Postgres*"
372+
}
373+
if(!project.hasProperty("test_sqlite")) {
374+
exclude "**/*Sqlite*"
375+
}
376+
if(!project.hasProperty("test_hazelcast")) {
377+
exclude "**/*Hazelcast*"
378+
exclude "**/*hazelcast*"
379+
exclude "**/*HJ_*"
380+
}
381+
if(!project.hasProperty("test_mongodb")) {
382+
exclude "**/*MongoDB*"
383+
}
357384
}
358385

359386
// Setup test to run on parllel threads = to number of processors by default

gradle-test-classpath.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ then
66
exit 1
77
fi
88

9-
./gradlew test -Ptest_mysql -Ptest_sqlite -Ptest_mssql -Ptest_oracle -Ptest_postgres -Ptest_perf --tests $1
9+
./gradlew test -Ptest_all -Ptest_perf --tests $1

src/main/java/picoded/dstack/DataObjectMap.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,18 @@ default Set<String> getKeyNames(int seekDepth) {
335335
Set<String> res = new HashSet<String>();
336336

337337
// Iterate the list, get key names
338-
int idx = 0;
339-
for (DataObject obj : values()) {
340-
341-
// Break iteration once seekdepth limits reached
342-
if (idx >= seekDepth && seekDepth >= 0) {
343-
break;
338+
DataObject obj = randomObject();
339+
res.addAll(obj.keySet());
340+
341+
// Lets iterate through
342+
for (int i = 1; i < seekDepth; ++i) {
343+
obj = looselyIterateObject(obj);
344+
if (obj != null) {
345+
res.addAll(obj.keySet());
344346
}
345-
346-
// Add all the various key names
347-
res.addAll(obj.keySet());
348347
}
349348

349+
// Return the result set
350350
return res;
351351
}
352352

0 commit comments

Comments
 (0)