Skip to content

Feature/make tests fast again #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/arangodb/internal/ArangoDBImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ArangoDBImpl(final VstCommunicationSync.Builder vstBuilder, final HttpCom

hostResolver.init(this.executor(), util());

LOGGER.info("ArangoDB Client is ready to use");
LOGGER.debug("ArangoDB Client is ready to use");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected HostHandler createHostHandler(final HostResolver hostResolver) {
hostHandler = new FallbackHostHandler(hostResolver);
}

LOG.info("HostHandler is " + hostHandler.getClass().getSimpleName());
LOG.debug("HostHandler is " + hostHandler.getClass().getSimpleName());

return new DirtyReadHostHandler(hostHandler, new RoundRobinHostHandler(hostResolver));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public HostSet resolve(boolean initial, boolean closeConnections) {
lastUpdate = System.currentTimeMillis();

final Collection<String> endpoints = resolveFromServer();
LOGGER.info("Resolve " + endpoints.size() + " Endpoints");
LOGGER.debug("Resolve " + endpoints.size() + " Endpoints");
LOGGER.debug("Endpoints " + Arrays.deepToString(endpoints.toArray()));

if (!endpoints.isEmpty()) {
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/com/arangodb/ArangoCollectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ public class ArangoCollectionTest extends BaseTest {

public ArangoCollectionTest(final Builder builder) {
super(builder);
db.createCollection(COLLECTION_NAME, null);
try {
db.createCollection(COLLECTION_NAME, null);
} catch (final ArangoDBException e) {

}
}

@After
public void teardown() {
db.collection(COLLECTION_NAME).truncate();
try {db.collection(COLLECTION_NAME).drop();} catch (final ArangoDBException e) {};
try {db.collection(EDGE_COLLECTION_NAME).drop();} catch (final ArangoDBException e) {};
try {db.collection(COLLECTION_NAME + "_1").drop();} catch (final ArangoDBException e) {};
}

@Test
Expand Down
29 changes: 10 additions & 19 deletions src/test/java/com/arangodb/ArangoDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,10 @@ public void getVersion() {
}

@Test
public void createDatabase() {
try {
final Boolean result = arangoDB.createDatabase(BaseTest.TEST_DB);
assertThat(result, is(true));
} finally {
try {
arangoDB.db(BaseTest.TEST_DB).drop();
} catch (final ArangoDBException e) {
}
}
}

@Test
public void deleteDatabase() {
final Boolean resultCreate = arangoDB.createDatabase(BaseTest.TEST_DB);
public void createAndDeleteDatabase() {
final Boolean resultCreate = arangoDB.createDatabase(BaseTest.TEST_DB_CUSTOM);
assertThat(resultCreate, is(true));
final Boolean resultDelete = arangoDB.db(BaseTest.TEST_DB).drop();
final Boolean resultDelete = arangoDB.db(BaseTest.TEST_DB_CUSTOM).drop();
assertThat(resultDelete, is(true));
}

Expand All @@ -123,14 +110,16 @@ public void getDatabases() {
assertThat(dbs, is(notNullValue()));
assertThat(dbs.size(), is(greaterThan(0)));
final int dbCount = dbs.size();
assertThat(dbs.iterator().next(), is("_system"));
arangoDB.createDatabase(BaseTest.TEST_DB);
//assertThat(dbs.iterator().next(), is("_system"));
assertThat(dbs, hasItem(BaseTest.TEST_DB));
arangoDB.createDatabase(BaseTest.TEST_DB_CUSTOM);
dbs = arangoDB.getDatabases();
assertThat(dbs.size(), is(greaterThan(dbCount)));
assertThat(dbs, hasItem("_system"));
assertThat(dbs, hasItem(BaseTest.TEST_DB_CUSTOM));
assertThat(dbs, hasItem(BaseTest.TEST_DB));
} finally {
arangoDB.db(BaseTest.TEST_DB).drop();
arangoDB.db(BaseTest.TEST_DB_CUSTOM).drop();
}
}

Expand Down Expand Up @@ -471,10 +460,12 @@ public void accessMultipleDatabases() {
}
}

/*
@Test
public void acquireHostList() {
final ArangoDB arango = new ArangoDB.Builder().acquireHostList(true).build();
final ArangoDBVersion version = arango.getVersion();
assertThat(version, is(notNullValue()));
}
*/
}
53 changes: 51 additions & 2 deletions src/test/java/com/arangodb/ArangoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -104,6 +106,45 @@ public class ArangoDatabaseTest extends BaseTest {
public ArangoDatabaseTest(final Builder builder) {
super(builder);
}

@Before
public void setUp() {
try {
ArangoCollection c = db.collection(COLLECTION_NAME);
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection(COLLECTION_NAME + "1");
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection(COLLECTION_NAME + "2");
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection(COLLECTION_NAME + "edge");
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection(COLLECTION_NAME + "from");
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection(COLLECTION_NAME + "to");
c.drop();
} catch (final ArangoDBException e) {
}
}

@Test
public void create() {
Expand Down Expand Up @@ -469,15 +510,21 @@ public void getCollectionsExcludeSystem() {
try {
final CollectionsReadOptions options = new CollectionsReadOptions().excludeSystem(true);
final Collection<CollectionEntity> systemCollections = db.getCollections(options);

assertThat(systemCollections.size(), is(0));
db.createCollection(COLLECTION_NAME + "1", null);
db.createCollection(COLLECTION_NAME + "2", null);
final Collection<CollectionEntity> collections = db.getCollections(options);
assertThat(collections.size(), is(2));
assertThat(collections, is(notNullValue()));
} catch (final ArangoDBException e) {
System.out.println(e.getErrorMessage());
} finally {
db.collection(COLLECTION_NAME + "1").drop();
try {
db.collection(COLLECTION_NAME + "1").drop();
db.collection(COLLECTION_NAME + "2").drop();
} catch (final ArangoDBException e) {
}
}
}

Expand Down Expand Up @@ -684,7 +731,9 @@ public void queryWithBatchSize() {
for (int i = 0; i < 10; i++, cursor.next()) {
assertThat(cursor.hasNext(), is(i != 10));
}

} catch (final ArangoDBException e) {
System.out.println(e.getErrorMessage());
System.out.println(e.getErrorNum());
} finally {
db.collection(COLLECTION_NAME).drop();
}
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/com/arangodb/ArangoEdgeCollectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Collection;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -63,18 +64,25 @@ public class ArangoEdgeCollectionTest extends BaseTest {

public ArangoEdgeCollectionTest(final Builder builder) {
super(builder);
setup();
}

@Before
public void setup() {
try {
db.graph(GRAPH_NAME).drop(true);
} catch (final ArangoDBException e) {
}

try {
db.createCollection(VERTEX_COLLECTION_NAME, null);
} catch (final ArangoDBException e) {
}

try {
db.createCollection(EDGE_COLLECTION_NAME, new CollectionCreateOptions().type(CollectionType.EDGES));
} catch (final ArangoDBException e) {
}

final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<EdgeDefinition>();
edgeDefinitions.add(new EdgeDefinition().collection(EDGE_COLLECTION_NAME).from(VERTEX_COLLECTION_NAME)
.to(VERTEX_COLLECTION_NAME));
Expand All @@ -86,6 +94,10 @@ public void teardown() {
for (final String collection : new String[] { VERTEX_COLLECTION_NAME, EDGE_COLLECTION_NAME }) {
db.collection(collection).truncate();
}

try {
db.graph(GRAPH_NAME).drop(true);
} catch (final ArangoDBException e) {}
}

private BaseEdgeDocument createEdgeValue() {
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/arangodb/ArangoGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Iterator;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -65,12 +66,12 @@ public class ArangoGraphTest extends BaseTest {

public ArangoGraphTest(final Builder builder) {
super(builder);
setup();
}

@Before
public void setup() {
try {
db.graph(GRAPH_NAME).drop();
db.graph(GRAPH_NAME).drop(true);
} catch (final ArangoDBException e1) {
}
final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<EdgeDefinition>();
Expand Down
17 changes: 16 additions & 1 deletion src/test/java/com/arangodb/ArangoSearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Collection;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -60,12 +62,24 @@ public ArangoSearchTest(final Builder builder) {

@After
public void teardown() {
try {
ArangoCollection c = db.collection("view_update_prop_test_collection");
c.drop();
} catch (final ArangoDBException e) {
}

try {
ArangoCollection c = db.collection("view_replace_prop_test_collection");
c.drop();
} catch (final ArangoDBException e) {
}

try {
db.view(VIEW_NAME).drop();
} catch (final ArangoDBException e) {
}
}

@Test
public void exists() {
if (!requireVersion(3, 4)) {
Expand Down Expand Up @@ -200,6 +214,7 @@ public void replaceProperties() {
if (!requireVersion(3, 4)) {
return;
}

db.createCollection("view_replace_prop_test_collection");
final ArangoSearch view = db.arangoSearch(VIEW_NAME);
view.create(new ArangoSearchCreateOptions());
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/com/arangodb/ArangoVertexCollectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ public void setup() {
} catch (final ArangoDBException e) {
}
final GraphCreateOptions options = new GraphCreateOptions().orphanCollections(COLLECTION_NAME);
db.createGraph(GRAPH_NAME, null, options);
try {
db.createGraph(GRAPH_NAME, null, options);
} catch (final ArangoDBException e) {
}

}

@After
public void teardown() {
db.collection(COLLECTION_NAME).truncate();
try {db.graph(GRAPH_NAME).drop();} catch (final ArangoDBException e) {}
try {db.collection(COLLECTION_NAME).drop();} catch (final ArangoDBException e) {}

}

@Test
Expand Down
14 changes: 9 additions & 5 deletions src/test/java/com/arangodb/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static Collection<ArangoDB.Builder> builders() {
}

protected static final String TEST_DB = "java_driver_test_db";
protected static final String TEST_DB_CUSTOM = "java_driver_test_db_custom";
protected static ArangoDB arangoDB;
protected static ArangoDatabase db;

Expand All @@ -50,18 +51,21 @@ public BaseTest(final ArangoDB.Builder builder) {
if (arangoDB != null) {
shutdown();
}
arangoDB = builder.build();
arangoDB = builder.build();
db = arangoDB.db(TEST_DB);

// only create the database if not existing
try {
arangoDB.db(TEST_DB).drop();
db.getVersion().getVersion();
} catch (final ArangoDBException e) {
if (e.getErrorNum() == 1228) { // DATABASE NOT FOUND
arangoDB.createDatabase(TEST_DB);
}
}
arangoDB.createDatabase(TEST_DB);
db = arangoDB.db(TEST_DB);
}

@AfterClass
public static void shutdown() {
arangoDB.db(TEST_DB).drop();
arangoDB.shutdown();
arangoDB = null;
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/arangodb/DocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public void setup() {
@After
public void teardown() {
collection.truncate();
try {
db.collection(COLLECTION_NAME).drop();
} catch (final ArangoDBException e) {

}
}

@SuppressWarnings("unchecked")
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/arangodb.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
arangodb.hosts=127.0.0.1:8529
arangodb.connections.max=1
arangodb.acquireHostList=true
arangodb.acquireHostList=false