Skip to content

Commit 0b55213

Browse files
author
mpv1989
committed
Add cluster tests
1 parent 0d65bce commit 0b55213

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,72 @@ public void createCollection() {
119119
}
120120
}
121121

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

0 commit comments

Comments
 (0)