Skip to content

Commit 64ffdce

Browse files
author
mpv1989
committed
Add cluster tests
1 parent c02859c commit 64ffdce

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

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

Lines changed: 70 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;
@@ -123,6 +124,75 @@ public void createCollection() throws InterruptedException, ExecutionException {
123124
}
124125
}
125126

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

0 commit comments

Comments
 (0)