Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
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
63 changes: 59 additions & 4 deletions .grabl/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ build:
bazel build //...
bazel run @graknlabs_dependencies//tool/checkstyle:test-coverage
bazel test $(bazel query 'kind(checkstyle_test, //...)') --test_output=errors
test-behaviour:
test-behaviour-connection:
image: graknlabs-ubuntu-20.04
type: foreground
command: |
Expand All @@ -61,10 +61,65 @@ build:
export ARTIFACT_PASSWORD=$REPO_GRAKN_PASSWORD
bazel run @graknlabs_dependencies//distribution/artifact:create-netrc
bazel test //tests/behaviour/connection/... --test_output=errors --jobs=1
test-behaviour-concept:
image: graknlabs-ubuntu-20.04
type: foreground
command: |
pyenv global 3.6.10
pip install -r requirements_dev.txt
sudo unlink /usr/bin/python3
sudo ln -s $(which python3) /usr/bin/python3
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
export ARTIFACT_USERNAME=$REPO_GRAKN_USERNAME
export ARTIFACT_PASSWORD=$REPO_GRAKN_PASSWORD
bazel run @graknlabs_dependencies//distribution/artifact:create-netrc
bazel test //tests/behaviour/concept/... --test_output=errors --jobs=1
test-behaviour-match:
image: graknlabs-ubuntu-20.04
type: foreground
command: |
pyenv global 3.6.10
pip install -r requirements_dev.txt
sudo unlink /usr/bin/python3
sudo ln -s $(which python3) /usr/bin/python3
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
export ARTIFACT_USERNAME=$REPO_GRAKN_USERNAME
export ARTIFACT_PASSWORD=$REPO_GRAKN_PASSWORD
bazel run @graknlabs_dependencies//distribution/artifact:create-netrc
bazel test //tests/behaviour/graql/language/match/... --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/get/... --test_output=errors --jobs=1
# TODO: add other Graql Language tests once they stabilise fully
# TODO: remove --jobs=1 from Concept and Graql tests once Grakn runner is parallelisable
test-behaviour-writable:
image: graknlabs-ubuntu-20.04
type: foreground
command: |
pyenv global 3.6.10
pip install -r requirements_dev.txt
sudo unlink /usr/bin/python3
sudo ln -s $(which python3) /usr/bin/python3
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
export ARTIFACT_USERNAME=$REPO_GRAKN_USERNAME
export ARTIFACT_PASSWORD=$REPO_GRAKN_PASSWORD
bazel run @graknlabs_dependencies//distribution/artifact:create-netrc
bazel test //tests/behaviour/graql/language/insert/... --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/delete/... --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/update:checkstyle --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/update:test-core --test_output=errors --jobs=1
test-behaviour-definable:
image: graknlabs-ubuntu-20.04
type: foreground
command: |
pyenv global 3.6.10
pip install -r requirements_dev.txt
sudo unlink /usr/bin/python3
sudo ln -s $(which python3) /usr/bin/python3
sudo ln -s /usr/share/pyshared/lsb_release.py /opt/pyenv/versions/3.6.10/lib/python3.6/site-packages/lsb_release.py
export ARTIFACT_USERNAME=$REPO_GRAKN_USERNAME
export ARTIFACT_PASSWORD=$REPO_GRAKN_PASSWORD
bazel run @graknlabs_dependencies//distribution/artifact:create-netrc
bazel test //tests/behaviour/graql/language/define:checkstyle --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/define:test-core --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/undefine:checkstyle --test_output=errors --jobs=1
bazel test //tests/behaviour/graql/language/undefine:test-core --test_output=errors --jobs=1
test-cluster-failover:
image: graknlabs-ubuntu-20.04
type: foreground
Expand All @@ -80,7 +135,7 @@ build:
bazel test //tests:test_cluster_failover --test_output=errors
deploy-pip-snapshot:
image: graknlabs-ubuntu-20.04
dependencies: [build, test-behaviour, test-cluster-failover]
dependencies: [build, test-behaviour-connection, test-behaviour-concept, test-behaviour-match, test-behaviour-writable, test-behaviour-definable, test-cluster-failover]
filter:
owner: graknlabs
branch: master
Expand Down
2 changes: 1 addition & 1 deletion dependencies/graknlabs/artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def graknlabs_grakn_core_artifacts():
artifact_name = "grakn-core-server-{platform}-{version}.{ext}",
tag_source = deployment["artifact.release"],
commit_source = deployment["artifact.snapshot"],
commit = "c2efc0a71a215b59650a3ea0e8b6f4c2c83737e3",
commit = "0efbea38aaf0f187e03168cf2c515aa5c7b44f26",
)

def graknlabs_grakn_cluster_artifacts():
Expand Down
2 changes: 1 addition & 1 deletion dependencies/graknlabs/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def graknlabs_behaviour():
git_repository(
name = "graknlabs_behaviour",
remote = "https://github.com/graknlabs/behaviour",
commit = "71f72dce4e7b46488f0f1f5a6c457018b83660c5" # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_behaviour
commit = "bc4730a40866f64decd22cb0cb35c9b6a6b77b31" # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_behaviour
)
9 changes: 9 additions & 0 deletions grakn/query/query_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def delete(self, query: str, options: GraknOptions = None):
request.delete_req.CopyFrom(delete_req)
return self._iterate_query(request, lambda res: [], options)

def update(self, query: str, options: GraknOptions = None):
if not options:
options = GraknOptions.core()
request = query_proto.Query.Req()
update_req = query_proto.Query.Update.Req()
update_req.query = query
request.update_req.CopyFrom(update_req)
return map(lambda answer_proto: concept_map._of(answer_proto), self._iterate_query(request, lambda res: res.query_res.update_res.answers, options))

def define(self, query: str, options: GraknOptions = None):
if not options:
options = GraknOptions.core()
Expand Down
8 changes: 8 additions & 0 deletions tests/behaviour/background/environment_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from tests.behaviour.config.parameters import RootLabel
from tests.behaviour.context import Context, ThingSubtype

import time

IGNORE_TAGS = ["ignore", "ignore-client-python"]


Expand Down Expand Up @@ -78,6 +80,9 @@ def after_scenario(context: Context, scenario):
if scenario.status == Status.skipped:
return

#TODO: REMOVE THIS ONCE THE CRASHES ARE FIXED
time.sleep(0.01)

for session in context.sessions:
session.close()
for future_session in context.sessions_parallel:
Expand All @@ -87,4 +92,7 @@ def after_scenario(context: Context, scenario):


def after_all(context: Context):
#TODO: REMOVE THIS ONCE THE CRASHES ARE FIXED
time.sleep(0.01)

context.client.close()
14 changes: 14 additions & 0 deletions tests/behaviour/concept/thing/relation/relation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ def step_impl(context: Context, var1: str, role_label: str, var2: str):
def step_impl(context: Context, var1: str, role_label: str, var2: str):
context.get(var1).as_remote(context.tx()).remove_player(context.get(var1).as_remote(context.tx()).get_type().as_remote(context.tx()).get_relates(role_label), context.get(var2))

@step("relation {var1:Var} add player for role({role_label}): {var2:Var}; throws exception")
def step_impl(context: Context, var1: str, role_label: str, var2: str):
adding_player_throws_exception(context, var1, role_label, var2)

def adding_player_throws_exception(context: Context, var1: str, role_label: str, var2: str):
try:
context.get(var1).as_remote(context.tx()).add_player(
context.get(var1).as_remote(context.tx()).get_type().as_remote(context.tx()).get_relates(role_label),
context.get(var2))
assert False;
except GraknClientException:
pass



@step("relation {var:Var} get players contain")
def step_impl(context: Context, var: str):
Expand Down
23 changes: 23 additions & 0 deletions tests/behaviour/graql/graql_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ def step_impl(context: Context, exception: str):
assert_that(calling(next).with_args(context.tx().query().insert(query=context.text)), raises(GraknClientException, exception))


@step("graql update")
def step_impl(context: Context):
context.tx().query().update(query=context.text)


@step("graql update; throws exception")
def step_impl(context: Context):
assert_that(calling(next).with_args(context.tx().query().update(query=context.text)), raises(GraknClientException))


@step("graql update; throws exception containing \"{exception}\"")
def step_impl(context: Context, exception: str):
assert_that(calling(next).with_args(context.tx().query().update(query=context.text)), raises(GraknClientException, exception))

@step("get answers of graql insert")
def step_impl(context: Context):
context.clear_answers()
Expand Down Expand Up @@ -136,6 +150,15 @@ def step_impl(context: Context, expected_size: int):
assert_that(context.answers, has_length(expected_size), "Expected [%d] answers, but got [%d]" % (expected_size, len(context.answers)))


@step("rules contain: {rule_label}")
def step_impl(context: Context, rule_label: str):
return rule_label in [rule.get_label() for rule in context.tx().logic().get_rules()]

@step("rules do not contain: {rule_label}")
def step_impl(context: Context, rule_label: str):
return not (rule_label in [rule.get_label() for rule in context.tx().logic().get_rules()])


class ConceptMatcher:

def matches(self, context: Context, concept: ConceptSubtype):
Expand Down
53 changes: 53 additions & 0 deletions tests/behaviour/graql/language/update/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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(default_visibility = ["//tests/behaviour:__subpackages__"])
load("//tools:behave_rule.bzl", "grakn_behaviour_py_test")
load("@graknlabs_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test")

grakn_behaviour_py_test(
name = "test",
feats = ["@graknlabs_behaviour//graql/language:update.feature"],
background_core = ["//tests/behaviour/background:core"],
background_cluster = ["//tests/behaviour/background:cluster"],
steps = [
"//tests/behaviour/connection:steps",
"//tests/behaviour/connection/database:steps",
"//tests/behaviour/connection/session:steps",
"//tests/behaviour/connection/transaction:steps",
"//tests/behaviour/graql:steps",
],
deps = [
"//:client_python",
"//tests/behaviour:context",
"//tests/behaviour:util",
"//tests/behaviour/config:parameters",
"//tests/behaviour/background",
],
native_grakn_artifact_core = "//tests:native-grakn-core-artifact",
native_grakn_artifact_cluster = "//tests:native-grakn-cluster-artifact",
size = "medium",
)

checkstyle_test(
name = "checkstyle",
include = glob(["*"]),
license_type = "apache",
size = "small",
)
2 changes: 1 addition & 1 deletion tools/cluster_test_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _rule_implementation(ctx):
./1/grakn server --data data --address=127.0.0.1:11729:11730 --peers=127.0.0.1:11729:11730,127.0.0.1:21729:21730,127.0.0.1:31729:31730 &
./2/grakn server --data data --address=127.0.0.1:21729:21730 --peers=127.0.0.1:11729:11730,127.0.0.1:21729:21730,127.0.0.1:31729:31730 &
./3/grakn server --data data --address=127.0.0.1:31729:31730 --peers=127.0.0.1:11729:11730,127.0.0.1:21729:21730,127.0.0.1:31729:31730 &
sleep 14
sleep 20

"""

Expand Down