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

Run integration tests on Cosmos DB #237

Merged
merged 9 commits into from
Feb 14, 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
6 changes: 5 additions & 1 deletion testware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ To run tests on an external Gremlin Server use the `configPath` parameter, for e
#### Run Integration Tests on AWS Neptune

* Setup port forwarding or run inside VPC
* Run `gradle :testware:integration-test-suites:suite --tests "org.opencypher.gremlin.suites.NeptuneSuite" -DconfigPath=/path/to/neptune-client.yaml -Dtranslate=neptune`
* Run `gradle :testware:integration-test-suites:suite --tests "org.opencypher.gremlin.suites.NeptuneSuite" -DconfigPath=/path/to/neptune-client.yaml -Dtranslate=neptune`

#### Run Integration Tests on CosmosDB

* Run `gradle :testware:integration-test-suites:suite --tests "org.opencypher.gremlin.suites.CosmosDBSuite" -DconfigPath=/path/to/cosmosdb-client.yaml -Dtranslate=cosmosdb`
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2018 "Neo4j, Inc." [https://neo4j.com]
*
* 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 org.opencypher.gremlin.suites;

import org.junit.experimental.categories.Categories;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.opencypher.gremlin.groups.SkipCollectionsInProperties;
import org.opencypher.gremlin.groups.SkipExtensions;
import org.opencypher.gremlin.groups.SkipWithCosmosDB;
import org.opencypher.gremlin.queries.CaseTest;
import org.opencypher.gremlin.queries.CastTest;
import org.opencypher.gremlin.queries.ComparisonTest;
import org.opencypher.gremlin.queries.ComplexExamplesTest;
import org.opencypher.gremlin.queries.ContainerIndexTest;
import org.opencypher.gremlin.queries.CreateTest;
import org.opencypher.gremlin.queries.DeleteTest;
import org.opencypher.gremlin.queries.ExplainTest;
import org.opencypher.gremlin.queries.ExpressionTest;
import org.opencypher.gremlin.queries.FunctionTest;
import org.opencypher.gremlin.queries.ListComprehensionTest;
import org.opencypher.gremlin.queries.ListSliceTest;
import org.opencypher.gremlin.queries.LiteralTest;
import org.opencypher.gremlin.queries.MatchTest;
import org.opencypher.gremlin.queries.MergeTest;
import org.opencypher.gremlin.queries.NativeTraversalTest;
import org.opencypher.gremlin.queries.NullTest;
import org.opencypher.gremlin.queries.OptionalMatchTest;
import org.opencypher.gremlin.queries.OrderByTest;
import org.opencypher.gremlin.queries.ParameterTest;
import org.opencypher.gremlin.queries.PercentileTest;
import org.opencypher.gremlin.queries.ProcedureTest;
import org.opencypher.gremlin.queries.RangeTest;
import org.opencypher.gremlin.queries.ReturnTest;
import org.opencypher.gremlin.queries.SetTest;
import org.opencypher.gremlin.queries.SpecificsTest;
import org.opencypher.gremlin.queries.UnionTest;
import org.opencypher.gremlin.queries.UnwindTest;
import org.opencypher.gremlin.queries.VariableLengthPathTest;
import org.opencypher.gremlin.queries.WhereTest;
import org.opencypher.gremlin.queries.WithTest;

@RunWith(Categories.class)
@Categories.ExcludeCategory({
SkipWithCosmosDB.class,
SkipExtensions.class,
SkipCollectionsInProperties.class,
})
@Suite.SuiteClasses({CaseTest.class, NativeTraversalTest.class, CastTest.class, NullTest.class, ComparisonTest.class, OptionalMatchTest.class, ComplexExamplesTest.class, OrderByTest.class, ContainerIndexTest.class, ParameterTest.class, CreateTest.class, PercentileTest.class, DeleteTest.class, ProcedureTest.class, ExplainTest.class, RangeTest.class, ExpressionTest.class, ReturnTest.class, FunctionTest.class, SetTest.class, ListComprehensionTest.class, UnionTest.class, ListSliceTest.class, UnwindTest.class, LiteralTest.class, VariableLengthPathTest.class, MatchTest.class, WhereTest.class, MergeTest.class, WithTest.class, SpecificsTest.class})
public class CosmosDBSuite {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright (c) 2018 "Neo4j, Inc." [https://neo4j.com]
*
* 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 org.opencypher.gremlin.groups;

import org.opencypher.gremlin.queries.LiteralTest;
import org.opencypher.gremlin.queries.SpecificsTest;
import org.opencypher.gremlin.translation.ir.rewrite.CosmosDbFlavor;
import org.opencypher.gremlin.translation.ir.rewrite.CustomFunctionFallback;

/**
* Tests that are skipped because of Cosmos DB specifics. Refer to categories for more details.
*/
public interface SkipWithCosmosDB {
/**
* from() and to() modulators are not supported for path() step
*
* @see SpecificsTest#pathFromToNotSupported()
* @see CosmosDbFlavor#removeFromTo
*/
interface PathFromToNotSupported extends SkipWithCosmosDB {
}

/**
* min() and max() on not existing values causes "is not a valid number" exception
*
* @see SpecificsTest#minMaxBugs()
*/
interface MinMaxBugs extends SkipWithCosmosDB {
}

/**
* No <a href="http://tinkerpop.apache.org/docs/current/reference/#math-step">Math</a> Step
*
* @see SpecificsTest#noMath()
*/
interface NoMath extends SkipWithCosmosDB {
}

/**
* No <a href="http://tinkerpop.apache.org/docs/current/reference/#choose-step">none</a> token
*
* @see SpecificsTest#noNoneToken()
*/
interface NoNoneToken extends SkipWithCosmosDB {
}

/**
* Response chunks truncated to 4096 bytes on Azure server side.
* Large responses are unparseable because of invalid JSON
*
* @see SpecificsTest#return100Elements()
*/
interface Truncate4096 extends SkipWithCosmosDB {
}

/**
* Traversal in property not supported
*
* @see SpecificsTest#traversalInProperty()
*/
interface TraversalInProperty extends SkipWithCosmosDB {
}

/**
* No <a href="http://tinkerpop.apache.org/docs/current/reference/#loops-step">Loops</a> Step which is required for
* range implementation. Workaround is applied in rewriter {@link CosmosDbFlavor#rewriteRange}, which doesn't cover
* all cases.
*
* @see CosmosDbFlavor#rewriteRange
* @see SpecificsTest#loopsStep()
*/
interface LoopsStepNotSupported extends SkipWithCosmosDB {
}

/**
* Inner traversals are not <a href="https://github.com/Azure/azure-documentdb-dotnet/issues/316">supported</a>
*
* @see SpecificsTest#innerTraversals()
*/
interface InnerTraversals extends SkipWithCosmosDB {
}

/**
* Inconsistent behaviour on realiasing items
*
* @see SpecificsTest#realiasingCreatesCollection()
*/
interface RealiasingCreatesCollection extends SkipWithCosmosDB {
}

/**
* Inconsistent behaviour of <a href="http://tinkerpop.apache.org/docs/current/reference/#choose-step">choose step</a>
*
* @see SpecificsTest#choose()
*/
interface Choose extends SkipWithCosmosDB {
}

/**
* Range with negative values has different behaviour with reference implementation
*
* @see SpecificsTest#negativeRange()
*/
interface NegativeRange extends SkipWithCosmosDB {
}

/**
* Sign is lost on negative values
*
* @see SpecificsTest#signIsLost() ()
*/
interface SignIsLost extends SkipWithCosmosDB {
}

/**
* `[:]` is not recognized as empty map
*
* @see LiteralTest#returnEmptyMap()
*/
interface EmptyMap extends SkipWithCosmosDB {
}

/**
* `neq` predicate does not work on different types
*
* @see SpecificsTest#neqOnDifferentTypes()
* @see CosmosDbFlavor#neqOnDiff
*/
interface IsNeqOnDifferentTypes extends SkipWithCosmosDB {
}

/**
* Inconsistent behaviour of <a href="http://tinkerpop.apache.org/docs/current/reference/#_values_step">values step</a>
*
* @see SpecificsTest#setAndGetEdgeProperty()
*/
interface ValuesDoesNotWorkInSomeCases extends SkipWithCosmosDB {
}

/**
* Cypher for Gremlin uses workaround {@link CustomFunctionFallback} to
* <a href="https://stackoverflow.com/questions/53734954/how-can-i-return-meaningful-errors-in-gremlin">throw error in Gremlin</a>
* Workaround is not applicable in Cosmos DB
*/
interface NoKnownWayToThrowRuntimeException extends SkipWithCosmosDB {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.opencypher.gremlin.groups.SkipWithCosmosDB;
import org.opencypher.gremlin.rules.GremlinServerExternalResource;
import org.opencypher.gremlin.test.TestCommons;

Expand All @@ -42,6 +44,7 @@ private List<Map<String, Object>> submitAndGet(String cypher) {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleFormNumericMatch() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n:person) RETURN " +
Expand All @@ -59,6 +62,7 @@ public void simpleFormNumericMatch() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleFormStringMatch() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n:software) RETURN\n" +
Expand All @@ -74,6 +78,7 @@ public void simpleFormStringMatch() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleFormPartialMatch() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n:person) RETURN " +
Expand All @@ -88,6 +93,7 @@ public void simpleFormPartialMatch() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Choose.class)
public void predicateMatch() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) RETURN " +
Expand All @@ -104,6 +110,7 @@ public void predicateMatch() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Choose.class)
public void orderWhenMatching2Predicates() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n:person) RETURN\n" +
Expand All @@ -119,6 +126,7 @@ public void orderWhenMatching2Predicates() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleFormMatchUnexpectedNulls() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) RETURN " +
Expand All @@ -133,6 +141,7 @@ public void simpleFormMatchUnexpectedNulls() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleMatchDifferentTypes() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"UNWIND [13, 3.14, 'bingo', true, null, ['a']] AS n RETURN CASE n " +
Expand All @@ -151,6 +160,7 @@ public void simpleMatchDifferentTypes() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleReturnDifferentTypes() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) RETURN " +
Expand All @@ -170,6 +180,7 @@ public void simpleReturnDifferentTypes() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Choose.class)
public void returnDifferentTypes() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) RETURN " +
Expand All @@ -189,6 +200,7 @@ public void returnDifferentTypes() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoMath.class)
public void labelPredicatesWithAggregationProjection() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) " +
Expand All @@ -205,6 +217,7 @@ public void labelPredicatesWithAggregationProjection() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Choose.class)
public void caseInWhere() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) WHERE " +
Expand All @@ -221,6 +234,7 @@ public void caseInWhere() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.NoNoneToken.class)
public void simpleCaseInWhere() throws Exception {
List<Map<String, Object>> results = submitAndGet(
"MATCH (n) WHERE " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.opencypher.gremlin.groups.SkipExtensions;
import org.opencypher.gremlin.groups.SkipWithCosmosDB;
import org.opencypher.gremlin.rules.GremlinServerExternalResource;

public class ComplexExamplesTest {
Expand Down Expand Up @@ -266,6 +267,7 @@ public void biDirectionalPath() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Truncate4096.class)
public void matchAndReverseOptionalMatch() throws Exception {
submitAndGet("CREATE (:A {name: 'A'})-[:T {name: 'T'}]->(:B {name: 'B'})");
List<Map<String, Object>> results = submitAndGet(
Expand Down Expand Up @@ -335,6 +337,7 @@ public void optionalMatchOnEmptyGraph() throws Exception {
}

@Test
@Category(SkipWithCosmosDB.Choose.class)
public void doubleWithMerge() throws Exception {
submitAndGet("CREATE ({id: 0})");
List<Map<String, Object>> results = submitAndGet(
Expand Down
Loading