Skip to content

Commit 06fd8c9

Browse files
author
mpv1989
committed
Add cluster tests
1 parent d40b7a4 commit 06fd8c9

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import com.arangodb.entity.BaseDocument;
5454
import com.arangodb.entity.BaseEdgeDocument;
5555
import com.arangodb.entity.CollectionEntity;
56+
import com.arangodb.entity.CollectionPropertiesEntity;
5657
import com.arangodb.entity.CollectionType;
5758
import com.arangodb.entity.DatabaseEntity;
5859
import com.arangodb.entity.GraphEntity;
@@ -62,6 +63,7 @@
6263
import com.arangodb.entity.QueryCachePropertiesEntity.CacheMode;
6364
import com.arangodb.entity.QueryEntity;
6465
import com.arangodb.entity.QueryTrackingPropertiesEntity;
66+
import com.arangodb.entity.ServerRole;
6567
import com.arangodb.entity.TraversalEntity;
6668
import com.arangodb.model.AqlFunctionDeleteOptions;
6769
import com.arangodb.model.AqlQueryOptions;
@@ -116,6 +118,75 @@ public void createCollection() throws InterruptedException, ExecutionException {
116118
}
117119
}
118120

121+
@Test
122+
public void createCollectionWithReplicationFactor() throws InterruptedException, ExecutionException {
123+
if (arangoDB.getRole().get() == ServerRole.SINGLE) {
124+
return;
125+
}
126+
try {
127+
final CollectionEntity result = db
128+
.createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2)).get();
129+
assertThat(result, is(notNullValue()));
130+
assertThat(result.getId(), is(notNullValue()));
131+
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor(), is(2));
132+
} finally {
133+
db.collection(COLLECTION_NAME).drop();
134+
}
135+
}
136+
137+
@Test
138+
public void createCollectionWithNumberOfShards() throws InterruptedException, ExecutionException {
139+
if (arangoDB.getRole().get() == ServerRole.SINGLE) {
140+
return;
141+
}
142+
try {
143+
final CollectionEntity result = db
144+
.createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2)).get();
145+
assertThat(result, is(notNullValue()));
146+
assertThat(result.getId(), is(notNullValue()));
147+
assertThat(db.collection(COLLECTION_NAME).getProperties().get().getNumberOfShards(), is(2));
148+
} finally {
149+
db.collection(COLLECTION_NAME).drop();
150+
}
151+
}
152+
153+
@Test
154+
public void createCollectionWithNumberOfShardsAndShardKey() throws InterruptedException, ExecutionException {
155+
if (arangoDB.getRole().get() == ServerRole.SINGLE) {
156+
return;
157+
}
158+
try {
159+
final CollectionEntity result = db
160+
.createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2).shardKeys("a"))
161+
.get();
162+
assertThat(result, is(notNullValue()));
163+
assertThat(result.getId(), is(notNullValue()));
164+
final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get();
165+
assertThat(properties.getNumberOfShards(), is(2));
166+
assertThat(properties.getShardKeys().size(), is(1));
167+
} finally {
168+
db.collection(COLLECTION_NAME).drop();
169+
}
170+
}
171+
172+
@Test
173+
public void createCollectionWithNumberOfShardsAndShardKeys() throws InterruptedException, ExecutionException {
174+
if (arangoDB.getRole().get() == ServerRole.SINGLE) {
175+
return;
176+
}
177+
try {
178+
final CollectionEntity result = db.createCollection(COLLECTION_NAME,
179+
new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b")).get();
180+
assertThat(result, is(notNullValue()));
181+
assertThat(result.getId(), is(notNullValue()));
182+
final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get();
183+
assertThat(properties.getNumberOfShards(), is(2));
184+
assertThat(properties.getShardKeys().size(), is(2));
185+
} finally {
186+
db.collection(COLLECTION_NAME).drop();
187+
}
188+
}
189+
119190
@Test
120191
public void deleteCollection() throws InterruptedException, ExecutionException {
121192
db.createCollection(COLLECTION_NAME, null).get();

0 commit comments

Comments
 (0)