Skip to content

Commit fe3d05e

Browse files
author
mpv1989
committed
Add cluster tests
1 parent 7b906f2 commit fe3d05e

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
@@ -111,6 +111,72 @@ public void createCollection() {
111111
}
112112
}
113113

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

0 commit comments

Comments
 (0)