Unverified Commit a853f70e authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥
Browse files

CI: Fixing integration tests.

parent 110cd163
Pipeline #171 passed with stages
in 1 minute and 37 seconds
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
This directory caches those eggs to prevent repeated downloads.
However, it is safe to delete this directory.
image: goblinogm/goblin-buildchain
cache:
paths:
- vendor
test:
services:
- name: goblinogm/gremlin-server-python:latest
alias: gremlin-server
image: goblinogm/goblin-buildchain
script:
- pip install -U -r requirements.txt
- cd docs
- make html
- python setup.py test
except:
- master
......
project-0 @ 110cd163
Subproject commit 110cd16336d7e67d40c3656cd5a651a5db49229d
[fetch]
recurseSubmodules = false
gremlinpython==3.3.0
PyYAML>=3.12
#required foir kobalos
six==1.10.0
aenum==1.4.5
aiohttp==2.3.10
inflection==0.3.1
#for kobalos testing
pytest-asyncio>=0.8.0
pytest-cache>=1.0
pytest-cov>=2.5.1
pytest-pep8>=1.0.6
pytest>=3.2.1
......@@ -16,9 +16,13 @@
# along with Goblin. If not, see <http://www.gnu.org/licenses/>.
import asyncio
import pytest
from aiogremlin.structure.graph import Graph
from gremlin_python.process.traversal import T
from aiogremlin import driver
from aiogremlin.driver.provider import TinkerGraph
from gremlin_python.driver import serializer
from aiogremlin.remote.driver_remote_connection import DriverRemoteConnection
# def pytest_generate_tests(metafunc):
......@@ -29,7 +33,7 @@ from gremlin_python.driver import serializer
def pytest_addoption(parser):
parser.addoption('--provider', default='tinkergraph',
choices=('tinkergraph', 'dse',))
parser.addoption('--gremlin-host', default='localhost')
parser.addoption('--gremlin-host', default='gremlin-server')
parser.addoption('--gremlin-port', default='8182')
......@@ -63,7 +67,7 @@ def gremlin_server():
@pytest.fixture
def unused_server_url(unused_tcp_port):
return 'http://localhost:{}/gremlin'.format(unused_tcp_port)
return 'https://localhost:{}/gremlin'.format(unused_tcp_port)
@pytest.fixture
......@@ -78,7 +82,7 @@ def gremlin_port(request):
@pytest.fixture
def gremlin_url(gremlin_host, gremlin_port):
return "http://{}:{}/gremlin".format(gremlin_host, gremlin_port)
return "ws://{}:{}/gremlin".format(gremlin_host, gremlin_port)
@pytest.fixture
......@@ -133,3 +137,37 @@ def cluster(request, gremlin_host, gremlin_port, event_loop, provider, aliases):
@pytest.fixture
def cluster_class(event_loop):
return driver.Cluster
@pytest.fixture
def remote_connection(event_loop, gremlin_url):
try:
remote_conn = event_loop.run_until_complete(
DriverRemoteConnection.open(gremlin_url, 'g'))
except OSError:
pytest.skip('Gremlin Server is not running')
else:
return remote_conn
@pytest.fixture(autouse=True)
def run_around_tests(remote_connection, event_loop):
g = Graph().traversal().withRemote(remote_connection)
async def create_graph():
await g.V().drop().iterate()
software1 = await g.addV("software").property("name", "lop").property("lang", "java").property(T.id, 3).next()
software2 = await g.addV("software").property("name", "ripple").property("lang", "java").property(T.id, 5).next()
person1 = await g.addV("person").property("name", "marko").property("age", "29").property(T.id, 1).next()
person2 = await g.addV("person").property("name", "vadas").property("age", "27").property(T.id, 2).next()
person3 = await g.addV("person").property("name", "josh").property("age", "32").property(T.id, 4).next()
person4 = await g.addV("person").property("name", "peter").property("age", "35").property(T.id, 6).next()
knows1 = await g.addE("knows").from_(person1).to(person2).property("weight", 0.5).property(T.id, 7).next()
knows2 = await g.addE("knows").from_(person1).to(person3).property("weight", 1,0).property(T.id, 8).next()
created1 = await g.addE("created").from_(person1).to(software1).property("weight", 0.4).property(T.id, 9).next()
created2 = await g.addE("created").from_(person3).to(software2).property("weight", 1.0).property(T.id, 10).next()
created3 = await g.addE("created").from_(person3).to(software1).property("weight", 1.0).property(T.id, 11).next()
created4 = await g.addE("created").from_(person4).to(software1).property("weight", 0.2).property(T.id, 12).next()
event_loop.run_until_complete(create_graph())
yield
......@@ -9,7 +9,7 @@ from gremlin_python.driver import request, serializer
@pytest.mark.asyncio
async def test_gremlin_query(event_loop, cluster):
alias = { 'g': 'g' }
cluster = await driver.Cluster.open(event_loop, aliases=alias)
cluster = await driver.Cluster.open(event_loop, aliases=alias, hosts=['gremlin-server'])
client = await cluster.connect()
assert client.aliases == alias
resp = await client.submit("1 + 1")
......@@ -22,7 +22,7 @@ async def test_gremlin_query(event_loop, cluster):
async def test_alias_serialization(event_loop):
alias = { 'g': 'g' }
message = '1 + 1'
cluster = await driver.Cluster.open(event_loop, aliases=alias)
cluster = await driver.Cluster.open(event_loop, aliases=alias, hosts=['gremlin-server'])
client = await cluster.connect()
# This is the code client/conn uses on submit
message = request.RequestMessage(
......
......@@ -25,7 +25,7 @@ from aiogremlin.driver.server import GremlinServer
@pytest.mark.asyncio
async def test_client_auto_release(cluster):
client = await cluster.connect()
client = await cluster.connect(hostname='gremlin-server')
resp = await client.submit("1 + 1")
async for msg in resp:
pass
......@@ -37,7 +37,7 @@ async def test_client_auto_release(cluster):
@pytest.mark.asyncio
async def test_alias(cluster):
client = await cluster.connect()
client = await cluster.connect(hostname='gremlin-server')
aliased_client = client.alias({"g": "g1"})
assert aliased_client._aliases == {"g": "g1"}
assert aliased_client._cluster is client._cluster
......@@ -47,11 +47,11 @@ async def test_alias(cluster):
@pytest.mark.asyncio
async def test_client_auto_release(cluster):
client = await cluster.connect(hostname='localhost')
client = await cluster.connect(hostname='gremlin-server')
resp = await client.submit("1 + 1")
async for msg in resp:
assert msg == 2
assert client._hostname == 'localhost'
assert client._hostname == 'gremlin-server'
await cluster.close()
......
......@@ -79,7 +79,7 @@ def test_cluster_config_from_json(event_loop, cluster_class):
def test_cluster_config_from_yaml(event_loop, cluster_class):
cluster = cluster_class(event_loop)
cluster = cluster_class(event_loop, host='gremlin-server')
cluster.config_from_file(dirname + '/tests/config/config.yml')
assert cluster.config['scheme'] == 'wss'
assert cluster.config['hosts'] == ['localhost']
......
......@@ -19,11 +19,12 @@ under the License.
'''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492'''
import pytest
from aiogremlin.remote.driver_remote_connection import (
DriverRemoteConnection)
from aiogremlin.structure.graph import Graph
from aiogremlin.remote.driver_remote_connection import DriverRemoteConnection
from aiogremlin.driver.protocol import GremlinServerWSProtocol
from aiogremlin.driver.aiohttp.transport import AiohttpTransport
from gremlin_python.driver.serializer import GraphSONMessageSerializer
from gremlin_python.process.traversal import T
@pytest.fixture
......@@ -44,3 +45,27 @@ def remote_connection(event_loop, gremlin_url):
pytest.skip('Gremlin Server is not running')
else:
return remote_conn
@pytest.fixture(autouse=True)
def run_around_tests(remote_connection, event_loop):
g = Graph().traversal().withRemote(remote_connection)
async def create_graph():
await g.V().drop().iterate()
software1 = await g.addV("software").property("name", "lop").property("lang", "java").property(T.id, 3).next()
software2 = await g.addV("software").property("name", "ripple").property("lang", "java").property(T.id, 5).next()
person1 = await g.addV("person").property("name", "marko").property("age", "29").property(T.id, 1).next()
person2 = await g.addV("person").property("name", "vadas").property("age", "27").property(T.id, 2).next()
person3 = await g.addV("person").property("name", "josh").property("age", "32").property(T.id, 4).next()
person4 = await g.addV("person").property("name", "peter").property("age", "35").property(T.id, 6).next()
knows1 = await g.addE("knows").from_(person1).to(person2).property("weight", 0.5).property(T.id, 7).next()
knows2 = await g.addE("knows").from_(person1).to(person3).property("weight", 1,0).property(T.id, 8).next()
created1 = await g.addE("created").from_(person1).to(software1).property("weight", 0.4).property(T.id, 9).next()
created2 = await g.addE("created").from_(person3).to(software2).property("weight", 1.0).property(T.id, 10).next()
created3 = await g.addE("created").from_(person3).to(software1).property("weight", 1.0).property(T.id, 11).next()
created4 = await g.addE("created").from_(person4).to(software1).property("weight", 0.2).property(T.id, 12).next()
event_loop.run_until_complete(create_graph())
yield
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment