Skip to content
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

Move gremlin to its own module #274

Merged
merged 12 commits into from
Jan 11, 2022
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 .github/workflows/mvn-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Test
continue-on-error: ${{ matrix.continue-on-error }}
run: mvn verify -Pintegration -Pcoverage --batch-mode --errors --fail-at-end --show-version --file pom.xml
run: mvn verify -Pintegration -Pdocker --batch-mode --errors --fail-at-end --show-version --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
85 changes: 85 additions & 0 deletions e2e/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright © 2021-present Arcade Data Ltd ([email protected])

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-parent</artifactId>
<version>22.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<properties>
<testcontainers.version>1.16.2</testcontainers.version>
<postgresql.version>42.2.24</postgresql.version>
<logback-classic.version>1.2.10</logback-classic.version>
</properties>

<artifactId>arcadedb-e2e</artifactId>
<packaging>jar</packaging>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-network</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
47 changes: 47 additions & 0 deletions e2e/src/test/java/com/arcadedb/e2e/ArcadeContainerTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright © 2021-present Arcade Data Ltd ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arcadedb.e2e;

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();

protected int httpPort = ARCADE.getMappedPort(2480);

protected int redisPort = ARCADE.getMappedPort(6379);

protected int pgsqlPort = ARCADE.getMappedPort(5432);

protected int gremlinPort = ARCADE.getMappedPort(8182);
}
69 changes: 69 additions & 0 deletions e2e/src/test/java/com/arcadedb/e2e/JdbcQueriesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright © 2021-present Arcade Data Ltd ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arcadedb.e2e;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
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 static org.assertj.core.api.Assertions.assertThat;

public class JdbcQueriesTest extends ArcadeContainerTemplate {

private Connection conn;

@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");

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

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

@Test
void simpleSQLQuery() throws Exception {

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

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

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

assertThat(rs.next()).isFalse();
}
}
}
}
58 changes: 58 additions & 0 deletions e2e/src/test/java/com/arcadedb/e2e/RemoteDatabaseQueriesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright © 2021-present Arcade Data Ltd ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arcadedb.e2e;

import com.arcadedb.query.sql.executor.ResultSet;
import com.arcadedb.remote.RemoteDatabase;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

public class RemoteDatabaseQueriesTest extends ArcadeContainerTemplate {

private RemoteDatabase database;

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

@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 simpleGremlinQuery() {
database.transaction(() -> {
ResultSet result = database.query("gremlin", "g.V().limit(10)");
assertThat(result.countEntries()).isEqualTo(10);
});
}

}
14 changes: 14 additions & 0 deletions e2e/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>

<logger name="org.testcontainers" level="INFO"/>
<logger name="com.github.dockerjava" level="WARN"/>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,60 @@
/**
* Asynchronous Task that creates the edge that connects 2 vertices.
*/
public class CreateEdgeAsyncTask extends DatabaseAsyncAbstractTask {
protected final Identifiable sourceVertex;
protected final Identifiable destinationVertex;
public class CreateEdgeAsyncTask implements DatabaseAsyncTask {
protected final Identifiable sourceVertex;
protected final Identifiable destinationVertex;

protected final String edgeType;
protected final Object[] edgeAttributes;
protected final String edgeType;
protected final Object[] edgeAttributes;

protected final boolean bidirectional;
protected final boolean light;
protected final NewEdgeCallback callback;
protected final boolean bidirectional;
protected final boolean light;
protected final NewEdgeCallback callback;

public CreateEdgeAsyncTask(final Identifiable sourceVertex, final Identifiable destinationVertex, final String edgeType, final Object[] edgeAttributes,
final boolean bidirectional, final boolean light, final NewEdgeCallback callback) {
this.sourceVertex = sourceVertex;
this.destinationVertex = destinationVertex;
public CreateEdgeAsyncTask(final Identifiable sourceVertex,
final Identifiable destinationVertex,
final String edgeType,
final Object[] edgeAttributes,
final boolean bidirectional,
final boolean light,
final NewEdgeCallback callback) {
this.sourceVertex = sourceVertex;
this.destinationVertex = destinationVertex;

this.edgeType = edgeType;
this.edgeAttributes = edgeAttributes;
this.edgeType = edgeType;
this.edgeAttributes = edgeAttributes;

this.bidirectional = bidirectional;
this.light = light;
this.callback = callback;
}
this.bidirectional = bidirectional;
this.light = light;
this.callback = callback;
}

public void execute(final DatabaseAsyncExecutorImpl.AsyncThread async, final DatabaseInternal database) {
createEdge(database, sourceVertex, destinationVertex, false, false);
}
@Override
public void execute(final DatabaseAsyncExecutorImpl.AsyncThread async, final DatabaseInternal database) {
createEdge(database, sourceVertex, destinationVertex, false, false);
}

protected void createEdge(final DatabaseInternal database, final Identifiable sourceVertex, final Identifiable destinationVertex,
final boolean createdSourceVertex, boolean createdDestinationVertex) {
protected void createEdge(final DatabaseInternal database,
final Identifiable sourceVertex,
final Identifiable destinationVertex,
final boolean createdSourceVertex,
final boolean createdDestinationVertex) {

final Edge edge;
final Edge edge;

if (light)
edge = database.getGraphEngine().newLightEdge((VertexInternal) sourceVertex.getRecord(), edgeType, destinationVertex.getIdentity(), bidirectional);
else
edge = database.getGraphEngine()
.newEdge((VertexInternal) sourceVertex.getRecord(), edgeType, destinationVertex.getIdentity(), bidirectional, edgeAttributes);
if (light)
edge = database.getGraphEngine().newLightEdge((VertexInternal) sourceVertex.getRecord(), edgeType, destinationVertex.getIdentity(), bidirectional);
else
edge = database.getGraphEngine()
.newEdge((VertexInternal) sourceVertex.getRecord(), edgeType, destinationVertex.getIdentity(), bidirectional, edgeAttributes);

if (callback != null)
callback.call(edge, createdSourceVertex, createdDestinationVertex);
}
if (callback != null)
callback.call(edge, createdSourceVertex, createdDestinationVertex);
}

@Override
public String toString() {
return "CreateEdgeAsyncTask(" + sourceVertex + "->" + destinationVertex + ")";
}
@Override
public String toString() {
return "CreateEdgeAsyncTask(" + sourceVertex + "->" + destinationVertex + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Asynchronous Task that creates the relationship between the destinationVertex and the sourceVertex as incoming.
*/
public class CreateIncomingEdgeAsyncTask extends DatabaseAsyncAbstractTask {
public class CreateIncomingEdgeAsyncTask implements DatabaseAsyncTask {
protected final RID sourceVertexRID;
protected final Identifiable destinationVertex;
protected final Identifiable edge;
Expand Down
Loading