Skip to content

Commit

Permalink
Enlarged timeout for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Feb 1, 2022
1 parent 1f3e115 commit 440ab28
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 117 deletions.
46 changes: 21 additions & 25 deletions e2e/src/test/java/com/arcadedb/e2e/ArcadeContainerTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,26 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;

public abstract class ArcadeContainerTemplate {

static final GenericContainer ARCADE;

static {
ARCADE = new GenericContainer("arcadedata/arcadedb:latest")
.withExposedPorts(2480, 6379, 5432, 8182)
.withEnv("arcadedb.server.rootPassword", "playwithdata")
.withEnv("arcadedb.server.defaultDatabases", "beer[root]{import:https://github.com/ArcadeData/arcadedb-datasets/raw/main/orientdb/OpenBeer.gz}")
.withEnv("arcadedb.server.plugins", "Redis:com.arcadedb.redis.RedisProtocolPlugin, " +
"MongoDB:com.arcadedb.mongo.MongoDBProtocolPlugin, " +
"Postgres:com.arcadedb.postgres.PostgresProtocolPlugin, " +
"GremlinServer:com.arcadedb.server.gremlin.GremlinServerPlugin")
.waitingFor(Wait.forListeningPort());
ARCADE.start();
}

protected String host = ARCADE.getHost();
import java.time.*;

protected int httpPort = ARCADE.getMappedPort(2480);

protected int redisPort = ARCADE.getMappedPort(6379);

protected int pgsqlPort = ARCADE.getMappedPort(5432);

protected int gremlinPort = ARCADE.getMappedPort(8182);
public abstract class ArcadeContainerTemplate {
static final GenericContainer ARCADE;

static {
ARCADE = new GenericContainer("arcadedata/arcadedb:latest").withExposedPorts(2480, 6379, 5432, 8182)//
.withStartupTimeout(Duration.ofSeconds(90))//
.withEnv("arcadedb.server.rootPassword", "playwithdata")
.withEnv("arcadedb.server.defaultDatabases", "beer[root]{import:https://github.com/ArcadeData/arcadedb-datasets/raw/main/orientdb/OpenBeer.gz}")
.withEnv("arcadedb.server.plugins", "Redis:com.arcadedb.redis.RedisProtocolPlugin, " +//
"MongoDB:com.arcadedb.mongo.MongoDBProtocolPlugin, " +//
"Postgres:com.arcadedb.postgres.PostgresProtocolPlugin, " +//
"GremlinServer:com.arcadedb.server.gremlin.GremlinServerPlugin").waitingFor(Wait.forListeningPort());
ARCADE.start();
}

protected String host = ARCADE.getHost();
protected int httpPort = ARCADE.getMappedPort(2480);
protected int redisPort = ARCADE.getMappedPort(6379);
protected int pgsqlPort = ARCADE.getMappedPort(5432);
protected int gremlinPort = ARCADE.getMappedPort(8182);
}
96 changes: 46 additions & 50 deletions e2e/src/test/java/com/arcadedb/e2e/JdbcQueriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,75 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.sql.*;
import java.util.*;

import static org.assertj.core.api.Assertions.assertThat;

public class JdbcQueriesTest extends ArcadeContainerTemplate {

private Connection conn;
private Connection conn;

@BeforeAll
static void beforeAll() throws ClassNotFoundException {
Class.forName("org.postgresql.Driver");
}
@BeforeAll
static void beforeAll() throws ClassNotFoundException {
Class.forName("org.postgresql.Driver");
}

@BeforeEach
void setUp() throws Exception {
Properties props = new Properties();
props.setProperty("user", "root");
props.setProperty("password", "playwithdata");
props.setProperty("ssl", "false");
@BeforeEach
void setUp() throws Exception {
Properties props = new Properties();
props.setProperty("user", "root");
props.setProperty("password", "playwithdata");
props.setProperty("ssl", "false");

conn = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + pgsqlPort + "/beer", props);
}
conn = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + pgsqlPort + "/beer", props);
}

@AfterEach
void tearDown() throws SQLException {
conn.close();
}
@AfterEach
void tearDown() throws SQLException {
conn.close();
}

@Test
void simpleSQLQuery() throws Exception {
@Test
void simpleSQLQuery() throws Exception {

try (Statement st = conn.createStatement()) {
try (Statement st = conn.createStatement()) {

try (java.sql.ResultSet rs = st.executeQuery("SELECT * FROM Beer limit 1")) {
assertThat(rs.next()).isTrue();
try (java.sql.ResultSet rs = st.executeQuery("SELECT * FROM Beer limit 1")) {
assertThat(rs.next()).isTrue();

assertThat(rs.getString("name")).isNotBlank();
assertThat(rs.getString("name")).isNotBlank();

assertThat(rs.next()).isFalse();
}
}
assertThat(rs.next()).isFalse();
}
}
}

@Test
void simpleGremlinQuery() throws Exception {

try (Statement st = conn.createStatement()) {
@Test
void simpleGremlinQuery() throws Exception {
try (Statement st = conn.createStatement()) {

try (java.sql.ResultSet rs = st.executeQuery("{gremlin}g.V().limit(1)")) {
assertThat(rs.next()).isTrue();
try (java.sql.ResultSet rs = st.executeQuery("{gremlin}g.V().limit(1)")) {
assertThat(rs.next()).isTrue();

assertThat(rs.getString("name")).isNotBlank();
assertThat(rs.getString("name")).isNotBlank();

assertThat(rs.next()).isFalse();
}
}
assertThat(rs.next()).isFalse();
}
}
@Test
void simpleCypherQuery() throws Exception {
}

try (Statement st = conn.createStatement()) {
@Test
void simpleCypherQuery() throws Exception {
try (Statement st = conn.createStatement()) {

try (java.sql.ResultSet rs = st.executeQuery("{cypher}MATCH(p:Beer) RETURN * LIMIT 1")) {
assertThat(rs.next()).isTrue();
try (java.sql.ResultSet rs = st.executeQuery("{cypher}MATCH(p:Beer) RETURN * LIMIT 1")) {
assertThat(rs.next()).isTrue();

assertThat(rs.getString("name")).isNotBlank();
assertThat(rs.getString("name")).isNotBlank();

assertThat(rs.next()).isFalse();
}
}
assertThat(rs.next()).isFalse();
}
}
}
}
66 changes: 32 additions & 34 deletions e2e/src/test/java/com/arcadedb/e2e/RemoteDatabaseQueriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,41 @@
import static org.assertj.core.api.Assertions.assertThat;

public class RemoteDatabaseQueriesTest extends ArcadeContainerTemplate {
private RemoteDatabase database;

private RemoteDatabase database;
@BeforeEach
void setUp() {
database = new RemoteDatabase(host, httpPort, "beer", "root", "playwithdata");
// ENLARGE THE TIMEOUT TO PASS THESE TESTS ON CI (GITHUB ACTIONS)
database.setTimeout(60_000);
}

@BeforeEach
void setUp() {
database = new RemoteDatabase(host, httpPort, "beer", "root", "playwithdata");
database.setTimeout(10000);
}
@AfterEach
void tearDown() {
database.close();
}

@AfterEach
void tearDown() {
database.close();
}
@Test
void simpleSQLQuery() {
database.transaction(() -> {
ResultSet result = database.query("SQL", "select from Beer limit 10");
assertThat(result.countEntries()).isEqualTo(10);
});
}

@Test
void simpleSQLQuery() {
database.transaction(() -> {
ResultSet result = database.query("SQL", "select from Beer limit 10");
assertThat(result.countEntries()).isEqualTo(10);
});

}

@Test
void simpleGremlinQuery() {
database.transaction(() -> {
ResultSet result = database.query("gremlin", "g.V().limit(10)");
assertThat(result.countEntries()).isEqualTo(10);
});
}

@Test
void simpleCypherQuery() {
database.transaction(() -> {
ResultSet result = database.query("cypher", "MATCH(p:Beer) RETURN * LIMIT 10");
assertThat(result.countEntries()).isEqualTo(10);
});
}
@Test
void simpleGremlinQuery() {
database.transaction(() -> {
ResultSet result = database.query("gremlin", "g.V().limit(10)");
assertThat(result.countEntries()).isEqualTo(10);
});
}

@Test
void simpleCypherQuery() {
database.transaction(() -> {
ResultSet result = database.query("cypher", "MATCH(p:Beer) RETURN * LIMIT 10");
assertThat(result.countEntries()).isEqualTo(10);
});
}
}
21 changes: 13 additions & 8 deletions network/src/main/java/com/arcadedb/remote/RemoteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@
import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.database.RID;
import com.arcadedb.exception.ArcadeDBException;
import com.arcadedb.exception.ConcurrentModificationException;
import com.arcadedb.exception.*;
import com.arcadedb.exception.DatabaseOperationException;
import com.arcadedb.exception.DuplicatedKeyException;
import com.arcadedb.exception.NeedRetryException;
import com.arcadedb.exception.RecordNotFoundException;
import com.arcadedb.exception.SchemaException;
import com.arcadedb.exception.TimeoutException;
import com.arcadedb.exception.TransactionException;
import com.arcadedb.log.LogManager;
import com.arcadedb.network.binary.QuorumNotReachedException;
import com.arcadedb.network.binary.ServerIsNotTheLeaderException;
Expand All @@ -38,13 +45,11 @@
import org.json.JSONArray;
import org.json.JSONObject;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.io.*;
import java.net.*;
import java.nio.charset.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.*;

public class RemoteDatabase extends RWLockContext {

Expand All @@ -62,7 +67,7 @@ public class RemoteDatabase extends RWLockContext {
private CONNECTION_STRATEGY connectionStrategy = CONNECTION_STRATEGY.ROUND_ROBIN;
private Pair<String, Integer> leaderServer;
private int currentReplicaServerIndex = -1;
private int timeout = 5000;
private int timeout;
private static final String protocol = "http";
private static final String charset = "UTF-8";
private String sessionId;
Expand Down

0 comments on commit 440ab28

Please sign in to comment.